sign_api_controller.go 51KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671
  1. package controllers
  2. import (
  3. "encoding/base64"
  4. "encoding/json"
  5. "fmt"
  6. "io/ioutil"
  7. "strconv"
  8. "time"
  9. "XT_New/models"
  10. "XT_New/service"
  11. "XT_New/utils"
  12. "github.com/astaxie/beego"
  13. )
  14. type SignApiController struct {
  15. BaseAuthAPIController
  16. }
  17. func SignApiRegistRouters() {
  18. //获取短信验证码
  19. beego.Router("/api/sign/getsign", &SignApiController{}, "Get:GetSign")
  20. //创建个人用户并实名
  21. beego.Router("/api/sign/createrusername", &SignApiController{}, "Get:CreateUserName")
  22. //创建企业用户并实名
  23. beego.Router("/api/sign/createenterpriserealname", &SignApiController{}, "Get:CreateEnterPriseRealName")
  24. //添加企业成员
  25. beego.Router("/api/sign/createuserid", &SignApiController{}, "Get:CreateUserId")
  26. //创建个人印章
  27. beego.Router("/api/sign/createpersionseal", &SignApiController{}, "Get:CreatePersionSeal")
  28. //上传文件创建创建合同
  29. beego.Router("/api/sign/createuploadpact", &SignApiController{}, "Get:CreateUploadPact")
  30. //添加合同签署人
  31. beego.Router("/api/sign/addcontractsignatory", &SignApiController{}, "Get:AddContractSignatory")
  32. //获取短信验证
  33. beego.Router("/api/sign/getverificationcode", &SignApiController{}, "Get:GetVerificationCode")
  34. //后台签署(返回签署文件)
  35. beego.Router("/api/sign/createbackstagesign", &SignApiController{}, "Get:CreateBackStageSign")
  36. //署意愿认证-短信验证
  37. beego.Router("/api/sign/totestelment", &SignApiController{}, "Get:CreateEnterprise")
  38. //测试PDF
  39. beego.Router("/api/sign/totestthrityment", &SignApiController{}, "Get:GetTestThrityMent")
  40. //CA企业认证
  41. beego.Router("/api/sign/saveenerprise", &SignApiController{}, "Post:SaveEnerprise")
  42. //
  43. beego.Router("/api/sign/getenerprisebyid", &SignApiController{}, "Get:GetEnerPriseById")
  44. beego.Router("/api/sign/getmobilecode", &SignApiController{}, "Get:GetMobileCode")
  45. beego.Router("/api/sign/getpersionenterprise", &SignApiController{}, "Post:GetPersionEnterPrise")
  46. beego.Router("/api/sign/getpersenterprisebyid", &SignApiController{}, "Get:GetPerseEnterPriseById")
  47. beego.Router("/api/device/sign/creterpersionseal", &SignApiController{}, "Get:CreateNewPersionSeal")
  48. beego.Router("/api/device/sign/createnewenterprise", &SignApiController{}, "Get:CreateNewEnterPrise")
  49. beego.Router("/api/device/contractid", &SignApiController{}, "Get:GetContractId")
  50. beego.Router("/api/device/endenterprise", &SignApiController{}, "Get:EndEnterPrise")
  51. beego.Router("/api/device/getenterprisedetail", &SignApiController{}, "Get:GetEnterPriseDetail")
  52. beego.Router("/api/device/uploadprintorder", &SignApiController{}, "Post:UploadPrintOrder")
  53. //sdk 版本
  54. beego.Router("/api/device/createqianshuusername", &SignApiController{}, "Post:CreateQianshuUserName")
  55. //发送消息
  56. beego.Router("/api/device/createskdsendinformation", &SignApiController{}, "Post:CreateSdkSendInformation")
  57. //删除
  58. beego.Router("/api/device/tosavepdfinformation", &SignApiController{}, "Get:SavePdfInformation")
  59. beego.Router("/api/device/tocheckinformation", &SignApiController{}, "Get:ToCheckInformation")
  60. beego.Router("/api/device/toautodrug", &SignApiController{}, "Get:ToAutoDrug")
  61. beego.Router("/api/device/toautodiagnose", &SignApiController{}, "Get:ToAutoDiagnose")
  62. //加油
  63. beego.Router("/api/device/toautojiayou", &SignApiController{}, "Get:ToAutoJiaYou")
  64. //显示字段脚本
  65. beego.Router("/api/device/getfieldconfiglist", &SignApiController{}, "Get:GetFieldConfigList")
  66. beego.Router("/api/device/tocheckquery", &SignApiController{}, "Get:ToCheckQuery")
  67. }
  68. // 短信服务接口
  69. func (this *SignApiController) GetSign() {
  70. phone := this.GetString("phone")
  71. fmt.Println("phone", phone)
  72. var tempphone string
  73. tempphone = "13318464642"
  74. sign := service.GetSignNameByPhone(tempphone)
  75. this.ServeSuccessJSON(map[string]interface{}{
  76. "sign": sign,
  77. })
  78. return
  79. }
  80. type Result2121 struct {
  81. Phone string `json:"phone"`
  82. DisPlayName string `json:"dis_play_name"`
  83. Authentication string `json:"authentication"`
  84. TwAuthReq struct {
  85. OneLineAuth string `json:"oneLineAuth"`
  86. ApiAuthReq struct {
  87. RealName float64 `json:"real_name"`
  88. IdCardType string `json:"id_card_type"`
  89. IdCardNum string `json:"id_card_num"`
  90. BankCard string `json:"bank_card"`
  91. CodeNumber string `json:"code_number"`
  92. VerifyCode string `json:"verify_code"`
  93. } `json:"apiAuthReq"`
  94. } `json:"twAuthReq"`
  95. }
  96. type MapData struct {
  97. dat struct {
  98. Code float64 `json:"code"`
  99. data struct {
  100. userId string `json:"userId"`
  101. }
  102. }
  103. }
  104. // 创建个人用户并实名
  105. func (this *SignApiController) CreateUserName() {
  106. phone := this.GetString("phone")
  107. disPlayName := this.GetString("disPlayName")
  108. sign, userId := service.CreateUserName(phone, disPlayName)
  109. var dat map[string]interface{}
  110. if err := json.Unmarshal([]byte(sign), &dat); err == nil {
  111. fmt.Println(dat)
  112. } else {
  113. fmt.Println(err)
  114. }
  115. this.ServeSuccessJSON(map[string]interface{}{
  116. "sign": sign,
  117. "dat": dat,
  118. "userId": userId,
  119. })
  120. return
  121. }
  122. // 创建个人印章
  123. func (this *SignApiController) CreatePersionSeal() {
  124. user_id := this.GetString("user_id")
  125. person_seal_type, _ := this.GetInt64("person_seal_type")
  126. person_seal_name := this.GetString("person_seal_name")
  127. person_seal_base := this.GetString("person_seal_base")
  128. color, _ := this.GetInt64("color")
  129. alpha, _ := this.GetInt64("alpha")
  130. width, _ := this.GetInt64("width")
  131. height, _ := this.GetInt64("height")
  132. border, _ := this.GetInt64("border")
  133. font_type, _ := this.GetInt64("font_type")
  134. sign, personSealId := service.CreatePersionSeal(user_id, person_seal_type, person_seal_name, person_seal_base, color, alpha, width, height, border, font_type)
  135. var dat map[string]interface{}
  136. if err := json.Unmarshal([]byte(sign), &dat); err == nil {
  137. fmt.Println(dat)
  138. } else {
  139. fmt.Println(err)
  140. }
  141. this.ServeSuccessJSON(map[string]interface{}{
  142. "sign": sign,
  143. "dat": dat,
  144. "personSealId": personSealId,
  145. })
  146. return
  147. }
  148. func (this *SignApiController) CreateUploadPact() {
  149. contractcode := this.GetString("contractcode")
  150. contractname := this.GetString("contractname")
  151. signcount, _ := this.GetInt64("signcount")
  152. docname := this.GetString("docname")
  153. contractbase := this.GetString("contractbase")
  154. creator := this.GetString("creator")
  155. enterpriseid := this.GetString("enterpriseid")
  156. signvalidays, _ := this.GetInt64("signvalidays")
  157. sysncurl := this.GetString("sysncurl")
  158. asyncurl := this.GetString("asyncurl")
  159. sign := service.CreateUploadPact(contractcode, contractname, signcount, docname, contractbase, creator, enterpriseid, signvalidays, sysncurl, asyncurl)
  160. this.ServeSuccessJSON(map[string]interface{}{
  161. "sign": sign,
  162. })
  163. return
  164. }
  165. // 添加企业成员
  166. func (this *SignApiController) CreateUserId() {
  167. userId := this.GetString("userId")
  168. displayName := this.GetString("displayName")
  169. sign := service.CreateUserId(userId, displayName)
  170. this.ServeSuccessJSON(map[string]interface{}{
  171. "sign": sign,
  172. })
  173. return
  174. }
  175. func (this *SignApiController) CreateEnterPriseRealName() {
  176. enterprisename := this.GetString("enterprisename")
  177. sign := service.CreateEnterPriseRealName(enterprisename)
  178. this.ServeSuccessJSON(map[string]interface{}{
  179. "sign": sign,
  180. })
  181. return
  182. }
  183. // 添加合同签署人
  184. func (this *SignApiController) AddContractSignatory() {
  185. contractId := this.GetString("contractId")
  186. signers := this.GetString("signers")
  187. var newContract models.NewContract
  188. newContract.ContractId = "156001444267295949"
  189. sign := service.AddContractSignatory(contractId, signers, newContract)
  190. this.ServeSuccessJSON(map[string]interface{}{
  191. "sign": sign,
  192. })
  193. return
  194. }
  195. type Struct2401 struct {
  196. someTimestampStyle []someTimestampStyle
  197. }
  198. type someTimestampStyle struct {
  199. ControlsKey string
  200. Pattern string
  201. Color string
  202. }
  203. func (this *SignApiController) CreateBackStageSign() {
  204. contractId := this.GetString("contractId")
  205. signers := this.GetString("signers")
  206. sign := service.CreateBackStageSign(contractId, signers)
  207. this.ServeSuccessJSON(map[string]interface{}{
  208. "sign": sign,
  209. })
  210. return
  211. }
  212. func (this *SignApiController) GetVerificationCode() {
  213. sign := service.GetVerificationCode()
  214. this.ServeSuccessJSON(map[string]interface{}{
  215. "sign": sign,
  216. })
  217. return
  218. }
  219. func (this *SignApiController) CreateEnterprise() {
  220. sign := service.CreateEnterprise()
  221. this.ServeSuccessJSON(map[string]interface{}{
  222. "sign": sign,
  223. })
  224. return
  225. }
  226. func (this *SignApiController) GetTestThrityMent() {
  227. //pdf := gofpdf.New("P", "mm", "A4", "")
  228. //pdf.AddPage()
  229. //pdf.SetFont("Arial", "B", 16)
  230. //pdf.Cell(40, 10, "Hello, World!")
  231. //pdf.OutputFileAndClose("output.pdf")
  232. //
  233. //this.ServeSuccessJSON(map[string]interface{}{
  234. // "sign": "msg",
  235. //})
  236. //return
  237. }
  238. func loremList() []string {
  239. return []string{
  240. "我爱你中国" +
  241. "tempor incididunt ut labore et dolore magna aliqua.",
  242. "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut " +
  243. "aliquip ex ea commodo consequat.",
  244. "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum " +
  245. "dolore eu fugiat nulla pariatur.",
  246. "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui " +
  247. "officia deserunt mollit anim id est laborum.",
  248. }
  249. }
  250. func (this *SignApiController) SaveEnerprise() {
  251. orgId := this.GetAdminUserInfo().CurrentOrgId
  252. creater := this.GetAdminUserInfo().AdminUser.Id
  253. dataBody := make(map[string]interface{}, 0)
  254. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  255. fmt.Println("err", err)
  256. id := int64(dataBody["id"].(float64))
  257. org_type := int64(dataBody["org_type"].(float64))
  258. enterprise_name := dataBody["enterprise_name"].(string)
  259. code := dataBody["code"].(string)
  260. org_code := dataBody["org_code"].(string)
  261. legal_person_name := dataBody["legal_person_name"].(string)
  262. legal_id_card_num := dataBody["legal_id_card_num"].(string)
  263. legal_phone := dataBody["legal_phone"].(string)
  264. enterprise := models.XtDeviceEnterprise{
  265. ID: id,
  266. UserOrgId: orgId,
  267. OrgType: org_type,
  268. EnterpriseName: enterprise_name,
  269. Code: code,
  270. OrgCode: org_code,
  271. LegalPersonName: legal_person_name,
  272. LegalIdCardNum: legal_id_card_num,
  273. LegalPhone: legal_phone,
  274. Creater: creater,
  275. Ctime: time.Now().Unix(),
  276. Mtime: 0,
  277. Enterpriseid: "",
  278. Status: 1,
  279. }
  280. service.SaveEnerPrise(enterprise)
  281. //查找该机构有没有认证信息
  282. lastenterprise, _ := service.GetEnterPriseByUserOrgId(orgId)
  283. //调用企业认证接口
  284. if lastenterprise.ID > 0 {
  285. enterPrise, enterpriseid := service.CreateNewEnterPriseRealName(lastenterprise)
  286. fmt.Println("enterprise2ooo2oo2o2o2o", enterPrise)
  287. updateEnterprise := models.XtDeviceEnterprise{
  288. ID: enterprise.ID,
  289. UserOrgId: orgId,
  290. OrgType: org_type,
  291. EnterpriseName: enterprise_name,
  292. Code: code,
  293. OrgCode: org_code,
  294. LegalPersonName: legal_person_name,
  295. LegalIdCardNum: legal_id_card_num,
  296. LegalPhone: legal_phone,
  297. Creater: creater,
  298. Ctime: time.Now().Unix(),
  299. Mtime: 0,
  300. Enterpriseid: enterpriseid,
  301. Status: 1,
  302. }
  303. service.SaveEnerPrise(updateEnterprise)
  304. this.ServeSuccessJSON(map[string]interface{}{
  305. "enterPrise": enterPrise,
  306. })
  307. return
  308. }
  309. }
  310. func (this *SignApiController) GetEnerPriseById() {
  311. orgId := this.GetAdminUserInfo().CurrentOrgId
  312. enterPrise, _ := service.GetEnterPriseByUserOrgId(orgId)
  313. this.ServeSuccessJSON(map[string]interface{}{
  314. "enterPrise": enterPrise,
  315. })
  316. return
  317. }
  318. func (this *SignApiController) GetMobileCode() {
  319. phone := this.GetString("phone")
  320. sign, orderNumber := service.GetNewSignNameByPhone(phone)
  321. this.ServeSuccessJSON(map[string]interface{}{
  322. "sign": sign,
  323. "orderNumber": orderNumber,
  324. })
  325. return
  326. }
  327. func (this *SignApiController) GetPersionEnterPrise() {
  328. orgId := this.GetAdminUserInfo().CurrentOrgId
  329. creater := this.GetAdminUserInfo().AdminUser.Id
  330. dataBody := make(map[string]interface{}, 0)
  331. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  332. fmt.Println("err", err)
  333. id := int64(dataBody["id"].(float64))
  334. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  335. code := dataBody["code"].(string)
  336. display_name := dataBody["display_name"].(string)
  337. id_card_num := dataBody["id_card_num"].(string)
  338. phone := dataBody["phone"].(string)
  339. enterprise := models.XtDevicePersonEnterprise{
  340. ID: id,
  341. AdminUserId: admin_user_id,
  342. DisplayName: display_name,
  343. Phone: phone,
  344. IdCardNum: id_card_num,
  345. UserOrgId: orgId,
  346. Status: 1,
  347. Creater: creater,
  348. Ctime: time.Now().Unix(),
  349. Mtime: 0,
  350. UserId: "",
  351. }
  352. service.SavePersonEnterPrise(enterprise)
  353. lastEnterPrise, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId)
  354. _, orderNumber := service.GetNewSignNameByPhone(phone)
  355. personEnterPrse, UserId := service.CreateNewUserName(lastEnterPrise.Phone, lastEnterPrise.DisplayName, code, orderNumber, lastEnterPrise.IdCardNum)
  356. firstenterprise := models.XtDevicePersonEnterprise{
  357. ID: id,
  358. AdminUserId: admin_user_id,
  359. DisplayName: display_name,
  360. Phone: phone,
  361. IdCardNum: id_card_num,
  362. UserOrgId: orgId,
  363. Status: 1,
  364. Creater: creater,
  365. Ctime: time.Now().Unix(),
  366. Mtime: 0,
  367. UserId: UserId,
  368. }
  369. service.SavePersonEnterPrise(firstenterprise)
  370. this.ServeSuccessJSON(map[string]interface{}{
  371. "personEnterPrse": personEnterPrse,
  372. })
  373. return
  374. }
  375. func (this *SignApiController) GetPerseEnterPriseById() {
  376. orgId := this.GetAdminUserInfo().CurrentOrgId
  377. admin_user_id, _ := this.GetInt64("admin_user_id")
  378. lastPerson, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId)
  379. this.ServeSuccessJSON(map[string]interface{}{
  380. "lastPerson": lastPerson,
  381. })
  382. return
  383. }
  384. func (this *SignApiController) CreateNewPersionSeal() {
  385. orgId := this.GetAdminUserInfo().CurrentOrgId
  386. admin_user_id, _ := this.GetInt64("admin_user_id")
  387. creater := this.GetAdminUserInfo().AdminUser.Id
  388. userName := service.GetLastAdminUserName(admin_user_id, orgId)
  389. //查询医护是否完成认证
  390. lastPerson, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId)
  391. if lastPerson.ID > 0 {
  392. this.ServeDynamicFailJsonSend("已完成认证,无需再次认证")
  393. return
  394. }
  395. if lastPerson.ID == 0 {
  396. //去认证
  397. personSeal, sealBase64 := service.CreateSKDPersionSeal(lastPerson.UserId, userName)
  398. fmt.Println("sealBase64", sealBase64)
  399. enterprise := models.XtDevicePersonEnterprise{
  400. AdminUserId: admin_user_id,
  401. DisplayName: "",
  402. Phone: "",
  403. IdCardNum: "",
  404. UserOrgId: orgId,
  405. Status: 1,
  406. Creater: creater,
  407. Ctime: time.Now().Unix(),
  408. Mtime: 0,
  409. UserId: "",
  410. Personsealid: "",
  411. Sealid: "",
  412. UserName: userName,
  413. Sealbase64: sealBase64,
  414. }
  415. service.CreateEnterpriseUserName(enterprise)
  416. this.ServeSuccessJSON(map[string]interface{}{
  417. "personSeal": personSeal,
  418. })
  419. return
  420. }
  421. }
  422. func (this *SignApiController) CreateNewEnterPrise() {
  423. //orgId := this.GetAdminUserInfo().CurrentOrgId
  424. //
  425. //admin_user_id, _ := this.GetInt64("admin_user_id")
  426. //
  427. //enterPrise, _ := service.GetEnterPriseByUserOrgId(orgId)
  428. //fmt.Println("地址日活", enterPrise.Enterpriseid)
  429. //lastPerson, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId)
  430. //
  431. //newEnterPrise, sealId := service.CreateNewEnterPrise(enterPrise.Enterpriseid, lastPerson.UserId)
  432. //
  433. //fmt.Println("newEnterPrise",newEnterPrise)
  434. //service.UpdatePersonEnterPrise(lastPerson.ID, sealId)
  435. newEnterPrise, _ := service.CreateSDKEnterPrise()
  436. //var url string
  437. //url = "http://localhost:8890/sdk/seal/createEnterpriseSeal"
  438. //appId := beego.AppConfig.String("sign_appid")
  439. //
  440. //serviceKye := beego.AppConfig.String("serviceKye")
  441. //
  442. //serviceCode := beego.AppConfig.String("serviceCode")
  443. //
  444. //maprequest := make(map[string]interface{})
  445. //
  446. //maprequest["sealType"] = 1
  447. //maprequest["enterpriseName"] = "深圳伊森时光科技有限公司"
  448. //maprequest["horizontalText"] = "财务专用章"
  449. //
  450. //byterequest, _ := json.Marshal(maprequest)
  451. //reader := bytes.NewReader(byterequest)
  452. //
  453. //signatureStr, _ := service.GenerateHMACSHA1SignatureTwo(maprequest, serviceKye, serviceCode)
  454. //fmt.Println("signatureStr", signatureStr)
  455. //request, err := http.NewRequest("POST", url, reader)
  456. //
  457. //fmt.Println("request23222222222222222", request)
  458. //if err != nil {
  459. // fmt.Println(err.Error())
  460. //}
  461. //
  462. //request.Header.Set("appId", appId)
  463. //request.Header.Set("serviceCode", serviceCode)
  464. //request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  465. //request.Header.Set("Content-Signature", signatureStr)
  466. //client := http.Client{}
  467. //
  468. //resp, err := client.Do(request)
  469. //if err != nil {
  470. // fmt.Println(err.Error())
  471. //
  472. //}
  473. //respBytes, err := ioutil.ReadAll(resp.Body)
  474. //if err != nil {
  475. // fmt.Println(err.Error())
  476. //
  477. //}
  478. //str := string(respBytes)
  479. //fmt.Println("strwowowowowo", str)
  480. //
  481. //var respJSON map[string]interface{}
  482. //if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
  483. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  484. //}
  485. this.ServeSuccessJSON(map[string]interface{}{
  486. "newEnterPrise": newEnterPrise,
  487. })
  488. return
  489. }
  490. func (this *SignApiController) GetContractId() {
  491. sign := service.GetContractId()
  492. this.ServeSuccessJSON(map[string]interface{}{
  493. "sign": sign,
  494. })
  495. return
  496. }
  497. func (this *SignApiController) EndEnterPrise() {
  498. sign := service.EndEnterPrise()
  499. this.ServeSuccessJSON(map[string]interface{}{
  500. "sign": sign,
  501. })
  502. return
  503. }
  504. func (this *SignApiController) GetEnterPriseDetail() {
  505. sign, url := service.GetEnterPriseDetail()
  506. this.ServeSuccessJSON(map[string]interface{}{
  507. "sign": sign,
  508. "url": url,
  509. })
  510. return
  511. }
  512. func (this *SignApiController) UploadPrintOrder() {
  513. orderList, _ := service.GetDialysisOrderListOne(21741)
  514. for _, item := range orderList {
  515. service.UpdateSchedulePatient(item.PatientId, item.DialysisDate, item.ZoneId, item.BedID)
  516. }
  517. //list, _ := service.GetAllPatientNew(10375)
  518. //for _, item := range list {
  519. //
  520. // hans := item.Name // 要转换的汉字字符串
  521. // // 创建一个拼音转换器
  522. // p := pinyin.NewArgs()
  523. //
  524. // // 将汉字转为拼音
  525. // pinyinSlice := pinyin.Pinyin(hans, p)
  526. //
  527. // // 输出拼音
  528. // fmt.Println("Pinyin:", pinyinSlice)
  529. //
  530. // // 获取首字母
  531. // firstLetter := ""
  532. // for _, py := range pinyinSlice {
  533. // if len(py) > 0 {
  534. // firstLetter += string(py[0][0])
  535. // }
  536. // }
  537. //
  538. // item.FirstLetter = firstLetter
  539. // service.UpdatePatientNew(item.ID, item.FirstLetter)
  540. // // 输出首字母
  541. // //fmt.Println("First Letter:", firstLetter)
  542. //}
  543. //baseList, _ := service.GeteAllBaseList(10375)
  544. //for _, item := range baseList {
  545. // hans := item.DrugName // 要转换的汉字字符串
  546. // // 创建一个拼音转换器
  547. // p := pinyin.NewArgs()
  548. // // 将汉字转为拼音
  549. // pinyinSlice := pinyin.Pinyin(hans, p)
  550. // // 获取首字母
  551. // firstLetter := ""
  552. // for _, py := range pinyinSlice {
  553. // if len(py) > 0 {
  554. // firstLetter += string(py[0][0])
  555. // }
  556. // }
  557. // item.FirstLetter = firstLetter
  558. // service.UpdateBaseList(item.ID, item.FirstLetter)
  559. //}
  560. //pdf := gofpdf.New("P", "mm", "A4", "")
  561. //pdf.AddPage()
  562. //pdf.Text(5, 10, "血液净化治疗记录单")
  563. //
  564. //pdf.AddUTF8Font("simfang", "", "D:/go/src/pkg/mod/github.com/jung-kurt/gofpdf@v1.16.2/font/simfang.ttf")
  565. //pdf.SetFont("simfang", "", 20)
  566. //var title = "血液透析(滤过)记录表单"
  567. ////表格居中显示
  568. //pdf.Text(70, 10, title)
  569. //wd := pdf.GetStringWidth(title) + 100
  570. //fmt.Println("wd", wd)
  571. //pdf.SetY(100) //先要设置 Y,然后再设置 X。否则,会导致 X 失效
  572. //pdf.SetX((210 - wd) / 2) //水平居中的算法
  573. //var numuber = "张三"
  574. ////表格居中显示
  575. //pdf.SetFont("", "", 14) // 设置加粗字体和字号
  576. //pdf.Text(10, 20, "姓名:"+numuber)
  577. //pdf.SetFont("", "", 14) // 设置加粗字体和字号
  578. //pdf.Text(35, 20, "性别:"+"男")
  579. //pdf.SetFont("", "", 14) // 设置正常字体和字号
  580. //pdf.Text(60, 20, "年龄:"+"18")
  581. //pdf.SetFont("", "", 14) // 设置正常字体和字号
  582. //pdf.Text(90, 20, "门诊:"+"住院")
  583. //pdf.SetFont("", "", 14) // 设置正常字体和字号
  584. //pdf.Text(120, 20, "病区:"+"A区")
  585. //pdf.SetFont("", "", 14) // 设置正常字体和字号
  586. //pdf.Text(150, 20, "床号:"+"1号")
  587. //pdf.SetFont("", "", 14) // 设置正常字体和字号
  588. //pdf.Text(180, 20, "透析号:")
  589. //pdf.SetFont("", "", 14) // 设置正常字体和字号
  590. //pdf.Text(210, 20, "住院号/门诊号:")
  591. //pdf.SetFont("", "", 14) // 设置正常字体和字号
  592. ////表格居中显示
  593. //pdf.SetFont("", "", 14) // 设置加粗字体和字号
  594. //pdf.Text(10, 30, "入科方式:"+numuber)
  595. //pdf.SetFont("", "", 14) // 设置加粗字体和字号
  596. //pdf.Text(60, 30, "诊断:")
  597. //
  598. //pdf.AddUTF8Font("simfang", "", "D:/go/src/pkg/mod/github.com/jung-kurt/gofpdf@v1.16.2/font/simfang.ttf")
  599. //pdf.SetFont("simfang", "", 16) // 设置字体、字号
  600. //pdf.SetFillColor(200, 200, 200)
  601. ////// 设置起始位置
  602. //var x = 10.0
  603. //var y = 40.0
  604. //pdf.SetXY(x, y)
  605. //// 设置填充颜色
  606. //pdf.CellFormat(200, 15, "透析前情况", "1", 0, "CM", false, 0, "") // 使用CellFormat()方法创建表格单元格
  607. //param1: 单元格的宽,为0时表示一行,单位根据new()里面设置的来
  608. //param2: 单元格的高,不能为0,单位根据new()里面设置的来
  609. //param3: 单元格内容
  610. //param4: 边框样式,一个空字符串表示无边框,“1”表示全边框,一个或多个“L”,“T”,“R”和“B”分别表示边界左,上,右,下
  611. //param5: 表示调用后当前位置的位置。可能的值为0,接着当前行继续,1换行,2目前没有试过
  612. //param6: 字体的位置,水平对齐包括"L", “C"或"R”(左,中,右)。垂直对齐由包含控制"T", “M”, “B"或"A”(上,中,下,基线),可以组合,比如说LT,CM等等
  613. //param7: 是否填充单元格,需要调用SetFillColor()方法.默认false
  614. //param8: 内部超链接,没用过
  615. //param9: 超链接,没用过
  616. //pdf.AddUTF8Font("simfang", "", "D:/go/src/pkg/mod/github.com/jung-kurt/gofpdf@v1.16.2/font/simfang.ttf")
  617. //pdf.SetFont("simfang", "", 8) // 设置字体、字号
  618. //pdf.SetFillColor(200, 200, 200) // 设置填充颜色
  619. //
  620. //// 设置起始位置
  621. //var x = 10.0
  622. //var y = 40.0
  623. ////创建8行2列的表格
  624. //
  625. //for j := 0; j < 1; j++ {
  626. // // 填充每个单元格的内容
  627. // pdf.SetXY(x, y) // 设置当前位置
  628. // pdf.CellFormat(20, 15, "时间", "1", 0, "CM", false, 0, "") // 使用CellFormat()方法创建表格单元格
  629. // pdf.CellFormat(20, 15, "血压(mmHg)", "1", 0, "CM", false, 0, "")
  630. // pdf.CellFormat(20, 15, "脉搏(次/分)", "1", 0, "CM", false, 0, "")
  631. // pdf.CellFormat(20, 15, "呼吸(次/分)", "1", 0, "CM", false, 0, "")
  632. // pdf.CellFormat(20, 15, "血流量(ml/min)", "1", 0, "CM", false, 0, "")
  633. // pdf.CellFormat(20, 15, "静脉压(mmHg)", "1", 0, "CM", false, 0, "")
  634. // pdf.CellFormat(20, 15, "跨膜压(mmHg)", "1", 0, "CM", false, 0, "")
  635. // pdf.CellFormat(20, 15, "透析液温(℃)", "1", 0, "CM", false, 0, "")
  636. // pdf.CellFormat(20, 15, "钠浓度(mmol/L)", "1", 0, "CM", false, 0, "")
  637. // pdf.CellFormat(20, 15, "超滤量(ml) ", "1", 0, "CM", false, 0, "")
  638. // pdf.CellFormat(35, 15, "病情变化及处理", "1", 0, "CM", false, 0, "")
  639. //
  640. // y += 15 // 下一行起始位置的y坐标增加60(单元格高度)
  641. //}
  642. //for j := 0; j < 1; j++ {
  643. // // 填充每个单元格的内容
  644. // pdf.SetXY(x, y) // 设置当前位置
  645. // pdf.CellFormat(20, 15, "13:57", "1", 0, "CM", false, 0, "") // 使用CellFormat()方法创建表格单元格
  646. // pdf.CellFormat(20, 15, "120/90", "1", 0, "CM", false, 0, "")
  647. // pdf.CellFormat(20, 15, "64", "1", 0, "CM", false, 0, "")
  648. // pdf.CellFormat(20, 15, "100", "1", 0, "CM", false, 0, "")
  649. // pdf.CellFormat(20, 15, "100", "1", 0, "CM", false, 0, "")
  650. // pdf.CellFormat(20, 15, "100", "1", 0, "CM", false, 0, "")
  651. // pdf.CellFormat(20, 15, "90", "1", 0, "CM", false, 0, "")
  652. // pdf.CellFormat(20, 15, "36.5", "1", 0, "CM", false, 0, "")
  653. // pdf.CellFormat(20, 15, "26", "1", 0, "CM", false, 0, "")
  654. // pdf.CellFormat(20, 15, "100", "1", 0, "CM", false, 0, "")
  655. // pdf.CellFormat(35, 15, "及时九嶷山", "1", 0, "CM", false, 0, "")
  656. //
  657. // y += 15 // 下一行起始位置的y坐标增加60(单元格高度)
  658. //}
  659. //x += 200.0 // 下一列起始位置的x坐标增加190(单元格宽度)
  660. //y = 10.0 // 行起始位置的y坐标重置为10
  661. //
  662. //pdf.Ln(2)
  663. //if err := pdf.OutputFileAndClose("6.pdf"); err != nil {
  664. // panic(err.Error())
  665. //}
  666. // 此处可以继续绘制表格的其他部分,例如内容行等。
  667. // ...
  668. // 保存PDF文档到文件
  669. //err := pdf.OutputFileAndClose("treatment_sheet_with_header.pdf")
  670. //if err != nil {
  671. // panic(err)
  672. //}
  673. this.ServeSuccessJSON(map[string]interface{}{
  674. //"sign": information,
  675. //"pdfBase64": pdfBase64,
  676. //"name": name,
  677. })
  678. }
  679. func (this *SignApiController) CreateQianshuUserName() {
  680. admin_user_id, _ := this.GetInt64("admin_user_id")
  681. orgId := this.GetAdminUserInfo().CurrentOrgId
  682. userName := service.GetLastAdminUserName(admin_user_id, orgId)
  683. idCardNumber := service.GetLastAdminUserIdCardNumber(admin_user_id, orgId)
  684. adminRole, _ := service.GetMobile(admin_user_id)
  685. //查询该医护人员是否已经签署了
  686. lastPerson, _ := service.GetLastPersonEnterPrise(admin_user_id, orgId)
  687. if len(lastPerson.UserId) > 0 {
  688. this.ServeDynamicFailJsonSend("已完成签署,无需再次签署")
  689. return
  690. }
  691. if len(lastPerson.UserId) == 0 {
  692. //去签署
  693. sign, userId := service.CreateQianshuUserName(userName, adminRole.Mobile, idCardNumber)
  694. err := service.UpdatePersionEnterPrise(lastPerson.ID, userId)
  695. fmt.Println(err)
  696. this.ServeSuccessJSON(map[string]interface{}{
  697. "sign": sign,
  698. "userId": userId,
  699. })
  700. }
  701. }
  702. func (this *SignApiController) CreateSdkSendInformation() {
  703. information, orderId := service.CreateSdkSendInformation()
  704. this.ServeSuccessJSON(map[string]interface{}{
  705. "information": information,
  706. "orderId": orderId,
  707. })
  708. }
  709. func (this *SignApiController) SavePdfInformation() {
  710. var name string
  711. information, pdfBase64 := service.SavePdfInformation(name)
  712. informationOne := service.ToCheckInformation(pdfBase64)
  713. maprequest := make(map[string]interface{})
  714. Receiver := make(map[string]interface{})
  715. //业务单号
  716. maprequest["orderId"] = "13318464642"
  717. maprequest["signTitle"] = "举报合同"
  718. //file := "C:/Users/28169/Desktop/2.pdf"
  719. file := "/swspan/gopath/src/XT_New/static/6.pdf"
  720. fileBytes, _ := ioutil.ReadFile(file) // 读取file
  721. contractBase64 := base64.StdEncoding.EncodeToString(fileBytes) // 加密成base64字符串
  722. //文件获取方式
  723. maprequest["fileType"] = 1
  724. maprequest["pdfBase64"] = contractBase64
  725. //合同内容
  726. maprequest["fileContent"] = contractBase64
  727. //签署用户人ID
  728. maprequest["userId"] = "JMO9U8JH4TN8E3QOI0GUVUF2"
  729. //业务单号
  730. maprequest["receiver"] = Receiver
  731. //签署人账号
  732. Receiver["account"] = "13318464642"
  733. //签署个人类型 1.个人 2.企业
  734. Receiver["signerType"] = 1
  735. //签署人姓名
  736. Receiver["realName "] = "马文强"
  737. // 证件类型
  738. Receiver["cardType"] = 0
  739. //证件编码
  740. Receiver["cardNumber"] = "430526199408156511"
  741. stepStamper := make(map[string]interface{})
  742. keywordSignControls := make([]map[string]interface{}, 0)
  743. //预冲者样式
  744. inputArrOne := make(map[string]interface{})
  745. inputArrOne["sealName"] = "1"
  746. inputArrOne["keyword"] = "医生签名"
  747. inputArrOne["pages"] = "0"
  748. inputArrOne["offsetX"] = "100"
  749. inputArrOne["offsetY"] = "100"
  750. keywordSignControls = append(keywordSignControls, inputArrOne)
  751. //穿刺者样式
  752. //inputArr := make(map[string]interface{})
  753. //inputArr["sealName"] = "2"
  754. //inputArr["keyword"] = "治疗护士"
  755. //inputArr["pages"] = "1"
  756. //inputArr["offsetX"] = "100"
  757. //inputArr["offsetY"] = "0"
  758. //
  759. //keywordSignControls = append(keywordSignControls, inputArr)
  760. //
  761. ////上机者
  762. //inputArrSix := make(map[string]interface{})
  763. //inputArrSix["sealName"] = "3"
  764. //inputArrSix["keyword"] = "核对护士"
  765. //inputArrSix["pages"] = "1"
  766. //inputArrSix["offsetX"] = "100"
  767. //inputArrSix["offsetY"] = "0"
  768. //
  769. //keywordSignControls = append(keywordSignControls, inputArrSix)
  770. //
  771. //stepStamper["keywordSignControls"] = keywordSignControls
  772. //
  773. ////医生签名
  774. //inputArrSeven := make(map[string]interface{})
  775. //inputArrSeven["sealName"] = "4"
  776. //inputArrSeven["keyword"] = "医生签名"
  777. //inputArrSeven["pages"] = "1"
  778. //inputArrSeven["offsetX"] = "100"
  779. //inputArrSeven["offsetY"] = "0"
  780. //
  781. //keywordSignControls = append(keywordSignControls, inputArrSeven)
  782. //
  783. //stepStamper["keywordSignControls"] = keywordSignControls
  784. //crossSignControls := make([]map[string]interface{}, 0)
  785. //
  786. //inputArrTwo := make(map[string]interface{})
  787. //inputArrTwo["sealName"] = "1"
  788. //inputArrTwo["positionX"] = "0"
  789. //inputArrTwo["positionY"] = "0"
  790. //inputArrTwo["pages"] = "0"
  791. //crossSignControls = append(crossSignControls, inputArrTwo)
  792. //
  793. //stepStamper["crossSignControls"] = crossSignControls
  794. //
  795. xySignControls := make([]map[string]interface{}, 0)
  796. inputArrThree := make(map[string]interface{})
  797. inputArrThree["sealName"] = "1"
  798. inputArrThree["positionX"] = "100"
  799. inputArrThree["positionY"] = "0"
  800. inputArrThree["pages"] = "0"
  801. xySignControls = append(xySignControls, inputArrThree)
  802. stepStamper["xySignControls"] = xySignControls
  803. maprequest["stepStamper"] = stepStamper
  804. seals := make([]map[string]interface{}, 0)
  805. //预冲者
  806. sealImagesList := make(map[string]interface{})
  807. fileOne := "/swspan/gopath/src/XT_New/static/huangzihui.jpg"
  808. fileBytesOne, _ := ioutil.ReadFile(fileOne) // 读取file
  809. contractBase64One := base64.StdEncoding.EncodeToString(fileBytesOne) // 加密成base64字符串
  810. sealImagesList["sealBase64"] = contractBase64One
  811. //控制签名的大小
  812. sealImagesList["width"] = "50"
  813. sealImagesList["height"] = "50"
  814. sealImagesList["verticalAlign"] = "middle"
  815. sealTextsList := make(map[string]interface{})
  816. sealTextsList["text"] = "2023年8月8日"
  817. sealTextsList["fontSize"] = "100"
  818. sealTextsList["fontColor"] = "#333333"
  819. sealTextsList["isTextArea"] = true
  820. sealTextsList["textAlign"] = 0
  821. sealTextsList["width"] = 150
  822. sealTextsList["height"] = 20
  823. sealsObj := make(map[string]interface{})
  824. sealsObj["sealWidth"] = "150"
  825. sealsObj["sealHeight"] = "150"
  826. sealsObj["sealName"] = "1"
  827. sealsObj["sealImage"] = sealImagesList
  828. sealsObj["sealText"] = sealTextsList
  829. seals = append(seals, sealsObj)
  830. //穿刺者
  831. //sealImagesListOne := make(map[string]interface{})
  832. //
  833. //fileTwo := "/swspan/gopath/src/XT_New/static/huangjunji.jpg"
  834. //
  835. //fileBytesTwo, _ := ioutil.ReadFile(fileTwo) // 读取file
  836. //
  837. //contractBase64Two := base64.StdEncoding.EncodeToString(fileBytesTwo) // 加密成base64字符串
  838. //sealImagesListOne["sealBase64"] = contractBase64Two
  839. ////控制签名的大小
  840. //sealImagesListOne["width"] = "50"
  841. //sealImagesListOne["height"] = "50"
  842. //sealImagesListOne["verticalAlign"] = "middle"
  843. //
  844. //sealTextsListOne := make(map[string]interface{})
  845. //sealTextsListOne["text"] = "2023年8月8日"
  846. //sealTextsListOne["fontSize"] = "100"
  847. //sealTextsListOne["fontColor"] = "100"
  848. //sealTextsListOne["isTextArea"] = true
  849. //sealTextsListOne["textAlign"] = 0
  850. //sealTextsListOne["width"] = 150
  851. //sealTextsListOne["height"] = 20
  852. //
  853. //sealsObjOne := make(map[string]interface{})
  854. //
  855. //sealsObjOne["sealWidth"] = "150"
  856. //sealsObjOne["sealHeight"] = "150"
  857. //sealsObjOne["sealName"] = "2"
  858. //sealsObjOne["sealImage"] = sealImagesListOne
  859. //sealsObjOne["sealText"] = sealTextsListOne
  860. //seals = append(seals, sealsObjOne)
  861. //间隔签名
  862. //上机者
  863. //sealImagesListTwo := make(map[string]interface{})
  864. //fileThree := "/swspan/gopath/src/XT_New/static/jianfeixia.jpg"
  865. //fileBytesThree, _ := ioutil.ReadFile(fileThree) // 读取file
  866. //contractBase64Three := base64.StdEncoding.EncodeToString(fileBytesThree) // 加密成base64字符串
  867. //sealImagesListTwo["sealBase64"] = contractBase64Three
  868. ////控制签名的大小
  869. //sealImagesListTwo["width"] = "50"
  870. //sealImagesListTwo["height"] = "50"
  871. //sealImagesListTwo["verticalAlign"] = "middle"
  872. //
  873. //sealTextsListTwo := make(map[string]interface{})
  874. //sealTextsListTwo["text"] = "2023年8月8日"
  875. //sealTextsListTwo["fontSize"] = "100"
  876. //sealTextsListTwo["fontColor"] = "100"
  877. //sealTextsListTwo["isTextArea"] = true
  878. //sealTextsListTwo["textAlign"] = 0
  879. //sealTextsListTwo["width"] = 150
  880. //sealTextsListTwo["height"] = 20
  881. //
  882. //sealsObjTwo := make(map[string]interface{})
  883. //
  884. //sealsObjTwo["sealWidth"] = "150"
  885. //sealsObjTwo["sealHeight"] = "150"
  886. //sealsObjTwo["sealName"] = "3"
  887. //sealsObjTwo["sealImage"] = sealImagesListTwo
  888. //sealsObjTwo["sealText"] = sealTextsListTwo
  889. //seals = append(seals, sealsObjTwo)
  890. //医生签名
  891. //sealImagesListThree := make(map[string]interface{})
  892. //fileFour := "/swspan/gopath/src/XT_New/static/jianfeixia.jpg"
  893. //fileBytesFour, _ := ioutil.ReadFile(fileFour) // 读取file
  894. //contractBase64Tour := base64.StdEncoding.EncodeToString(fileBytesFour) // 加密成base64字符串
  895. //sealImagesListThree["sealBase64"] = contractBase64Tour
  896. ////控制签名的大小
  897. //sealImagesListThree["width"] = "50"
  898. //sealImagesListThree["height"] = "50"
  899. //sealImagesListThree["verticalAlign"] = "middle"
  900. //
  901. //sealTextsListThree := make(map[string]interface{})
  902. //sealTextsListThree["text"] = "2023年8月8日"
  903. //sealTextsListThree["fontSize"] = "100"
  904. //sealTextsListThree["fontColor"] = "100"
  905. //sealTextsListThree["isTextArea"] = true
  906. //sealTextsListThree["textAlign"] = 0
  907. //sealTextsListThree["width"] = 150
  908. //sealTextsListThree["height"] = 20
  909. //
  910. //sealsObjThree := make(map[string]interface{})
  911. //
  912. //sealsObjThree["sealWidth"] = "150"
  913. //sealsObjThree["sealHeight"] = "150"
  914. //sealsObjThree["sealName"] = "4"
  915. //sealsObjThree["sealImage"] = sealImagesListThree
  916. //sealsObjThree["sealText"] = sealTextsListThree
  917. //seals = append(seals, sealsObjThree)
  918. maprequest["seals"] = seals
  919. maprequest["isUserWishes"] = true
  920. maprequest["phone"] = "13318464642"
  921. maprequest["verificationCode"] = "18888888888"
  922. this.ServeSuccessJSON(map[string]interface{}{
  923. "information": information,
  924. "orderId": pdfBase64,
  925. "informationOne": informationOne,
  926. "maprequest": maprequest,
  927. })
  928. }
  929. func (this *SignApiController) ToCheckInformation() {
  930. var name string
  931. information, pdfBase64 := service.SavePdfInformation(name)
  932. informationOne := service.ToCheckInformation(pdfBase64)
  933. this.ServeSuccessJSON(map[string]interface{}{
  934. "information": information,
  935. "informationOne": informationOne,
  936. })
  937. }
  938. func (this *SignApiController) ToAutoDrug() {
  939. //advice, _ := service.GetAutoDrugList(9919)
  940. //
  941. //for _, item := range advice {
  942. // //查找该患者是否出库过
  943. // outList, _ := service.GetDrugAutoWarehouseOutList(item.PatientId, item.UserOrgId, item.DrugId, item.AdviceDate)
  944. // if outList.ID == 0 {
  945. // service.HisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
  946. // }
  947. //}
  948. //prescriptionList, _ := service.GetAllPrescriptionList(10579)
  949. list, _ := service.GetScheduleListByOrder(10579)
  950. for _, item := range list {
  951. soluton, _ := service.GetDialysisSoluton(item.PatientId, item.ModeId)
  952. var DialysisMachineName string
  953. if len(soluton.DialysisDialyszers) > 0 {
  954. DialysisMachineName = soluton.DialysisDialyszers
  955. }
  956. //if len(soluton.DialyzerPerfusionApparatus) > 0 {
  957. // DialysisMachineName = DialysisMachineName + "," + soluton.DialyzerPerfusionApparatus
  958. //}
  959. if len(soluton.DialysisIrrigation) > 0 {
  960. DialysisMachineName = DialysisMachineName + "," + soluton.DialysisIrrigation
  961. }
  962. if len(soluton.DialysisStrainer) > 0 {
  963. DialysisMachineName = DialysisMachineName + "," + soluton.DialysisStrainer
  964. }
  965. DialysisMachineName = DialysisMachineName
  966. service.UpdateDialysisSchedule(item.ID, DialysisMachineName)
  967. }
  968. //for _, item := range prescriptionList {
  969. // var DialysisMachineName string
  970. // if len(item.DialysisDialyszers) > 0 {
  971. // DialysisMachineName = item.DialysisDialyszers
  972. // }
  973. // if len(item.DialyzerPerfusionApparatus) > 0 {
  974. // DialysisMachineName = DialysisMachineName + "," + item.DialyzerPerfusionApparatus
  975. // }
  976. //
  977. // if len(item.DialysisIrrigation) > 0 {
  978. // DialysisMachineName = DialysisMachineName + "," + item.DialysisIrrigation
  979. // }
  980. //
  981. // if len(item.DialysisStrainer) > 0 {
  982. // DialysisMachineName = DialysisMachineName + "," + item.DialysisStrainer
  983. // }
  984. // DialysisMachineName = DialysisMachineName
  985. // service.UpdateSchPatient(item.PatientId, item.RecordDate, item.UserOrgId, DialysisMachineName)
  986. //}
  987. this.ServeSuccessJSON(map[string]interface{}{
  988. "msg": "ok",
  989. })
  990. }
  991. func (this *SignApiController) ToAutoDiagnose() {
  992. //orgId := this.GetAdminUserInfo().CurrentOrgId
  993. //order, _ := service.GetDialysisOrderTotalCount()
  994. //
  995. //for _, item := range order {
  996. //
  997. // service.ModifyPatient(item.PatientId, item.Count)
  998. //}
  999. //list, _ := service.GetNewAllpatient(orgId)
  1000. //
  1001. //for _, item := range list {
  1002. // service.UpdateAllPatient(item.BloodId, item.Diagnose, item.UserOrgId)
  1003. //}
  1004. //list, _ := service.GetAllDialysisOrderTwo(10340)
  1005. //
  1006. //for _, item := range list {
  1007. // schedule, _ := service.GetLastScheduleByUserOrg(item.PatientId, item.DialysisDate, orgId, item.BedId, item.ZoneId, item.SchedualType)
  1008. // service.UpdateScheduleByOrder(item.PatientId, item.DialysisDate, orgId, item.BedId, item.ZoneId, item.SchedualType, schedule.ID)
  1009. //}
  1010. //drugList, _ := service.GetAllBaseDrugList(10318)
  1011. //for _, item := range drugList {
  1012. // service.UpdateDrugWarehouseInfoByDrug(item.ID, item.MinPrice, item.OrgId)
  1013. //
  1014. // //service.UpdateHisDoctorAdviceOne(item.ID, item.MinPrice, item.OrgId)
  1015. //}
  1016. //goodList, _ := service.GetAllGoodList(10571)
  1017. //for _, item := range goodList {
  1018. // service.UpdasteGoodWarehouseInfoByGood(item.ID, item.PackingPrice, item.OrgId)
  1019. //}
  1020. //list, _ := service.GetAllDialysisPrescription(29190)
  1021. //
  1022. //for _, item := range list {
  1023. // service.UpdateSchedulePrescrition(item.PatientId, item.RecordDate, item.UserOrgId, item.ModeId)
  1024. //}
  1025. //list, _ := service.GetPatientLapseList()
  1026. //
  1027. //fmt.Println(list)
  1028. //if len(list) > 0 {
  1029. // for _, items := range list {
  1030. // schedulelist, _ := service.GetPatientScheduleListByItem(items.ID)
  1031. // if len(schedulelist) < 2 {
  1032. // for _, it := range schedulelist {
  1033. // orderList, _ := service.GetAllDialysisOrder(it.PatientId, 1731254400, 1731254400)
  1034. // for _, item := range orderList {
  1035. // schedule, _ := service.GetLastScheduleByUserOrg(item.PatientId, item.DialysisDate, item.UserOrgId, item.BedId, item.ZoneId, item.SchedualType)
  1036. // prescribeOne, _ := service.GetDialysisPrescribeOne(item.UserOrgId, item.PatientId, item.DialysisDate)
  1037. // service.UpdateScheduleByOrder(item.PatientId, item.DialysisDate, item.UserOrgId, item.BedId, item.ZoneId, item.SchedualType, schedule.ID, prescribeOne.ModeId)
  1038. // }
  1039. //
  1040. // }
  1041. // }
  1042. // }
  1043. //}
  1044. //adviceList, _ := service.GetHisDoctorAdviceNoCheck(10721)
  1045. //
  1046. //if len(adviceList) > 0 {
  1047. // for _, item := range adviceList {
  1048. // checkObj, _ := service.GetDobuleCheckOne(item.UserOrgId, item.AdviceDate, item.PatientId)
  1049. // service.UpdateHisAdvice(item.PatientId, item.AdviceDate, item.UserOrgId, checkObj.Creater, checkObj.CheckDate)
  1050. // }
  1051. //}
  1052. //advice, _ := service.GetDoctorAdviceListByUserOrgId(10740, 1736179200)
  1053. //
  1054. //db := service.XTWriteDB()
  1055. //tx := db.Begin()
  1056. //defer func() {
  1057. // if r := recover(); r != nil {
  1058. // tx.Rollback()
  1059. // } else {
  1060. // tx.Commit()
  1061. // }
  1062. //}()
  1063. //for _, item := range advice {
  1064. //
  1065. // //查找该患者是否出库了
  1066. // outInfo, _ := service.GetSelfDrugWarehouseOutInfo(item.PatientId, item.DrugId, item.AdviceDate)
  1067. // if outInfo.ID == 0 {
  1068. // timeStr := time.Now().Format("2006-01-02")
  1069. // timeArr := strings.Split(timeStr, "-")
  1070. // total, _ := service.FindAllSelfDrugWarehouseOut(10740, tx)
  1071. //
  1072. // total = total + 1
  1073. // warehousing_out_order := strconv.FormatInt(10740, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
  1074. // number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
  1075. // number = number + total
  1076. // warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
  1077. // operation_time := time.Now().Unix()
  1078. //
  1079. // creater := this.GetAdminUserInfo().AdminUser.Id
  1080. //
  1081. // //创建一个出库单
  1082. // drugWarehouseOut := models.XtSelfDrugWarehouseOut{
  1083. // WarehouseOutOrderNumber: warehousing_out_order,
  1084. // OperationTime: operation_time,
  1085. // OrgId: 10740,
  1086. // Creater: creater,
  1087. // Ctime: time.Now().Unix(),
  1088. // Status: 1,
  1089. // WarehouseOutTime: item.AdviceDate,
  1090. // Type: 0,
  1091. // PatientId: item.PatientId,
  1092. // IsCheck: 1,
  1093. // IsSys: 1,
  1094. // }
  1095. //
  1096. // //查询今日是否有出库数据
  1097. // lastWarehouseOut, _ := service.GetSelfDrugLastWarehouseOutTwety(10740, item.AdviceDate, tx, 1)
  1098. //
  1099. // if lastWarehouseOut.ID == 0 {
  1100. // service.AddSelfSigleDrugWarehouseOut(&drugWarehouseOut, tx)
  1101. // }
  1102. //
  1103. // //查询今日是否有出库数据
  1104. // lastWarehouseOutOne, _ := service.GetSelfDrugLastWarehouseOutTwety(10740, item.AdviceDate, tx, 1)
  1105. //
  1106. // var warehousing_out_order_str string
  1107. // if lastWarehouseOut.ID == 0 {
  1108. // warehousing_out_order_str = warehousing_out_order
  1109. // } else {
  1110. // warehousing_out_order_str = lastWarehouseOut.WarehouseOutOrderNumber
  1111. // }
  1112. //
  1113. // //查询库存是否
  1114. // selfBasedrug, _ := service.GetSelfBasedrugByIdTwo(item.DrugId, item.UserOrgId)
  1115. // var prescribing_number_total_one int64
  1116. // //判断单位是否相等
  1117. // if selfBasedrug.MaxUnit == item.PrescribingNumberUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
  1118. // prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
  1119. // count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
  1120. // //转化为最小单位
  1121. // prescribing_number_total_one = count * selfBasedrug.MinNumber
  1122. // }
  1123. //
  1124. // if selfBasedrug.MinUnit == item.PrescribingNumberUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
  1125. // prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
  1126. // count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
  1127. // prescribing_number_total_one = count
  1128. //
  1129. // }
  1130. //
  1131. // if selfBasedrug.MinUnit == item.PrescribingNumberUnit && selfBasedrug.MaxUnit == selfBasedrug.MinUnit {
  1132. // prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
  1133. // count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
  1134. // prescribing_number_total_one = count
  1135. // }
  1136. //
  1137. // //出库
  1138. // warehouseOutInfo := &models.XtSelfDrugWarehouseOutInfo{
  1139. // WarehouseOutId: lastWarehouseOutOne.ID,
  1140. // WarehouseOutOrderNumber: warehousing_out_order_str,
  1141. // DrugId: item.DrugId,
  1142. // Count: prescribing_number_total_one,
  1143. // Price: 0,
  1144. // TotalPrice: 0,
  1145. // Status: 1,
  1146. // Ctime: item.AdviceDate,
  1147. // Mtime: item.AdviceDate,
  1148. // Remark: "",
  1149. // OrgId: item.UserOrgId,
  1150. // Type: 0,
  1151. // Manufacturer: selfBasedrug.Manufacturer,
  1152. // Dealer: selfBasedrug.Dealer,
  1153. // RetailPrice: 0,
  1154. // RetailTotalPrice: 0,
  1155. // CountUnit: selfBasedrug.MinUnit,
  1156. // ExpiryDate: 0,
  1157. // ProductDate: 0,
  1158. // Number: "",
  1159. // BatchNumber: "",
  1160. // IsSys: 0,
  1161. // WarehouseInfoId: 0,
  1162. // AdminUserId: 0,
  1163. // StockCount: "",
  1164. // IsCheck: 1,
  1165. // SysRecordTime: item.AdviceDate,
  1166. // PatientId: item.PatientId,
  1167. // AdviceId: item.ID,
  1168. // ClassType: "",
  1169. // }
  1170. // var warehousingOutInfo []*models.XtSelfDrugWarehouseOutInfo
  1171. // warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
  1172. //
  1173. // for _, it := range warehousingOutInfo {
  1174. //
  1175. // medical, _ := service.GetSelfBaseDrugMedical(it.DrugId, tx)
  1176. // drup, _ := service.FindSelfBaseDrugLibRecord(it.OrgId, it.DrugId, tx)
  1177. // //出库逻辑
  1178. // service.AutoNewSelfDrugDeliverInfoFourtyTwo(item.UserOrgId, it.Count, &lastWarehouseOut, &drup, it, it.CountUnit, tx)
  1179. //
  1180. // //查询剩余库存
  1181. // stockInfo, _ := service.GetSelfDrugAllStockInfo(it.PatientId, it.OrgId, it.DrugId, tx)
  1182. // var sum_count int64
  1183. // for _, its := range stockInfo {
  1184. // if its.MaxUnit == medical.MaxUnit {
  1185. // its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
  1186. // }
  1187. // sum_count += its.StockMaxNumber + its.StockMinNumber
  1188. // }
  1189. // service.UpdateSelfDrugStockCount(it.DrugId, it.OrgId, it.PatientId, sum_count, tx)
  1190. // }
  1191. // }
  1192. //}
  1193. //tx.Commit()
  1194. this.ServeSuccessJSON(map[string]interface{}{
  1195. "msg": "ok",
  1196. })
  1197. }
  1198. func (this *SignApiController) ToAutoJiaYou() {
  1199. list, _ := service.GetPrescriptionListOne(10579)
  1200. for _, item := range list {
  1201. schedule, _ := service.GetPatientScheduleById(item.PatientId, item.RecordDate)
  1202. var DialysisMachineName string
  1203. if len(item.DialysisDialyszers) > 0 {
  1204. DialysisMachineName = item.DialysisDialyszers
  1205. }
  1206. if len(item.DialysisIrrigation) > 0 {
  1207. DialysisMachineName = DialysisMachineName + "," + item.DialysisIrrigation
  1208. }
  1209. if len(item.DialysisStrainer) > 0 {
  1210. DialysisMachineName = DialysisMachineName + "," + item.DialysisStrainer
  1211. }
  1212. DialysisMachineName = DialysisMachineName
  1213. service.UpdateDialysisScheduleOne(schedule.ID, item.ModeId, DialysisMachineName)
  1214. }
  1215. }
  1216. func (this *SignApiController) GetFieldConfigList() {
  1217. orderList, _ := service.GetDialysisOrderByUserOrgId()
  1218. if len(orderList) > 0 {
  1219. filedConfigList, _ := service.GetFieldConfigList(9442)
  1220. for _, item := range orderList {
  1221. for _, it := range filedConfigList {
  1222. //查询该机构该模式是否有这个字段
  1223. fiedConfigObj, _ := service.GetFieldConfigByOrgId(item.UserOrgId, it.FiledNameCn, it.Module)
  1224. if fiedConfigObj.ID == 0 {
  1225. config := models.FiledConfig{
  1226. OrgId: item.UserOrgId,
  1227. Module: it.Module,
  1228. FiledName: it.FiledName,
  1229. FiledNameCn: it.FiledNameCn,
  1230. IsShow: 2,
  1231. CreateTime: time.Now().Unix(),
  1232. UpdateTime: time.Now().Unix(),
  1233. SysModule: it.SysModule,
  1234. IsWrite: it.IsWrite,
  1235. IsSecondMenu: it.IsSecondMenu,
  1236. }
  1237. service.CretedConfig(config)
  1238. }
  1239. }
  1240. }
  1241. }
  1242. //filedConfig, _ := service.GetFieldConfigGroupList(7)
  1243. //if len(filedConfig) > 0 {
  1244. // for _, item := range filedConfig {
  1245. // //查询该机构
  1246. // fiedConfigObj, _ := service.GetFieldConfigByOrgId(9442, item.FiledNameCn, item.Module)
  1247. //
  1248. // if fiedConfigObj.ID == 0 {
  1249. //
  1250. // config := models.FiledConfig{
  1251. // OrgId: 9442,
  1252. // Module: item.Module,
  1253. // FiledName: item.FiledName,
  1254. // FiledNameCn: item.FiledNameCn,
  1255. // IsShow: 2,
  1256. // CreateTime: time.Now().Unix(),
  1257. // UpdateTime: time.Now().Unix(),
  1258. // SysModule: item.SysModule,
  1259. // IsWrite: item.IsWrite,
  1260. // IsSecondMenu: item.IsSecondMenu,
  1261. // }
  1262. //
  1263. // service.CretedConfig(config)
  1264. // }
  1265. // }
  1266. //}
  1267. this.ServeSuccessJSON(map[string]interface{}{
  1268. "msg": "ok",
  1269. })
  1270. }
  1271. // 校验库存的脚本
  1272. func (this *SignApiController) ToCheckQuery() {
  1273. //获取监测监控的库存情况
  1274. queryList, _ := service.GetAllCheckQuery()
  1275. var recordDateStr = time.Now().Format("2006-01-02")
  1276. recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  1277. if len(queryList) > 0 {
  1278. for _, item := range queryList {
  1279. //查询今日该机构总的医嘱数量
  1280. adviceList, _ := service.GetAllDoctorAdviceQueryList(item.UserOrgId, recordDate.Unix())
  1281. if len(adviceList) > 0 {
  1282. for _, it := range adviceList {
  1283. var prescription_count int64
  1284. var out_count int64
  1285. advice, _ := service.GetDrugListById(it.DrugId, it.AdviceDate, it.PatientId)
  1286. medical, _ := service.GetBaseDrugMedical(it.DrugId)
  1287. if len(advice) > 0 {
  1288. for _, its := range advice {
  1289. prescribingNumberSix := strconv.FormatFloat(its.PrescribingNumber, 'f', -1, 64)
  1290. prescribingNumberSeven, _ := strconv.ParseInt(prescribingNumberSix, 10, 64)
  1291. if its.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
  1292. prescription_count += prescribingNumberSeven * medical.MinNumber
  1293. }
  1294. if its.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
  1295. prescription_count += prescribingNumberSeven
  1296. }
  1297. if its.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
  1298. prescription_count += prescribingNumberSeven
  1299. }
  1300. }
  1301. }
  1302. outinfo, _ := service.GetDrugWarehouseOutQueryListById(it.DrugId, it.AdviceDate, it.PatientId)
  1303. if len(outinfo) > 0 {
  1304. for _, s := range outinfo {
  1305. if s.CountUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
  1306. out_count += s.Count * medical.MinNumber
  1307. }
  1308. if s.CountUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
  1309. out_count += s.Count
  1310. }
  1311. if s.CountUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
  1312. out_count += s.Count
  1313. }
  1314. }
  1315. }
  1316. patients, _ := service.GetPatientName(it.PatientId)
  1317. var specifaciton_name string
  1318. specifaciton_name = medical.Dose + medical.DoseUnit + "*" + strconv.FormatInt(medical.MinNumber, 10) + medical.MinUnit + "/" + medical.MaxUnit
  1319. //如果当天医嘱数量和出库数量不一致,那么则插入到数据库
  1320. if prescription_count != out_count {
  1321. checkQuery := models.XtDrugCheckQuery{
  1322. DrugId: it.DrugId,
  1323. RecordDate: it.AdviceDate,
  1324. AdviceCount: prescription_count,
  1325. OutCount: out_count,
  1326. PatientId: it.PatientId,
  1327. UserOrgId: it.UserOrgId,
  1328. ExecutionState: it.ExecutionState,
  1329. IsMedicine: it.IsMedicine,
  1330. DrugName: medical.DrugName,
  1331. SpecificationName: specifaciton_name,
  1332. Name: patients.Name,
  1333. }
  1334. service.CreateCheckQuery(checkQuery)
  1335. }
  1336. }
  1337. }
  1338. //查询今日改机构耗材的总的医嘱数量
  1339. projectList, _ := service.GetAllPrescriptionProjectList(item.UserOrgId, recordDate.Unix())
  1340. if len(projectList) > 0 {
  1341. for _, item := range projectList {
  1342. var prescription_count int64
  1343. var out_count int64
  1344. project, _ := service.GetProjectListByPatient(item.PatientId, item.ProjectId, item.RecordDate)
  1345. for _, its := range project {
  1346. count, _ := strconv.ParseInt(its.Count, 10, 64)
  1347. prescription_count += count
  1348. }
  1349. outList, _ := service.GetWarehosueOutQueryList(item.PatientId, item.ProjectId, item.RecordDate)
  1350. for _, s := range outList {
  1351. out_count += s.Count
  1352. }
  1353. goodIdThirty, _ := service.GetGoodInformationByGoodIdThirty(item.ProjectId)
  1354. patients, _ := service.GetPatientName(item.PatientId)
  1355. //fmt.Println("hahhahahahahhh", item.ProjectId)
  1356. //fmt.Println("prescription_count", prescription_count)
  1357. //fmt.Println("out_count", out_count)
  1358. if prescription_count != out_count {
  1359. stockCheckQuery := models.XtStockCheckQuery{
  1360. GoodId: item.ProjectId,
  1361. RecordDate: item.RecordDate,
  1362. AdviceCount: prescription_count,
  1363. OutCount: out_count,
  1364. PatientId: item.PatientId,
  1365. UserOrgId: item.UserOrgId,
  1366. GoodName: goodIdThirty.GoodName,
  1367. SpecificationName: goodIdThirty.SpecificationName,
  1368. Name: patients.Name,
  1369. }
  1370. service.CreteStockCheckQuery(stockCheckQuery)
  1371. }
  1372. }
  1373. }
  1374. }
  1375. }
  1376. this.ServeSuccessJSON(map[string]interface{}{
  1377. "msg": "ok",
  1378. })
  1379. }