public_api_controller.go 62KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319
  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("/handle10215", &PublicApiController{}, "get:Handle10215")
  63. beego.Router("/handelOrder", &PublicApiController{}, "get:HandleOrder")
  64. beego.Router("/handelHis", &PublicApiController{}, "get:HandleHisTwo")
  65. beego.Router("/handelProject", &PublicApiController{}, "get:HandleProject")
  66. beego.Router("/handelsettledata", &PublicApiController{}, "get:HandleSettleData")
  67. beego.Router("/handelhispatient", &PublicApiController{}, "get:HandleHisPatient")
  68. //beego.Router("/handelOrder", &PublicApiController{}, "get:HandleOrder")
  69. beego.Router("/handleExportData", &PublicApiController{}, "get:HandleExportAllData")
  70. beego.Router("/handleExportData10138", &PublicApiController{}, "get:HandleExportData10138")
  71. beego.Router("/handleData10265", &PublicApiController{}, "get:HandleData10265")
  72. beego.Router("/handleData10106", &PublicApiController{}, "get:HandleData10106")
  73. beego.Router("/handelschedule", &PublicApiController{}, "get:HandleSchedule")
  74. beego.Router("/handelscheduleTwo", &PublicApiController{}, "get:HandleScheduleTwo")
  75. }
  76. type ResultFiveT struct {
  77. Balc float64 `json:"balc"`
  78. CvlservFlag string `json:"cvlserv_flag"`
  79. EmpName string `json:"emp_name"`
  80. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  81. Insutype string `json:"insutype"`
  82. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  83. PausInsuDate string `json:"paus_insu_date"`
  84. PsnInsuDate string `json:"psn_insu_date"`
  85. PsnInsuStas string `json:"psn_insu_stas"`
  86. PsnType string `json:"psn_type"`
  87. }
  88. func (c *PublicApiController) HandleSchedule() {
  89. //fmt.Println("~~~~~~")
  90. service.GetLongSolution()
  91. }
  92. func (c *PublicApiController) HandleScheduleTwo() {
  93. models, _ := service.GetAllSchMode()
  94. for _, item := range models {
  95. if item.Mode == 1 {
  96. templates, _ := service.GetOrgPatientScheduleTemplateIDs(item.OrgID)
  97. thisTime := time.Now()
  98. _, theWeek := thisTime.ISOWeek()
  99. templates[0].Week = theWeek
  100. service.UpdateTemplateItemWeek(templates[0].OrgID, templates[0].ID, int8(templates[0].Week))
  101. } else if item.Mode == 2 {
  102. templates, _ := service.GetOrgPatientScheduleTemplateIDs(item.OrgID)
  103. now := time.Now()
  104. nextSecWeek := now.AddDate(0, 0, 14)
  105. nextWeek := now.AddDate(0, 0, 7)
  106. if item.ExecuteTimes%2 == 0 { //下第二周生成的是
  107. templates[0].Week = service.GetWeeks(nextWeek.Format("2006-01-02 15:04:05"))
  108. templates[1].Week = service.GetWeeks(nextSecWeek.Format("2006-01-02 15:04:05"))
  109. service.UpdateTemplateItemWeek(templates[0].OrgID, templates[0].ID, int8(templates[0].Week))
  110. service.UpdateTemplateItemWeek(templates[1].OrgID, templates[1].ID, int8(templates[1].Week))
  111. } else if item.ExecuteTimes%2 == 1 {
  112. templates[0].Week = service.GetWeeks(nextSecWeek.Format("2006-01-02 15:04:05"))
  113. templates[1].Week = service.GetWeeks(nextSecWeek.Format("2006-01-02 15:04:05"))
  114. service.UpdateTemplateItemWeek(templates[0].OrgID, templates[0].ID, int8(templates[0].Week))
  115. service.UpdateTemplateItemWeek(templates[1].OrgID, templates[1].ID, int8(templates[1].Week))
  116. }
  117. }
  118. }
  119. }
  120. func (c *PublicApiController) HandleHisPatient() {
  121. ps, _ := service.GetHisPatient11111(10215)
  122. for _, item := range ps {
  123. var rf []*ResultFiveT
  124. json.Unmarshal([]byte(item.Iinfo), &rf)
  125. var insuplc_admdvs string
  126. var insutype string
  127. var is390 int = 0
  128. var is310 int = 0
  129. var insutypes []*ResultFiveT
  130. for _, item := range rf {
  131. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  132. insutypes = append(insutypes, item)
  133. }
  134. }
  135. fmt.Println(insutypes)
  136. if len(insutypes) == 1 {
  137. insutype = insutypes[0].Insutype
  138. is390 = 1
  139. fmt.Println("111111")
  140. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  141. } else {
  142. fmt.Println("222222")
  143. for _, i := range insutypes {
  144. if i.Insutype == "390" {
  145. is390 = 1
  146. }
  147. if i.Insutype == "310" {
  148. is310 = 1
  149. }
  150. }
  151. }
  152. if is390 == 1 {
  153. insutype = "390"
  154. }
  155. if is310 == 1 {
  156. insutype = "310"
  157. }
  158. if len(insutypes) == 0 {
  159. insutype = "310"
  160. }
  161. for _, item := range rf {
  162. if item.Insutype == insutype {
  163. insuplc_admdvs = item.InsuplcAdmdvs
  164. }
  165. }
  166. item.InsuplcAdmdvs = insuplc_admdvs
  167. service.SaveHP(item)
  168. }
  169. }
  170. func (c *PublicApiController) HandleSettleData() {
  171. orders, _ := service.GetHisOrderDetailThree()
  172. c.ServeSuccessJSON(map[string]interface{}{
  173. "order": orders,
  174. })
  175. }
  176. //func (c *PublicApiController) HandleData10106() {
  177. // start_time := c.GetString("start_time")
  178. // end_time := c.GetString("end_time")
  179. //
  180. // timeLayout := "2006-01-02"
  181. // loc, _ := time.LoadLocation("Local")
  182. // startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  183. // if err != nil {
  184. //
  185. // }
  186. // startRecordDateTime := startTime.Unix()
  187. //
  188. // endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  189. // if err != nil {
  190. //
  191. // }
  192. // endRecordDateTime := endTime.Unix()
  193. // fmt.Println(startRecordDateTime)
  194. // fmt.Println(endRecordDateTime)
  195. //
  196. // orders, _ := service.GetHisOrderDetail10106(startRecordDateTime, endRecordDateTime)
  197. // c.ServeSuccessJSON(map[string]interface{}{
  198. // "order": orders,
  199. // })
  200. //}
  201. func (c *PublicApiController) HandleData10106() {
  202. start_time := c.GetString("start_time")
  203. end_time := c.GetString("end_time")
  204. start_time = "2022-11-01"
  205. end_time = "2022-11-30"
  206. timeLayout := "2006-01-02"
  207. loc, _ := time.LoadLocation("Local")
  208. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  209. if err != nil {
  210. }
  211. startRecordDateTime := startTime.Unix()
  212. endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  213. if err != nil {
  214. }
  215. endRecordDateTime := endTime.Unix()
  216. fmt.Println(startRecordDateTime)
  217. fmt.Println(endRecordDateTime)
  218. orders, _ := service.GetHisOrderDetail10106(startRecordDateTime, endRecordDateTime)
  219. c.ServeSuccessJSON(map[string]interface{}{
  220. "order": orders,
  221. })
  222. }
  223. func (c *PublicApiController) HandleProject() {
  224. prescriptions := service.GetAllProjectPrescription()
  225. for _, item := range prescriptions {
  226. ps := service.GetAllProject(item.ID)
  227. for _, subItem := range ps {
  228. subItem.Status = 0
  229. service.SaveHisProject(subItem)
  230. }
  231. }
  232. }
  233. func (c *PublicApiController) HandleHisTwo() {
  234. hiss := service.GetAllPrivateHis(10215)
  235. for _, item := range hiss {
  236. patient, _ := service.GetPatientByID(10215, item.PatientId)
  237. item.Gender = patient.Gender
  238. service.SaveHis(item)
  239. }
  240. }
  241. func (c *PublicApiController) GetDoctorAdviceConfig() {
  242. drugs, _, _ := service.GetPublicDrugDics()
  243. drugways, _, _ := service.GetPublicDrugWayDics()
  244. efs, _, _ := service.GetPublicExecutionFrequencyDics()
  245. c.ServeSuccessJSON(map[string]interface{}{
  246. "drugs": drugs,
  247. "drugways": drugways,
  248. "efs": efs,
  249. })
  250. }
  251. func (c *PublicApiController) GetServerTime() {
  252. timeNow := time.Now()
  253. timeNowStamp := timeNow.Unix()
  254. timeNowStr := timeNow.Format("2006-01-02 15:04:05")
  255. c.ServeSuccessJSON(map[string]interface{}{
  256. "time": timeNowStr,
  257. "timestamp": timeNowStamp,
  258. })
  259. }
  260. func (c *PublicApiController) AppRelease() {
  261. // appId := c.GetString("appid")
  262. version := c.GetString("version")
  263. appType, _ := c.GetInt64("app_type", 0)
  264. appVersion, err := service.GetAppVersionByAppType(appType)
  265. if err != nil {
  266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  267. return
  268. }
  269. if appVersion == nil {
  270. c.ServeSuccessJSON(map[string]interface{}{
  271. "version": nil,
  272. "state": 2,
  273. })
  274. return
  275. }
  276. state := strings.Compare(version, appVersion.Version)
  277. // state := 1
  278. if state < 0 {
  279. c.ServeSuccessJSON(map[string]interface{}{
  280. "version": appVersion,
  281. "state": appVersion.Status,
  282. })
  283. return
  284. }
  285. c.ServeSuccessJSON(map[string]interface{}{
  286. "version": nil,
  287. "state": 2,
  288. })
  289. return
  290. }
  291. func (this *PublicApiController) GetJson() {
  292. type Global struct {
  293. DeviceSN string
  294. Version string
  295. Timestamp string
  296. InterfaceSource string
  297. }
  298. type RBPResultModel struct {
  299. Sys string
  300. Dia string
  301. HR string
  302. MeasureTime string
  303. }
  304. type ScannerResultModel struct {
  305. Code string
  306. }
  307. type IDCardResultModel struct {
  308. IDCardNo string
  309. UserName string
  310. Age string
  311. Female string
  312. Male string
  313. SocialSecurityNo string
  314. }
  315. type JsonTemp struct {
  316. Global Global
  317. RBPResultModel RBPResultModel
  318. ScannerResultModel ScannerResultModel
  319. IDCardResultModel IDCardResultModel
  320. }
  321. var person JsonTemp
  322. err3 := json.Unmarshal([]byte(this.GetString("params")), &person)
  323. fmt.Println(err3)
  324. fmt.Println(person.Global)
  325. //temp := JsonTemp{
  326. // Global:Global{
  327. // DeviceSN:"1122",
  328. // Version:"1122",
  329. // Timestamp:"1222",
  330. // InterfaceSource:"1233",
  331. // },
  332. // RBPResultModel: RBPResultModel{
  333. // Sys:"12",
  334. // Dia:"22",
  335. // HR:"23",
  336. // MeasureTime:"123",
  337. // },
  338. // ScannerResultModel:ScannerResultModel{
  339. // Code:"1233",
  340. // },
  341. // IDCardResultModel:IDCardResultModel{
  342. // IDCardNo:"123",
  343. // UserName:"123",
  344. // Age:"123",
  345. // Female:"123",
  346. // Male:"123",
  347. // SocialSecurityNo:"123",
  348. // },
  349. //}
  350. //
  351. //jsonBytes, err := json.Marshal(temp)
  352. //if err != nil {
  353. // fmt.Println(err)
  354. //}
  355. //fmt.Println(string(jsonBytes))
  356. }
  357. func (c *PublicApiController) HandleData() {
  358. //service.HandleData()
  359. org_app, _ := service.GetAllAppOrg()
  360. //org_role, _ := service.GetAllRole()
  361. //
  362. //var org_ids []int64
  363. for _, apps := range org_app {
  364. xt_org_app, _ := service.GetAppByType(int64(apps.OrgId), 3)
  365. //org_app_6, _ := service.GetAppByType(int64(apps.OrgId), 6)
  366. //org_app_7, _ := service.GetAppByType(int64(apps.OrgId), 7)
  367. //org_app_8, _ := service.GetAppByType(int64(apps.OrgId), 8)
  368. //org_app_9, _ := service.GetAppByType(int64(apps.OrgId), 9)
  369. //org_app_10, _ := service.GetAppByType(int64(apps.OrgId), 10)
  370. //org_app_11, _ := service.GetAppByType(int64(apps.OrgId), 11)
  371. //org_app_12, _ := service.GetAppByType(int64(apps.OrgId), 12)
  372. //org_app_13, _ := service.GetAppByType(int64(apps.OrgId), 13)
  373. //org_app_14, _ := service.GetAppByType(int64(apps.OrgId), 14)
  374. //org_app_15, _ := service.GetAppByType(int64(apps.OrgId), 15)
  375. //org_app_16, _ := service.GetAppByType(int64(apps.OrgId), 16)
  376. //org_app_17, _ := service.GetAppByType(int64(apps.OrgId), 17)
  377. org_app_18, _ := service.GetAppByType(int64(apps.OrgId), 18)
  378. var xt_temp_org_app *models.OrgApp
  379. //var mall_temp_org_app *models.OrgApp
  380. if xt_org_app == nil || xt_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  381. app, _ := service.GetOrgAppA(0, 3)
  382. org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  383. if org == nil || org.Id == 0 {
  384. continue
  385. }
  386. app.Id = 0
  387. app.OrgId = apps.OrgId
  388. app.Creator = int(org.Creator)
  389. app.Number = 0
  390. app.Status = 1
  391. app.ModifyTime = time.Now().Unix()
  392. app.CreateTime = time.Now().Unix()
  393. service.CreateOrgApp(app)
  394. xt_temp_org_app = app
  395. } else {
  396. xt_temp_org_app = xt_org_app
  397. }
  398. //if scrm_org_app == nil || scrm_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  399. //
  400. // app, _ := service.GetOrgAppA(0, 1)
  401. // //org, _ := service.GetOrgById(int64(12))
  402. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  403. // if org == nil || org.Id == 0 {
  404. // continue
  405. // }
  406. //
  407. //
  408. // app.OrgId = apps.OrgId
  409. // app.Id = 0
  410. //
  411. // app.Creator = int(org.Creator)
  412. // app.Number = 0
  413. // app.Status = 1
  414. // app.ModifyTime = time.Now().Unix()
  415. // app.CreateTime = time.Now().Unix()
  416. // service.CreateOrgApp(app)
  417. //
  418. //}
  419. //
  420. //if cdm_org_app == nil || cdm_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  421. // app, _ := service.GetOrgAppA(0, 4)
  422. // //org, _ := service.GetOrgById(int64(12))
  423. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  424. // if org == nil || org.Id == 0 {
  425. // continue
  426. // }
  427. //
  428. //
  429. // app.OrgId = apps.OrgId
  430. // app.Creator = int(org.Creator)
  431. // app.Number = 0
  432. // app.Id = 0
  433. //
  434. // app.Status = 1
  435. // app.ModifyTime = time.Now().Unix()
  436. // app.CreateTime = time.Now().Unix()
  437. // service.CreateOrgApp(app)
  438. //}
  439. //
  440. //if mall_org_app == nil || mall_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  441. // app, _ := service.GetOrgAppA(0, 5)
  442. // //org, _ := service.GetOrgById(int64(12))
  443. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  444. //
  445. // if org == nil || org.Id == 0 {
  446. // continue
  447. // }
  448. //
  449. // app.OrgId = apps.OrgId
  450. // app.Creator = int(org.Creator)
  451. // app.Number = 0
  452. // app.Id = 0
  453. //
  454. // app.Status = 1
  455. // app.ModifyTime = time.Now().Unix()
  456. // app.CreateTime = time.Now().Unix()
  457. // service.CreateOrgApp(app)
  458. // mall_temp_org_app = app
  459. //} else {
  460. // mall_temp_org_app = mall_org_app
  461. //}
  462. //
  463. //if org_app_16 == nil || org_app_16.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  464. // app, _ := service.GetOrgAppA(0, 16)
  465. // //org, _ := service.GetOrgById(int64(12))
  466. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  467. // if org == nil || org.Id == 0 {
  468. // continue
  469. // }
  470. //
  471. // app.OrgId = apps.OrgId
  472. // app.Creator = int(org.Creator)
  473. // app.Number = 11
  474. // app.Id = 0
  475. // app.Status = 1
  476. // app.ModifyTime = time.Now().Unix()
  477. // app.CreateTime = time.Now().Unix()
  478. // app.Pid = xt_temp_org_app.Id
  479. // service.CreateOrgApp(app)
  480. //
  481. //}
  482. //
  483. //if org_app_17 == nil || org_app_17.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  484. // app, _ := service.GetOrgAppA(0, 17)
  485. // //org, _ := service.GetOrgById(int64(12))
  486. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  487. // if org == nil || org.Id == 0 {
  488. // continue
  489. // }
  490. //
  491. // app.OrgId = apps.OrgId
  492. // app.Creator = int(org.Creator)
  493. // app.Number = 12
  494. // app.Id = 0
  495. // app.Status = 1
  496. // app.ModifyTime = time.Now().Unix()
  497. // app.CreateTime = time.Now().Unix()
  498. // app.Pid = xt_temp_org_app.Id
  499. // service.CreateOrgApp(app)
  500. //
  501. //}
  502. if org_app_18 == nil || org_app_18.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  503. app, _ := service.GetOrgAppA(0, 18)
  504. //org, _ := service.GetOrgById(int64(12))
  505. org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  506. if org == nil || org.Id == 0 {
  507. continue
  508. }
  509. app.OrgId = apps.OrgId
  510. app.Creator = int(org.Creator)
  511. app.Number = 5
  512. app.Id = 0
  513. app.Status = 1
  514. app.ModifyTime = time.Now().Unix()
  515. app.CreateTime = time.Now().Unix()
  516. app.Pid = xt_temp_org_app.Id
  517. service.CreateOrgApp(app)
  518. }
  519. //if org_app_7 == nil || org_app_7.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  520. // app, _ := service.GetOrgAppA(0, 7)
  521. // //org, _ := service.GetOrgById(int64(12))
  522. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  523. // if org == nil || org.Id == 0 {
  524. // continue
  525. // }
  526. //
  527. //
  528. // app.OrgId = apps.OrgId
  529. // app.Creator = int(org.Creator)
  530. // app.Number = 2
  531. // app.Status = 2
  532. // app.Id = 0
  533. //
  534. // app.ModifyTime = time.Now().Unix()
  535. // app.CreateTime = time.Now().Unix()
  536. // app.Pid = xt_temp_org_app.Id
  537. //
  538. // service.CreateOrgApp(app)
  539. //}
  540. //if org_app_8 == nil || org_app_8.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  541. // app, _ := service.GetOrgAppA(0, 8)
  542. // //org, _ := service.GetOrgById(int64(12))
  543. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  544. // if org == nil || org.Id == 0 {
  545. // continue
  546. // }
  547. //
  548. //
  549. // app.OrgId = apps.OrgId
  550. // app.Creator = int(org.Creator)
  551. // app.Number = 3
  552. // app.Id = 0
  553. //
  554. // app.Pid = mall_temp_org_app.Id
  555. //
  556. // app.Status = 1
  557. // app.ModifyTime = time.Now().Unix()
  558. // app.CreateTime = time.Now().Unix()
  559. // service.CreateOrgApp(app)
  560. //}
  561. //if org_app_9 == nil || org_app_9.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  562. // app, _ := service.GetOrgAppA(0, 9)
  563. // //org, _ := service.GetOrgById(int64(12))
  564. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  565. // if org == nil || org.Id == 0 {
  566. // continue
  567. // }
  568. //
  569. //
  570. // app.OrgId = apps.OrgId
  571. // app.Pid = xt_temp_org_app.Id
  572. //
  573. // app.Creator = int(org.Creator)
  574. // app.Number = 4
  575. // app.Id = 0
  576. //
  577. // app.Status = 1
  578. // app.ModifyTime = time.Now().Unix()
  579. // app.CreateTime = time.Now().Unix()
  580. // service.CreateOrgApp(app)
  581. //
  582. //}
  583. //if org_app_10 == nil || org_app_10.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  584. // app, _ := service.GetOrgAppA(0, 10)
  585. // //org, _ := service.GetOrgById(int64(12))
  586. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  587. // if org == nil || org.Id == 0 {
  588. // continue
  589. // }
  590. //
  591. //
  592. // app.OrgId = apps.OrgId
  593. // app.Creator = int(org.Creator)
  594. // app.Pid = xt_temp_org_app.Id
  595. //
  596. // app.Number = 5
  597. // app.Id = 0
  598. //
  599. // app.Status = 1
  600. // app.ModifyTime = time.Now().Unix()
  601. // app.CreateTime = time.Now().Unix()
  602. // service.CreateOrgApp(app)
  603. //}
  604. //if org_app_11 == nil || org_app_11.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  605. // app, _ := service.GetOrgAppA(0, 11)
  606. // //org, _ := service.GetOrgById(int64(12))
  607. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  608. // if org == nil || org.Id == 0 {
  609. // continue
  610. // }
  611. //
  612. //
  613. // app.OrgId = apps.OrgId
  614. // app.Creator = int(org.Creator)
  615. // app.Pid = xt_temp_org_app.Id
  616. // app.Id = 0
  617. //
  618. // app.Number = 6
  619. // app.Status = 1
  620. // app.ModifyTime = time.Now().Unix()
  621. // app.CreateTime = time.Now().Unix()
  622. // service.CreateOrgApp(app)
  623. //}
  624. //if org_app_12 == nil || org_app_12.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  625. // app, _ := service.GetOrgAppA(0, 12)
  626. // //org, _ := service.GetOrgById(int64(12))
  627. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  628. // if org == nil || org.Id == 0 {
  629. // continue
  630. // }
  631. //
  632. //
  633. // app.OrgId = apps.OrgId
  634. // app.Creator = int(org.Creator)
  635. // app.Pid = xt_temp_org_app.Id
  636. // app.Number = 7
  637. // app.Status = 1
  638. // app.Id = 0
  639. //
  640. // app.ModifyTime = time.Now().Unix()
  641. // app.CreateTime = time.Now().Unix()
  642. // service.CreateOrgApp(app)
  643. //}
  644. //if org_app_13 == nil || org_app_13.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  645. // app, _ := service.GetOrgAppA(0, 13)
  646. // //org, _ := service.GetOrgById(int64(12))
  647. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  648. // if org == nil || org.Id == 0 {
  649. // continue
  650. // }
  651. //
  652. //
  653. // app.OrgId = apps.OrgId
  654. // app.Creator = int(org.Creator)
  655. // app.Pid = xt_temp_org_app.Id
  656. // app.Number = 8
  657. // app.Id = 0
  658. // app.Status = 1
  659. // app.ModifyTime = time.Now().Unix()
  660. // app.CreateTime = time.Now().Unix()
  661. // service.CreateOrgApp(app)
  662. //}
  663. //if org_app_14 == nil || org_app_14.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  664. // app, _ := service.GetOrgAppA(0, 14)
  665. // //org, _ := service.GetOrgById(int64(12))
  666. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  667. // if org == nil || org.Id == 0 {
  668. // continue
  669. // }
  670. //
  671. //
  672. // app.OrgId = apps.OrgId
  673. // app.Creator = int(org.Creator)
  674. // app.Pid = xt_temp_org_app.Id
  675. // app.Id = 0
  676. // app.Number = 9
  677. // app.Status = 1
  678. // app.ModifyTime = time.Now().Unix()
  679. // app.CreateTime = time.Now().Unix()
  680. // service.CreateOrgApp(app)
  681. //}
  682. //if org_app_15 == nil || org_app_15.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  683. // app, _ := service.GetOrgAppA(0, 15)
  684. // //org, _ := service.GetOrgById(int64(12))
  685. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  686. // if org == nil || org.Id == 0 {
  687. // continue
  688. // }
  689. //
  690. // app.OrgId = apps.OrgId
  691. // app.Creator = int(org.Creator)
  692. // app.Pid = xt_temp_org_app.Id
  693. // app.Number = 10
  694. // app.Status = 1
  695. // app.Id = 0
  696. // app.ModifyTime = time.Now().Unix()
  697. // app.CreateTime = time.Now().Unix()
  698. // service.CreateOrgApp(app)
  699. //}
  700. }
  701. //for _, role := range org_role {
  702. // org_ids = append(org_ids, role.OrgId)
  703. //}
  704. //
  705. //
  706. ////创建内置角色
  707. //InitRoleAndPurviews(org_ids)
  708. //var org_id int = 0
  709. //管理员
  710. //app_roles := service.GetAllUserRoleByUserTypeOne(org_id)
  711. //for _, item := range app_roles{
  712. // var ids string
  713. // if len(item.RoleIds) == 0{
  714. // ids = strconv.FormatInt( item.RoleId,10)
  715. // }else{
  716. // ids = item.RoleIds + ","+strconv.FormatInt( item.RoleId,10)
  717. // }
  718. // service.UpdateRoleIds(item.Id, ids)
  719. //}
  720. //护士医生
  721. //app_roles2 := service.GetAllUserRoleByUserTypeOther()
  722. // for _, item := range app_roles2{
  723. // var ids string
  724. // if len(item.RoleIds) == 0{
  725. // ids = strconv.FormatInt( item.RoleId,10)
  726. // }else{
  727. // ids = item.RoleIds + ","+strconv.FormatInt( item.RoleId,10)
  728. // }
  729. // if item.UserType == 2{
  730. // role := service.FindRoleByUserTypeOne(item.OrgId)
  731. // ids = ids +"," + strconv.FormatInt(role.Id,10)
  732. //
  733. // } else if item.UserType == 3{
  734. // role := service.FindRoleByUserTypeTwo(item.OrgId)
  735. // ids = ids +"," + strconv.FormatInt(role.Id,10)
  736. // }
  737. // service.UpdateRoleIds(item.Id, ids)
  738. // }
  739. //c.ServeSuccessJSON(map[string]interface{}{
  740. // "msg": "ok",
  741. //})
  742. }
  743. func (c *PublicApiController) HandleGroupNo() {
  744. //service.GetAllPatientChargeDetails(10138, 1634054400)
  745. //pts, _ := service.GetHisPrescriptionTemplateTwo()
  746. //for _, item := range pts {
  747. // if len(item.HisPrescriptionAdviceTemplate) > 0 {
  748. // for index, subItem := range item.HisPrescriptionAdviceTemplate {
  749. // subItem.Groupno = int64(index + 1)
  750. // service.SaveAdviceTemplate(subItem)
  751. // }
  752. // }
  753. //}
  754. }
  755. func InitRoleAndPurviews(org_ids []int64) {
  756. roles := LoadRoleConfig("./role.json").Roles
  757. for _, org_id := range org_ids {
  758. app, _ := service.GetOrgAppB(org_id, 3)
  759. role, _ := service.GetSystemRole(org_id)
  760. if app == nil || app.Id == 0 {
  761. continue
  762. }
  763. if len(role) == 0 {
  764. for _, item := range roles {
  765. role := &models.Role{
  766. RoleName: item.RoleName,
  767. RoleIntro: item.RoleIntroduction,
  768. Creator: 0,
  769. OrgId: org_id,
  770. AppId: app.Id,
  771. IsSuperAdmin: false,
  772. Status: 1,
  773. CreateTime: time.Now().Unix(),
  774. ModifyTime: time.Now().Unix(),
  775. Number: item.Number,
  776. IsSystem: item.IsSystem,
  777. }
  778. err := service.CreateOrgRoleB(role)
  779. if err == nil {
  780. purview := &models.RolePurview{
  781. RoleId: role.Id,
  782. OrgId: org_id,
  783. AppId: role.AppId,
  784. PurviewIds: item.PurviewIds,
  785. Status: 1,
  786. CreateTime: time.Now().Unix(),
  787. ModifyTime: time.Now().Unix(),
  788. }
  789. func_purview := &models.SgjUserRoleFuncPurview{
  790. RoleId: role.Id,
  791. OrgId: org_id,
  792. AppId: role.AppId,
  793. PurviewIds: item.FuncIds,
  794. Status: 1,
  795. Ctime: time.Now().Unix(),
  796. Mtime: time.Now().Unix(),
  797. }
  798. service.CreateRolePurviewB(purview)
  799. service.CreateFuncRolePurviewB(func_purview)
  800. }
  801. }
  802. }
  803. }
  804. }
  805. type RoleConfig struct {
  806. Roles []*models.VMUserRoleAndPurview "json:roles"
  807. }
  808. func LoadRoleConfig(dataFile string) *RoleConfig {
  809. var config RoleConfig
  810. _, filename, _, _ := runtime.Caller(1)
  811. datapath := path.Join(path.Dir(filename), dataFile)
  812. config_file, err := os.Open(datapath)
  813. if err != nil {
  814. emit("Failed to open config file '%s': %s\n", datapath, err)
  815. return &config
  816. }
  817. fi, _ := config_file.Stat()
  818. buffer := make([]byte, fi.Size())
  819. _, err = config_file.Read(buffer)
  820. buffer, err = StripComments(buffer) //去掉注释
  821. if err != nil {
  822. emit("Failed to strip comments from json: %s\n", err)
  823. return &config
  824. }
  825. buffer = []byte(os.ExpandEnv(string(buffer))) //特殊
  826. err = json.Unmarshal(buffer, &config) //解析json格式数据
  827. if err != nil {
  828. emit("Failed unmarshalling json: %s\n", err)
  829. return &config
  830. }
  831. return &config
  832. }
  833. type GoodTypesConfig struct {
  834. GoodTypes []*models.VMGoodsType "json:list"
  835. }
  836. func LoadGoodTypeConfig(dataFile string) *GoodTypesConfig {
  837. var config GoodTypesConfig
  838. _, filename, _, _ := runtime.Caller(1)
  839. datapath := path.Join(path.Dir(filename), dataFile)
  840. config_file, err := os.Open(datapath)
  841. if err != nil {
  842. emit("Failed to open config file '%s': %s\n", datapath, err)
  843. return &config
  844. }
  845. fi, _ := config_file.Stat()
  846. buffer := make([]byte, fi.Size())
  847. _, err = config_file.Read(buffer)
  848. buffer, err = StripComments(buffer) //去掉注释
  849. if err != nil {
  850. emit("Failed to strip comments from json: %s\n", err)
  851. return &config
  852. }
  853. buffer = []byte(os.ExpandEnv(string(buffer))) //特殊
  854. err = json.Unmarshal(buffer, &config) //解析json格式数据
  855. if err != nil {
  856. emit("Failed unmarshalling json: %s\n", err)
  857. return &config
  858. }
  859. return &config
  860. }
  861. func (c *PublicApiController) HandleStockData() {
  862. org, _ := service.FindAllOrgByImportType()
  863. for _, item := range org {
  864. if item.Id != 3907 || item.Id != 9779 || item.Id != 9883 {
  865. goodTypes := &models.GoodsType{
  866. TypeCode: "14000000",
  867. TypeName: "穿刺针",
  868. Remark: "",
  869. Ctime: time.Now().Unix(),
  870. Mtime: time.Now().Unix(),
  871. Creater: 0,
  872. Modifier: 0,
  873. OrgId: item.Id,
  874. Status: 1,
  875. Type: 1,
  876. Number: 1,
  877. }
  878. service.AddSigleGoodType(goodTypes)
  879. goodTypes1 := &models.GoodsType{
  880. TypeCode: "14000001",
  881. TypeName: "透析器",
  882. Remark: "",
  883. Ctime: time.Now().Unix(),
  884. Mtime: time.Now().Unix(),
  885. Creater: 0,
  886. Modifier: 0,
  887. OrgId: item.Id,
  888. Status: 1,
  889. Type: 1,
  890. Number: 2,
  891. }
  892. service.AddSigleGoodType(goodTypes1)
  893. goodTypes2 := &models.GoodsType{
  894. TypeCode: "14000002",
  895. TypeName: "灌流器",
  896. Remark: "",
  897. Ctime: time.Now().Unix(),
  898. Mtime: time.Now().Unix(),
  899. Creater: 0,
  900. Modifier: 0,
  901. OrgId: item.Id,
  902. Status: 1,
  903. Type: 1,
  904. Number: 3,
  905. }
  906. service.AddSigleGoodType(goodTypes2)
  907. goodTypes3 := &models.GoodsType{
  908. TypeCode: "14000003",
  909. TypeName: "血路管",
  910. Remark: "",
  911. Ctime: time.Now().Unix(),
  912. Mtime: time.Now().Unix(),
  913. Creater: 0,
  914. Modifier: 0,
  915. OrgId: item.Id,
  916. Status: 1,
  917. Type: 1,
  918. Number: 4,
  919. }
  920. service.AddSigleGoodType(goodTypes3)
  921. goodTypes4 := &models.GoodsType{
  922. TypeCode: "14000004",
  923. TypeName: "血滤补液管",
  924. Remark: "",
  925. Ctime: time.Now().Unix(),
  926. Mtime: time.Now().Unix(),
  927. Creater: 0,
  928. Modifier: 0,
  929. OrgId: item.Id,
  930. Status: 1,
  931. Type: 1,
  932. Number: 5,
  933. }
  934. service.AddSigleGoodType(goodTypes4)
  935. goodTypes5 := &models.GoodsType{
  936. TypeCode: "14000005",
  937. TypeName: "注射器",
  938. Remark: "",
  939. Ctime: time.Now().Unix(),
  940. Mtime: time.Now().Unix(),
  941. Creater: 0,
  942. Modifier: 0,
  943. OrgId: item.Id,
  944. Status: 1,
  945. Type: 1,
  946. Number: 6,
  947. }
  948. service.AddSigleGoodType(goodTypes5)
  949. goodTypes6 := &models.GoodsType{
  950. TypeCode: "14000006",
  951. TypeName: "护理包(内瘘穿刺包)",
  952. Remark: "",
  953. Ctime: time.Now().Unix(),
  954. Mtime: time.Now().Unix(),
  955. Creater: 0,
  956. Modifier: 0,
  957. OrgId: item.Id,
  958. Status: 1,
  959. Type: 1,
  960. Number: 7,
  961. }
  962. service.AddSigleGoodType(goodTypes6)
  963. goodTypes7 := &models.GoodsType{
  964. TypeCode: "14000007",
  965. TypeName: "细菌过滤器",
  966. Remark: "",
  967. Ctime: time.Now().Unix(),
  968. Mtime: time.Now().Unix(),
  969. Creater: 0,
  970. Modifier: 0,
  971. OrgId: item.Id,
  972. Status: 1,
  973. Type: 1,
  974. Number: 8,
  975. }
  976. service.AddSigleGoodType(goodTypes7)
  977. goodTypes8 := &models.GoodsType{
  978. TypeCode: "14000008",
  979. TypeName: "血液透析干粉",
  980. Remark: "",
  981. Ctime: time.Now().Unix(),
  982. Mtime: time.Now().Unix(),
  983. Creater: 0,
  984. Modifier: 0,
  985. OrgId: item.Id,
  986. Status: 1,
  987. Type: 1,
  988. Number: 9,
  989. }
  990. service.AddSigleGoodType(goodTypes8)
  991. goodTypes9 := &models.GoodsType{
  992. TypeCode: "14000009",
  993. TypeName: "A液",
  994. Remark: "",
  995. Ctime: time.Now().Unix(),
  996. Mtime: time.Now().Unix(),
  997. Creater: 0,
  998. Modifier: 0,
  999. OrgId: item.Id,
  1000. Status: 1,
  1001. Type: 1,
  1002. Number: 10,
  1003. }
  1004. service.AddSigleGoodType(goodTypes9)
  1005. goodTypes10 := &models.GoodsType{
  1006. TypeCode: "14000010",
  1007. TypeName: "B液",
  1008. Remark: "",
  1009. Ctime: time.Now().Unix(),
  1010. Mtime: time.Now().Unix(),
  1011. Creater: 0,
  1012. Modifier: 0,
  1013. OrgId: item.Id,
  1014. Status: 1,
  1015. Type: 1,
  1016. Number: 11,
  1017. }
  1018. service.AddSigleGoodType(goodTypes10)
  1019. goodTypes11 := &models.GoodsType{
  1020. TypeCode: "14000011",
  1021. TypeName: "导管包",
  1022. Remark: "",
  1023. Ctime: time.Now().Unix(),
  1024. Mtime: time.Now().Unix(),
  1025. Creater: 0,
  1026. Modifier: 0,
  1027. OrgId: item.Id,
  1028. Status: 1,
  1029. Type: 1,
  1030. Number: 12,
  1031. }
  1032. service.AddSigleGoodType(goodTypes11)
  1033. goodTypes12 := &models.GoodsType{
  1034. TypeCode: "14000012",
  1035. TypeName: "血液透析导管",
  1036. Remark: "",
  1037. Ctime: time.Now().Unix(),
  1038. Mtime: time.Now().Unix(),
  1039. Creater: 0,
  1040. Modifier: 0,
  1041. OrgId: item.Id,
  1042. Status: 1,
  1043. Type: 1,
  1044. Number: 13,
  1045. }
  1046. service.AddSigleGoodType(goodTypes12)
  1047. }
  1048. }
  1049. }
  1050. func (c *PublicApiController) HandleComData() {
  1051. org_ids := []int64{3907, 9779, 9883}
  1052. for _, id := range org_ids {
  1053. //查处所有处方记录
  1054. prescriptions, _ := service.FindAllPrescription(id)
  1055. if id == 3907 {
  1056. for _, item := range prescriptions {
  1057. if item.Niprocart > 0 {
  1058. before := &models.DialysisBeforePrepare{
  1059. UserOrgId: id,
  1060. PatientId: item.PatientId,
  1061. RecordDate: item.RecordDate,
  1062. Count: 1,
  1063. Ctime: item.RecordDate,
  1064. Mtime: item.RecordDate,
  1065. Creater: item.Creater,
  1066. Modifier: item.Creater,
  1067. Status: 1,
  1068. }
  1069. before.GoodId = item.Niprocart
  1070. before.GoodTypeId = 241
  1071. service.AddSigleDialysisBeforePre(before)
  1072. }
  1073. if item.Jms > 0 {
  1074. before := &models.DialysisBeforePrepare{
  1075. UserOrgId: id,
  1076. PatientId: item.PatientId,
  1077. RecordDate: item.RecordDate,
  1078. Count: 1,
  1079. Ctime: item.RecordDate,
  1080. Mtime: item.RecordDate,
  1081. Creater: item.Creater,
  1082. Modifier: item.Creater,
  1083. Status: 1,
  1084. }
  1085. before.GoodId = item.Jms
  1086. before.GoodTypeId = 233
  1087. service.AddSigleDialysisBeforePre(before)
  1088. }
  1089. if item.FistulaNeedleSet > 0 {
  1090. before := &models.DialysisBeforePrepare{
  1091. UserOrgId: id,
  1092. PatientId: item.PatientId,
  1093. RecordDate: item.RecordDate,
  1094. Count: 1,
  1095. Ctime: item.RecordDate,
  1096. Mtime: item.RecordDate,
  1097. Creater: item.Creater,
  1098. Modifier: item.Creater,
  1099. Status: 1,
  1100. }
  1101. before.GoodId = item.FistulaNeedleSet
  1102. before.GoodTypeId = 233
  1103. service.AddSigleDialysisBeforePre(before)
  1104. }
  1105. if item.FistulaNeedleSet16 > 0 {
  1106. before := &models.DialysisBeforePrepare{
  1107. UserOrgId: id,
  1108. PatientId: item.PatientId,
  1109. RecordDate: item.RecordDate,
  1110. Count: 1,
  1111. Ctime: item.RecordDate,
  1112. Mtime: item.RecordDate,
  1113. Creater: item.Creater,
  1114. Modifier: item.Creater,
  1115. Status: 1,
  1116. }
  1117. before.GoodId = item.FistulaNeedleSet16
  1118. before.GoodTypeId = 233
  1119. service.AddSigleDialysisBeforePre(before)
  1120. }
  1121. if item.Hemoperfusion > 0 {
  1122. before := &models.DialysisBeforePrepare{
  1123. UserOrgId: id,
  1124. PatientId: item.PatientId,
  1125. RecordDate: item.RecordDate,
  1126. Count: 1,
  1127. Ctime: item.RecordDate,
  1128. Mtime: item.RecordDate,
  1129. Creater: item.Creater,
  1130. Modifier: item.Creater,
  1131. Status: 1,
  1132. }
  1133. before.GoodId = item.Hemoperfusion
  1134. before.GoodTypeId = 235
  1135. service.AddSigleDialysisBeforePre(before)
  1136. }
  1137. if item.DialyserSterilised > 0 {
  1138. before := &models.DialysisBeforePrepare{
  1139. UserOrgId: id,
  1140. PatientId: item.PatientId,
  1141. RecordDate: item.RecordDate,
  1142. Count: 1,
  1143. Ctime: item.RecordDate,
  1144. Mtime: item.RecordDate,
  1145. Creater: item.Creater,
  1146. Modifier: item.Creater,
  1147. Status: 1,
  1148. }
  1149. before.GoodId = item.DialyserSterilised
  1150. before.GoodTypeId = 234
  1151. service.AddSigleDialysisBeforePre(before)
  1152. }
  1153. if item.Filtryzer > 0 {
  1154. before := &models.DialysisBeforePrepare{
  1155. UserOrgId: id,
  1156. PatientId: item.PatientId,
  1157. RecordDate: item.RecordDate,
  1158. Count: 1,
  1159. Ctime: item.RecordDate,
  1160. Mtime: item.RecordDate,
  1161. Creater: item.Creater,
  1162. Modifier: item.Creater,
  1163. Status: 1,
  1164. }
  1165. before.GoodId = item.Filtryzer
  1166. before.GoodTypeId = 234
  1167. service.AddSigleDialysisBeforePre(before)
  1168. }
  1169. if item.Dialyzers > 0 {
  1170. before := &models.DialysisBeforePrepare{
  1171. UserOrgId: id,
  1172. PatientId: item.PatientId,
  1173. RecordDate: item.RecordDate,
  1174. Count: 1,
  1175. Ctime: item.RecordDate,
  1176. Mtime: item.RecordDate,
  1177. Creater: item.Creater,
  1178. Modifier: item.Creater,
  1179. Status: 1,
  1180. }
  1181. before.GoodId = item.Dialyzers
  1182. before.GoodTypeId = 234
  1183. service.AddSigleDialysisBeforePre(before)
  1184. }
  1185. if item.Injector > 0 {
  1186. before := &models.DialysisBeforePrepare{
  1187. UserOrgId: id,
  1188. PatientId: item.PatientId,
  1189. RecordDate: item.RecordDate,
  1190. Count: 1,
  1191. Ctime: item.RecordDate,
  1192. Mtime: item.RecordDate,
  1193. Creater: item.Creater,
  1194. Modifier: item.Creater,
  1195. Status: 1,
  1196. }
  1197. before.GoodId = item.Injector
  1198. before.GoodTypeId = 238
  1199. service.AddSigleDialysisBeforePre(before)
  1200. }
  1201. if item.Bloodlines > 0 {
  1202. before := &models.DialysisBeforePrepare{
  1203. UserOrgId: id,
  1204. PatientId: item.PatientId,
  1205. RecordDate: item.RecordDate,
  1206. Count: 1,
  1207. Ctime: item.RecordDate,
  1208. Mtime: item.RecordDate,
  1209. Creater: item.Creater,
  1210. Modifier: item.Creater,
  1211. Status: 1,
  1212. }
  1213. before.GoodId = item.Bloodlines
  1214. before.GoodTypeId = 236
  1215. service.AddSigleDialysisBeforePre(before)
  1216. }
  1217. if item.TubingHemodialysis > 0 {
  1218. before := &models.DialysisBeforePrepare{
  1219. UserOrgId: id,
  1220. PatientId: item.PatientId,
  1221. RecordDate: item.RecordDate,
  1222. Count: 1,
  1223. Ctime: item.RecordDate,
  1224. Mtime: item.RecordDate,
  1225. Creater: item.Creater,
  1226. Modifier: item.Creater,
  1227. Status: 1,
  1228. }
  1229. before.GoodId = item.TubingHemodialysis
  1230. before.GoodTypeId = 237
  1231. service.AddSigleDialysisBeforePre(before)
  1232. }
  1233. if item.Package > 0 {
  1234. before := &models.DialysisBeforePrepare{
  1235. UserOrgId: id,
  1236. PatientId: item.PatientId,
  1237. RecordDate: item.RecordDate,
  1238. Count: 1,
  1239. Ctime: item.RecordDate,
  1240. Mtime: item.RecordDate,
  1241. Creater: item.Creater,
  1242. Modifier: item.Creater,
  1243. Status: 1,
  1244. }
  1245. before.GoodId = item.Package
  1246. before.GoodTypeId = 239
  1247. service.AddSigleDialysisBeforePre(before)
  1248. }
  1249. if item.ALiquid > 0 {
  1250. before := &models.DialysisBeforePrepare{
  1251. UserOrgId: id,
  1252. PatientId: item.PatientId,
  1253. RecordDate: item.RecordDate,
  1254. Count: 1,
  1255. Ctime: item.RecordDate,
  1256. Mtime: item.RecordDate,
  1257. Creater: item.Creater,
  1258. Modifier: item.Creater,
  1259. Status: 1,
  1260. }
  1261. before.GoodId = item.ALiquid
  1262. before.GoodTypeId = 242
  1263. service.AddSigleDialysisBeforePre(before)
  1264. }
  1265. }
  1266. } else if id == 9779 {
  1267. for _, item := range prescriptions {
  1268. if item.Niprocart > 0 {
  1269. before := &models.DialysisBeforePrepare{
  1270. UserOrgId: id,
  1271. PatientId: item.PatientId,
  1272. RecordDate: item.RecordDate,
  1273. Count: 1,
  1274. Ctime: item.RecordDate,
  1275. Mtime: item.RecordDate,
  1276. Creater: item.Creater,
  1277. Modifier: item.Creater,
  1278. Status: 1,
  1279. }
  1280. before.GoodId = item.Niprocart
  1281. before.GoodTypeId = 254
  1282. service.AddSigleDialysisBeforePre(before)
  1283. }
  1284. if item.Jms > 0 {
  1285. before := &models.DialysisBeforePrepare{
  1286. UserOrgId: id,
  1287. PatientId: item.PatientId,
  1288. RecordDate: item.RecordDate,
  1289. Count: 1,
  1290. Ctime: item.RecordDate,
  1291. Mtime: item.RecordDate,
  1292. Creater: item.Creater,
  1293. Modifier: item.Creater,
  1294. Status: 1,
  1295. }
  1296. before.GoodId = item.Jms
  1297. before.GoodTypeId = 246
  1298. service.AddSigleDialysisBeforePre(before)
  1299. }
  1300. if item.FistulaNeedleSet > 0 {
  1301. before := &models.DialysisBeforePrepare{
  1302. UserOrgId: id,
  1303. PatientId: item.PatientId,
  1304. RecordDate: item.RecordDate,
  1305. Count: 1,
  1306. Ctime: item.RecordDate,
  1307. Mtime: item.RecordDate,
  1308. Creater: item.Creater,
  1309. Modifier: item.Creater,
  1310. Status: 1,
  1311. }
  1312. before.GoodId = item.FistulaNeedleSet
  1313. before.GoodTypeId = 246
  1314. service.AddSigleDialysisBeforePre(before)
  1315. }
  1316. if item.FistulaNeedleSet16 > 0 {
  1317. before := &models.DialysisBeforePrepare{
  1318. UserOrgId: id,
  1319. PatientId: item.PatientId,
  1320. RecordDate: item.RecordDate,
  1321. Count: 1,
  1322. Ctime: item.RecordDate,
  1323. Mtime: item.RecordDate,
  1324. Creater: item.Creater,
  1325. Modifier: item.Creater,
  1326. Status: 1,
  1327. }
  1328. before.GoodId = item.FistulaNeedleSet16
  1329. before.GoodTypeId = 246
  1330. service.AddSigleDialysisBeforePre(before)
  1331. }
  1332. if item.Hemoperfusion > 0 {
  1333. before := &models.DialysisBeforePrepare{
  1334. UserOrgId: id,
  1335. PatientId: item.PatientId,
  1336. RecordDate: item.RecordDate,
  1337. Count: 1,
  1338. Ctime: item.RecordDate,
  1339. Mtime: item.RecordDate,
  1340. Creater: item.Creater,
  1341. Modifier: item.Creater,
  1342. Status: 1,
  1343. }
  1344. before.GoodId = item.Hemoperfusion
  1345. before.GoodTypeId = 248
  1346. service.AddSigleDialysisBeforePre(before)
  1347. }
  1348. if item.DialyserSterilised > 0 {
  1349. before := &models.DialysisBeforePrepare{
  1350. UserOrgId: id,
  1351. PatientId: item.PatientId,
  1352. RecordDate: item.RecordDate,
  1353. Count: 1,
  1354. Ctime: item.RecordDate,
  1355. Mtime: item.RecordDate,
  1356. Creater: item.Creater,
  1357. Modifier: item.Creater,
  1358. Status: 1,
  1359. }
  1360. before.GoodId = item.DialyserSterilised
  1361. before.GoodTypeId = 247
  1362. service.AddSigleDialysisBeforePre(before)
  1363. }
  1364. if item.Filtryzer > 0 {
  1365. before := &models.DialysisBeforePrepare{
  1366. UserOrgId: id,
  1367. PatientId: item.PatientId,
  1368. RecordDate: item.RecordDate,
  1369. Count: 1,
  1370. Ctime: item.RecordDate,
  1371. Mtime: item.RecordDate,
  1372. Creater: item.Creater,
  1373. Modifier: item.Creater,
  1374. Status: 1,
  1375. }
  1376. before.GoodId = item.Filtryzer
  1377. before.GoodTypeId = 247
  1378. service.AddSigleDialysisBeforePre(before)
  1379. }
  1380. if item.Dialyzers > 0 {
  1381. before := &models.DialysisBeforePrepare{
  1382. UserOrgId: id,
  1383. PatientId: item.PatientId,
  1384. RecordDate: item.RecordDate,
  1385. Count: 1,
  1386. Ctime: item.RecordDate,
  1387. Mtime: item.RecordDate,
  1388. Creater: item.Creater,
  1389. Modifier: item.Creater,
  1390. Status: 1,
  1391. }
  1392. before.GoodId = item.Dialyzers
  1393. before.GoodTypeId = 247
  1394. service.AddSigleDialysisBeforePre(before)
  1395. }
  1396. if item.Injector > 0 {
  1397. before := &models.DialysisBeforePrepare{
  1398. UserOrgId: id,
  1399. PatientId: item.PatientId,
  1400. RecordDate: item.RecordDate,
  1401. Count: 1,
  1402. Ctime: item.RecordDate,
  1403. Mtime: item.RecordDate,
  1404. Creater: item.Creater,
  1405. Modifier: item.Creater,
  1406. Status: 1,
  1407. }
  1408. before.GoodId = item.Injector
  1409. before.GoodTypeId = 251
  1410. service.AddSigleDialysisBeforePre(before)
  1411. }
  1412. if item.Bloodlines > 0 {
  1413. before := &models.DialysisBeforePrepare{
  1414. UserOrgId: id,
  1415. PatientId: item.PatientId,
  1416. RecordDate: item.RecordDate,
  1417. Count: 1,
  1418. Ctime: item.RecordDate,
  1419. Mtime: item.RecordDate,
  1420. Creater: item.Creater,
  1421. Modifier: item.Creater,
  1422. Status: 1,
  1423. }
  1424. before.GoodId = item.Bloodlines
  1425. before.GoodTypeId = 249
  1426. service.AddSigleDialysisBeforePre(before)
  1427. }
  1428. if item.TubingHemodialysis > 0 {
  1429. before := &models.DialysisBeforePrepare{
  1430. UserOrgId: id,
  1431. PatientId: item.PatientId,
  1432. RecordDate: item.RecordDate,
  1433. Count: 1,
  1434. Ctime: item.RecordDate,
  1435. Mtime: item.RecordDate,
  1436. Creater: item.Creater,
  1437. Modifier: item.Creater,
  1438. Status: 1,
  1439. }
  1440. before.GoodId = item.TubingHemodialysis
  1441. before.GoodTypeId = 250
  1442. service.AddSigleDialysisBeforePre(before)
  1443. }
  1444. if item.Package > 0 {
  1445. before := &models.DialysisBeforePrepare{
  1446. UserOrgId: id,
  1447. PatientId: item.PatientId,
  1448. RecordDate: item.RecordDate,
  1449. Count: 1,
  1450. Ctime: item.RecordDate,
  1451. Mtime: item.RecordDate,
  1452. Creater: item.Creater,
  1453. Modifier: item.Creater,
  1454. Status: 1,
  1455. }
  1456. before.GoodId = item.Package
  1457. before.GoodTypeId = 252
  1458. service.AddSigleDialysisBeforePre(before)
  1459. }
  1460. if item.ALiquid > 0 {
  1461. before := &models.DialysisBeforePrepare{
  1462. UserOrgId: id,
  1463. PatientId: item.PatientId,
  1464. RecordDate: item.RecordDate,
  1465. Count: 1,
  1466. Ctime: item.RecordDate,
  1467. Mtime: item.RecordDate,
  1468. Creater: item.Creater,
  1469. Modifier: item.Creater,
  1470. Status: 1,
  1471. }
  1472. before.GoodId = item.ALiquid
  1473. before.GoodTypeId = 255
  1474. service.AddSigleDialysisBeforePre(before)
  1475. }
  1476. }
  1477. } else if id == 9883 {
  1478. for _, item := range prescriptions {
  1479. if item.Niprocart > 0 {
  1480. before := &models.DialysisBeforePrepare{
  1481. UserOrgId: id,
  1482. PatientId: item.PatientId,
  1483. RecordDate: item.RecordDate,
  1484. Count: 1,
  1485. Ctime: item.RecordDate,
  1486. Mtime: item.RecordDate,
  1487. Creater: item.Creater,
  1488. Modifier: item.Creater,
  1489. Status: 1,
  1490. }
  1491. before.GoodId = item.Niprocart
  1492. before.GoodTypeId = 267
  1493. service.AddSigleDialysisBeforePre(before)
  1494. }
  1495. if item.Jms > 0 {
  1496. before := &models.DialysisBeforePrepare{
  1497. UserOrgId: id,
  1498. PatientId: item.PatientId,
  1499. RecordDate: item.RecordDate,
  1500. Count: 1,
  1501. Ctime: item.RecordDate,
  1502. Mtime: item.RecordDate,
  1503. Creater: item.Creater,
  1504. Modifier: item.Creater,
  1505. Status: 1,
  1506. }
  1507. before.GoodId = item.Jms
  1508. before.GoodTypeId = 259
  1509. service.AddSigleDialysisBeforePre(before)
  1510. }
  1511. if item.FistulaNeedleSet > 0 {
  1512. before := &models.DialysisBeforePrepare{
  1513. UserOrgId: id,
  1514. PatientId: item.PatientId,
  1515. RecordDate: item.RecordDate,
  1516. Count: 1,
  1517. Ctime: item.RecordDate,
  1518. Mtime: item.RecordDate,
  1519. Creater: item.Creater,
  1520. Modifier: item.Creater,
  1521. Status: 1,
  1522. }
  1523. before.GoodId = item.FistulaNeedleSet
  1524. before.GoodTypeId = 259
  1525. service.AddSigleDialysisBeforePre(before)
  1526. }
  1527. if item.FistulaNeedleSet16 > 0 {
  1528. before := &models.DialysisBeforePrepare{
  1529. UserOrgId: id,
  1530. PatientId: item.PatientId,
  1531. RecordDate: item.RecordDate,
  1532. Count: 1,
  1533. Ctime: item.RecordDate,
  1534. Mtime: item.RecordDate,
  1535. Creater: item.Creater,
  1536. Modifier: item.Creater,
  1537. Status: 1,
  1538. }
  1539. before.GoodId = item.FistulaNeedleSet16
  1540. before.GoodTypeId = 259
  1541. service.AddSigleDialysisBeforePre(before)
  1542. }
  1543. if item.Hemoperfusion > 0 {
  1544. before := &models.DialysisBeforePrepare{
  1545. UserOrgId: id,
  1546. PatientId: item.PatientId,
  1547. RecordDate: item.RecordDate,
  1548. Count: 1,
  1549. Ctime: item.RecordDate,
  1550. Mtime: item.RecordDate,
  1551. Creater: item.Creater,
  1552. Modifier: item.Creater,
  1553. Status: 1,
  1554. }
  1555. before.GoodId = item.Hemoperfusion
  1556. before.GoodTypeId = 261
  1557. service.AddSigleDialysisBeforePre(before)
  1558. }
  1559. if item.DialyserSterilised > 0 {
  1560. before := &models.DialysisBeforePrepare{
  1561. UserOrgId: id,
  1562. PatientId: item.PatientId,
  1563. RecordDate: item.RecordDate,
  1564. Count: 1,
  1565. Ctime: item.RecordDate,
  1566. Mtime: item.RecordDate,
  1567. Creater: item.Creater,
  1568. Modifier: item.Creater,
  1569. Status: 1,
  1570. }
  1571. before.GoodId = item.DialyserSterilised
  1572. before.GoodTypeId = 260
  1573. service.AddSigleDialysisBeforePre(before)
  1574. }
  1575. if item.Filtryzer > 0 {
  1576. before := &models.DialysisBeforePrepare{
  1577. UserOrgId: id,
  1578. PatientId: item.PatientId,
  1579. RecordDate: item.RecordDate,
  1580. Count: 1,
  1581. Ctime: item.RecordDate,
  1582. Mtime: item.RecordDate,
  1583. Creater: item.Creater,
  1584. Modifier: item.Creater,
  1585. Status: 1,
  1586. }
  1587. before.GoodId = item.Filtryzer
  1588. before.GoodTypeId = 260
  1589. service.AddSigleDialysisBeforePre(before)
  1590. }
  1591. if item.Dialyzers > 0 {
  1592. before := &models.DialysisBeforePrepare{
  1593. UserOrgId: id,
  1594. PatientId: item.PatientId,
  1595. RecordDate: item.RecordDate,
  1596. Count: 1,
  1597. Ctime: item.RecordDate,
  1598. Mtime: item.RecordDate,
  1599. Creater: item.Creater,
  1600. Modifier: item.Creater,
  1601. Status: 1,
  1602. }
  1603. before.GoodId = item.Dialyzers
  1604. before.GoodTypeId = 260
  1605. service.AddSigleDialysisBeforePre(before)
  1606. }
  1607. if item.Injector > 0 {
  1608. before := &models.DialysisBeforePrepare{
  1609. UserOrgId: id,
  1610. PatientId: item.PatientId,
  1611. RecordDate: item.RecordDate,
  1612. Count: 1,
  1613. Ctime: item.RecordDate,
  1614. Mtime: item.RecordDate,
  1615. Creater: item.Creater,
  1616. Modifier: item.Creater,
  1617. Status: 1,
  1618. }
  1619. before.GoodId = item.Injector
  1620. before.GoodTypeId = 264
  1621. service.AddSigleDialysisBeforePre(before)
  1622. }
  1623. if item.Bloodlines > 0 {
  1624. before := &models.DialysisBeforePrepare{
  1625. UserOrgId: id,
  1626. PatientId: item.PatientId,
  1627. RecordDate: item.RecordDate,
  1628. Count: 1,
  1629. Ctime: item.RecordDate,
  1630. Mtime: item.RecordDate,
  1631. Creater: item.Creater,
  1632. Modifier: item.Creater,
  1633. Status: 1,
  1634. }
  1635. before.GoodId = item.Bloodlines
  1636. before.GoodTypeId = 262
  1637. service.AddSigleDialysisBeforePre(before)
  1638. }
  1639. if item.TubingHemodialysis > 0 {
  1640. before := &models.DialysisBeforePrepare{
  1641. UserOrgId: id,
  1642. PatientId: item.PatientId,
  1643. RecordDate: item.RecordDate,
  1644. Count: 1,
  1645. Ctime: item.RecordDate,
  1646. Mtime: item.RecordDate,
  1647. Creater: item.Creater,
  1648. Modifier: item.Creater,
  1649. Status: 1,
  1650. }
  1651. before.GoodId = item.TubingHemodialysis
  1652. before.GoodTypeId = 263
  1653. service.AddSigleDialysisBeforePre(before)
  1654. }
  1655. if item.Package > 0 {
  1656. before := &models.DialysisBeforePrepare{
  1657. UserOrgId: id,
  1658. PatientId: item.PatientId,
  1659. RecordDate: item.RecordDate,
  1660. Count: 1,
  1661. Ctime: item.RecordDate,
  1662. Mtime: item.RecordDate,
  1663. Creater: item.Creater,
  1664. Modifier: item.Creater,
  1665. Status: 1,
  1666. }
  1667. before.GoodId = item.Package
  1668. before.GoodTypeId = 265
  1669. service.AddSigleDialysisBeforePre(before)
  1670. }
  1671. if item.ALiquid > 0 {
  1672. before := &models.DialysisBeforePrepare{
  1673. UserOrgId: id,
  1674. PatientId: item.PatientId,
  1675. RecordDate: item.RecordDate,
  1676. Count: 1,
  1677. Ctime: item.RecordDate,
  1678. Mtime: item.RecordDate,
  1679. Creater: item.Creater,
  1680. Modifier: item.Creater,
  1681. Status: 1,
  1682. }
  1683. before.GoodId = item.ALiquid
  1684. before.GoodTypeId = 268
  1685. service.AddSigleDialysisBeforePre(before)
  1686. }
  1687. }
  1688. }
  1689. }
  1690. }
  1691. func (c *PublicApiController) HandleHIS() {
  1692. his, _ := service.GetAllHisInfo(9919)
  1693. for _, item := range his {
  1694. fsn := strings.Split(item.FeedetlSn, "-")
  1695. item.FeedetlSn = fsn[0] + "-" + fsn[1] + "-" + strconv.FormatInt(item.ID, 10)
  1696. fmt.Println(item.FeedetlSn)
  1697. service.UpDateHis2(item)
  1698. }
  1699. }
  1700. func (c *PublicApiController) HandleOrder() {
  1701. orders, _ := service.GetAllHisOrder(10106)
  1702. record, _ := service.FindFapiaoByIsUse(10106)
  1703. last_order, _ := service.GetAllHisOrderTwo(10106)
  1704. if record.ID > 0 {
  1705. for index, item := range orders {
  1706. item.FaPiaoCode = record.FapiaoCode
  1707. var zero string
  1708. max_number, _ := strconv.ParseInt(last_order.FaPiaoNumber, 10, 64)
  1709. number, _ := strconv.ParseInt(record.FapiaoNumber, 10, 64)
  1710. number = number + max_number
  1711. if number+int64(index) >= 1000 {
  1712. zero = "0000" + strconv.FormatInt(number+int64(index), 10)
  1713. } else if number+int64(index) >= 10000 {
  1714. zero = "000" + strconv.FormatInt(number+int64(index), 10)
  1715. } else if number+int64(index) >= 100000 {
  1716. zero = "00" + strconv.FormatInt(number+int64(index), 10)
  1717. } else if number+int64(index) >= 1000000 {
  1718. zero = "0" + strconv.FormatInt(number+int64(index), 10)
  1719. } else {
  1720. zero = strconv.FormatInt(number+int64(index), 10)
  1721. }
  1722. item.FaPiaoNumber = zero
  1723. item.FaPiaoBatchnumberId = record.ID
  1724. service.SaveOrder(item)
  1725. }
  1726. }
  1727. }
  1728. func Mkdir(dir string) {
  1729. // 创建文件夹
  1730. exist, err := PathExists(dir)
  1731. if err != nil {
  1732. fmt.Println(err.Error())
  1733. } else {
  1734. if exist {
  1735. fmt.Println(dir + "文件夹已存在!")
  1736. } else {
  1737. // 文件夹名称,权限
  1738. err := os.Mkdir(dir, os.ModePerm)
  1739. if err != nil {
  1740. fmt.Println(dir+"文件夹创建失败:", err.Error())
  1741. } else {
  1742. fmt.Println(dir + "文件夹创建成功!")
  1743. }
  1744. }
  1745. }
  1746. }
  1747. func PathExists(path string) (bool, error) {
  1748. _, err := os.Stat(path)
  1749. if err == nil {
  1750. return true, nil
  1751. }
  1752. if os.IsNotExist(err) {
  1753. return false, nil
  1754. }
  1755. return false, err
  1756. }
  1757. func (c *PublicApiController) Handle10215() {
  1758. //projects,_ := service.GetAllInfo(10215,2284)
  1759. //
  1760. //for _, item := range projects{
  1761. // service.UpdateStatus(item.ID, item.PrescriptionId)
  1762. //}
  1763. //projects_two,_ := service.GetAllInfo(10215,2277)
  1764. //
  1765. //for _, item := range projects_two{
  1766. // service.UpdateStatus(item.ID, item.PrescriptionId)
  1767. //}
  1768. //service.GetAllInfo(10215,2284)
  1769. //service.GetAllInfo(10215,2277)
  1770. his, _ := service.GetAllPT(10215)
  1771. for _, item := range his {
  1772. //
  1773. //pro := &models.HisPrescriptionProjectTemplate{
  1774. // ProjectId: 1750,
  1775. // Price: 6.00,
  1776. // UserOrgId: 10215,
  1777. // Status: 1,
  1778. // Ctime: time.Now().Unix(),
  1779. // Mtime: time.Now().Unix(),
  1780. // PatientId: item.PatientId,
  1781. // RecordDate: 0,
  1782. // Count: 1,
  1783. // FeedetlSn: "",
  1784. // MedListCodg: "",
  1785. // SingleDose: "1",
  1786. // DeliveryWay: "",
  1787. // ExecutionFrequency: "",
  1788. // Day: "1",
  1789. // Remark: "",
  1790. // Unit: "",
  1791. // Type: 2,
  1792. // PrescriptionId: info.ID,
  1793. // FrequencyType: 1,
  1794. // DayCount: 0,
  1795. // WeekDay: "",
  1796. //}
  1797. //service.CreateHisPrescriptionProjectTemplate(pro)
  1798. //
  1799. //pro2 := &models.HisPrescriptionProjectTemplate{
  1800. // ProjectId: 2462,
  1801. // Price: 4.94,
  1802. // UserOrgId: 10215,
  1803. // Status: 1,
  1804. // Ctime: time.Now().Unix(),
  1805. // Mtime: time.Now().Unix(),
  1806. // PatientId: item.PatientId,
  1807. // RecordDate: 0,
  1808. // Count: 1,
  1809. // FeedetlSn: "",
  1810. // MedListCodg: "",
  1811. // SingleDose: "1",
  1812. // DeliveryWay: "",
  1813. // ExecutionFrequency: "",
  1814. // Day: "1",
  1815. // Remark: "",
  1816. // Unit: "",
  1817. // Type: 3,
  1818. // PrescriptionId: info.ID,
  1819. // FrequencyType: 1,
  1820. // DayCount: 0,
  1821. // WeekDay: "",
  1822. //}
  1823. //service.CreateHisPrescriptionProjectTemplate(pro2)
  1824. //
  1825. //
  1826. infos, _ := service.GetAllPTInfo(10215, item.ID)
  1827. // // fmt.Println(infos)
  1828. for _, subItem := range infos {
  1829. if len(subItem.HisPrescriptionAdviceTemplate) > 0 && len(subItem.HisPrescriptionProjectTemplate) == 0 {
  1830. for _, ssubItem := range subItem.HisPrescriptionAdviceTemplate {
  1831. //if ssubItem.DrugId == 1234 {
  1832. // pro := &models.HisPrescriptionProjectTemplate{
  1833. // ProjectId: 2326,
  1834. // Price: 0.86,
  1835. // UserOrgId: ssubItem.UserOrgId,
  1836. // Status: 1,
  1837. // Ctime: time.Now().Unix(),
  1838. // Mtime: time.Now().Unix(),
  1839. // PatientId: ssubItem.PatientId,
  1840. // RecordDate: ssubItem.AdviceDate,
  1841. // Count: 1,
  1842. // FeedetlSn: "",
  1843. // MedListCodg: "",
  1844. // SingleDose: "1",
  1845. // DeliveryWay: "",
  1846. // ExecutionFrequency: "",
  1847. // Day: "1",
  1848. // Remark: "",
  1849. // Unit: "",
  1850. // Type: 3,
  1851. // PrescriptionId: info.ID,
  1852. // FrequencyType: ssubItem.FrequencyType,
  1853. // DayCount: ssubItem.DayCount,
  1854. // WeekDay: ssubItem.WeekDay,
  1855. // }
  1856. // service.CreateHisPrescriptionProjectTemplate(pro)
  1857. //
  1858. //}
  1859. if ssubItem.DrugId == 1288 {
  1860. info := &models.HisPrescriptionInfoTemplate{
  1861. UserOrgId: item.UserOrgId,
  1862. RecordDate: 0,
  1863. PatientId: item.PatientId,
  1864. Status: 1,
  1865. Ctime: time.Now().Unix(),
  1866. Mtime: time.Now().Unix(),
  1867. Type: 2,
  1868. Creator: 0,
  1869. Modifier: 0,
  1870. PType: 0,
  1871. PTemplateId: item.ID,
  1872. MedType: "14",
  1873. }
  1874. service.CreateHisPrescriptionInfoTemplate(info)
  1875. pro2 := &models.HisPrescriptionProjectTemplate{
  1876. ProjectId: 1727,
  1877. Price: 2.50,
  1878. UserOrgId: ssubItem.UserOrgId,
  1879. Status: 1,
  1880. Ctime: time.Now().Unix(),
  1881. Mtime: time.Now().Unix(),
  1882. PatientId: ssubItem.PatientId,
  1883. RecordDate: ssubItem.AdviceDate,
  1884. Count: "1",
  1885. FeedetlSn: "",
  1886. MedListCodg: "",
  1887. SingleDose: "1",
  1888. DeliveryWay: "",
  1889. ExecutionFrequency: "",
  1890. Day: "1",
  1891. Remark: "",
  1892. Unit: "",
  1893. Type: 2,
  1894. PrescriptionId: info.ID,
  1895. FrequencyType: ssubItem.FrequencyType,
  1896. DayCount: ssubItem.DayCount,
  1897. WeekDay: ssubItem.WeekDay,
  1898. }
  1899. service.CreateHisPrescriptionProjectTemplate(pro2)
  1900. //pro := &models.HisPrescriptionProjectTemplate{
  1901. // ProjectId: 2326,
  1902. // Price: 0.86,
  1903. // UserOrgId: ssubItem.UserOrgId,
  1904. // Status: 1,
  1905. // Ctime: time.Now().Unix(),
  1906. // Mtime: time.Now().Unix(),
  1907. // PatientId: ssubItem.PatientId,
  1908. // RecordDate: ssubItem.AdviceDate,
  1909. // Count: 1,
  1910. // FeedetlSn: "",
  1911. // MedListCodg: "",
  1912. // SingleDose: "1",
  1913. // DeliveryWay: "",
  1914. // ExecutionFrequency: "",
  1915. // Day: "1",
  1916. // Remark: "",
  1917. // Unit: "",
  1918. // Type: 3,
  1919. // PrescriptionId: info.ID,
  1920. // FrequencyType: ssubItem.FrequencyType,
  1921. // DayCount: ssubItem.DayCount,
  1922. // WeekDay: ssubItem.WeekDay,
  1923. //}
  1924. //service.CreateHisPrescriptionProjectTemplate(pro)
  1925. }
  1926. //if ssubItem.DrugId == 1306 {
  1927. //
  1928. // pro := &models.HisPrescriptionProjectTemplate{
  1929. // ProjectId: 2325,
  1930. // Price: 1.11,
  1931. // UserOrgId: ssubItem.UserOrgId,
  1932. // Status: 1,
  1933. // Ctime: time.Now().Unix(),
  1934. // Mtime: time.Now().Unix(),
  1935. // PatientId: ssubItem.PatientId,
  1936. // RecordDate: ssubItem.AdviceDate,
  1937. // Count: 1,
  1938. // FeedetlSn: "",
  1939. // MedListCodg: "",
  1940. // SingleDose: "1",
  1941. // DeliveryWay: "",
  1942. // ExecutionFrequency: "",
  1943. // Day: "1",
  1944. // Remark: "",
  1945. // Unit: "",
  1946. // Type: 3,
  1947. // PrescriptionId: info.ID,
  1948. // FrequencyType: ssubItem.FrequencyType,
  1949. // DayCount: ssubItem.DayCount,
  1950. // WeekDay: ssubItem.WeekDay,
  1951. // }
  1952. // service.CreateHisPrescriptionProjectTemplate(pro)
  1953. //
  1954. // pro2 := &models.HisPrescriptionProjectTemplate{
  1955. // ProjectId: 1727,
  1956. // Price: 2.50,
  1957. // UserOrgId: ssubItem.UserOrgId,
  1958. // Status: 1,
  1959. // Ctime: time.Now().Unix(),
  1960. // Mtime: time.Now().Unix(),
  1961. // PatientId: ssubItem.PatientId,
  1962. // RecordDate: ssubItem.AdviceDate,
  1963. // Count: 1,
  1964. // FeedetlSn: "",
  1965. // MedListCodg: "",
  1966. // SingleDose: "1",
  1967. // DeliveryWay: "",
  1968. // ExecutionFrequency: "",
  1969. // Day: "1",
  1970. // Remark: "",
  1971. // Unit: "",
  1972. // Type: 2,
  1973. // PrescriptionId: info.ID,
  1974. // FrequencyType: ssubItem.FrequencyType,
  1975. // DayCount: ssubItem.DayCount,
  1976. // WeekDay: ssubItem.WeekDay,
  1977. // }
  1978. // service.CreateHisPrescriptionProjectTemplate(pro2)
  1979. //
  1980. //}
  1981. //if ssubItem.DrugId == 1291 {
  1982. //
  1983. // pro := &models.HisPrescriptionProjectTemplate{
  1984. // ProjectId: 2322,
  1985. // Price: 0.68,
  1986. // UserOrgId: ssubItem.UserOrgId,
  1987. // Status: 1,
  1988. // Ctime: time.Now().Unix(),
  1989. // Mtime: time.Now().Unix(),
  1990. // PatientId: ssubItem.PatientId,
  1991. // RecordDate: ssubItem.AdviceDate,
  1992. // Count: 1,
  1993. // FeedetlSn: "",
  1994. // MedListCodg: "",
  1995. // SingleDose: "1",
  1996. // DeliveryWay: "",
  1997. // ExecutionFrequency: "",
  1998. // Day: "1",
  1999. // Remark: "",
  2000. // Unit: "",
  2001. // Type: 3,
  2002. // PrescriptionId: info.ID,
  2003. // FrequencyType: ssubItem.FrequencyType,
  2004. // DayCount: ssubItem.DayCount,
  2005. // WeekDay: ssubItem.WeekDay,
  2006. // }
  2007. // service.CreateHisPrescriptionProjectTemplate(pro)
  2008. //
  2009. // pro2 := &models.HisPrescriptionProjectTemplate{
  2010. // ProjectId: 1727,
  2011. // Price: 2.50,
  2012. // UserOrgId: ssubItem.UserOrgId,
  2013. // Status: 1,
  2014. // Ctime: time.Now().Unix(),
  2015. // Mtime: time.Now().Unix(),
  2016. // PatientId: ssubItem.PatientId,
  2017. // RecordDate: ssubItem.AdviceDate,
  2018. // Count: 1,
  2019. // FeedetlSn: "",
  2020. // MedListCodg: "",
  2021. // SingleDose: "1",
  2022. // DeliveryWay: "",
  2023. // ExecutionFrequency: "",
  2024. // Day: "1",
  2025. // Remark: "",
  2026. // Unit: "",
  2027. // Type: 2,
  2028. // PrescriptionId: info.ID,
  2029. // FrequencyType: ssubItem.FrequencyType,
  2030. // DayCount: ssubItem.DayCount,
  2031. // WeekDay: ssubItem.WeekDay,
  2032. // }
  2033. // service.CreateHisPrescriptionProjectTemplate(pro2)
  2034. //}
  2035. }
  2036. }
  2037. }
  2038. }
  2039. }
  2040. func (c *PublicApiController) HandleExportAllData() {
  2041. orders, _ := service.GetHisOrderDetail9504()
  2042. c.ServeSuccessJSON(map[string]interface{}{
  2043. "order": orders,
  2044. })
  2045. }
  2046. func (c *PublicApiController) HandleExportData10138() {
  2047. orders, _ := service.GetHisOrderDetail10138()
  2048. c.ServeSuccessJSON(map[string]interface{}{
  2049. "order": orders,
  2050. })
  2051. }
  2052. func (c *PublicApiController) HandleData10265() {
  2053. orders, _ := service.GetHisOrder10265()
  2054. for _, items := range orders {
  2055. if items.AdviceId == 0 && items.ProjectId > 0 {
  2056. p, _ := service.GetHisPrescriptionProjectByIDTwo(items.ProjectId)
  2057. if p.Type == 2 {
  2058. if p.HisProject.CostClassify == 3 {
  2059. items.MedChrgitmType = "04"
  2060. }
  2061. if p.HisProject.CostClassify == 2 {
  2062. items.MedChrgitmType = "05"
  2063. }
  2064. if p.HisProject.CostClassify == 8 {
  2065. items.MedChrgitmType = "03"
  2066. }
  2067. //p.HisProject.CostClassify == 8
  2068. } else {
  2069. items.MedChrgitmType = "08"
  2070. }
  2071. }
  2072. service.SaveOrderInfo(items)
  2073. }
  2074. }