12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303 |
- package controllers
-
- import (
- "XT_New/enums"
- "XT_New/models"
- "XT_New/service"
- "XT_New/utils"
- "encoding/json"
- "fmt"
- "github.com/astaxie/beego"
- "github.com/jinzhu/gorm"
- "reflect"
- "strconv"
- "time"
- )
-
- type ManagerCenterApiController struct {
- BaseAuthAPIController
- }
-
- func ManagerCenterRegistRouters() {
- //药品基础库
- beego.Router("/api/basedruglib/create", &ManagerCenterApiController{}, "post:CreateBaseDrugLib")
- beego.Router("/api/basedruglib/edit", &ManagerCenterApiController{}, "post:EditBaseDrugLib")
- beego.Router("/api/basedruglib/get", &ManagerCenterApiController{}, "get:GetBaseDrugLib")
- beego.Router("/api/basedruglib/list", &ManagerCenterApiController{}, "get:GetBaseDrugLibList")
- beego.Router("/api/medicineinsurancepercent/create", &ManagerCenterApiController{}, "post:CreateMedicineInsurancePercent")
- beego.Router("/api/drugunitsafeguard/create", &ManagerCenterApiController{}, "post:CreateDrugUnitSafeguard")
-
- beego.Router("/api/medicineinsurancepercent/get", &ManagerCenterApiController{}, "get:GetMedicineInsurancePercent")
- //beego.Router("/api/drugunitsafeguard/get", &ManagerCenterApiController{}, "get:GetDrugUnitSafeguard")
- beego.Router("/api/drug/basedruglib", &ManagerCenterApiController{}, "get:DeleteBaseDrugById")
- //专项字典
- beego.Router("/api/dictionary/getconfiglist", &ManagerCenterApiController{}, "get,post:GetConfigList")
- beego.Router("/api/dictionary/createconfig", &ManagerCenterApiController{}, "Post:CreateConfig")
- beego.Router("/api/dictionary/createchildconfig", &ManagerCenterApiController{}, "Post:CreateChildConfig")
- beego.Router("/api/dictionary/updatechildconfig", &ManagerCenterApiController{}, "Post:UpdateChildConfig")
- beego.Router("/api/dictionary/deletechildconfig", &ManagerCenterApiController{}, "Post:DeleteChildConfig")
- beego.Router("/api/dictionary/updatetemplate", &ManagerCenterApiController{}, "Post:UpdateTemplate")
-
- //经销商
- beego.Router("/api/stock/dealer/create", &ManagerCenterApiController{}, "post:CreateDealer")
- beego.Router("/api/stock/dealer/modify", &ManagerCenterApiController{}, "post:ModifyDealer")
- //经过测试这个接口完全不会执行,因为被另一个路由占用了
- beego.Router("/api/stock/dealer/list", &ManagerCenterApiController{}, "get:GetDealersList")
- beego.Router("/api/stock/dealer/delete", &ManagerCenterApiController{}, "post:DeleteDealer")
- beego.Router("/api/stock/dealer/get", &ManagerCenterApiController{}, "get:GetDealer")
-
- //厂商
- beego.Router("/api/stock/manufacturer/create", &ManagerCenterApiController{}, "post:CreateManufacturer")
- beego.Router("/api/stock/manufacturer/modify", &ManagerCenterApiController{}, "post:ModifyManufacturer")
- //经过测试这个接口也完全不会执行,因为被另一个路由占用了
- beego.Router("/api/stock/manufacturer/list", &ManagerCenterApiController{}, "get:GetManufacturerList")
- beego.Router("/api/stock/manufacturer/delete", &ManagerCenterApiController{}, "post:DeleteManufacturer")
- beego.Router("/api/stock/manufacturer/get", &ManagerCenterApiController{}, "get:GetManufacturer")
-
- beego.Router("/api/stock/good/info/create", &ManagerCenterApiController{}, "post:CreateGoodInfo")
- beego.Router("/api/stock/good/info/modify", &ManagerCenterApiController{}, "post:ModifyGoodInfo")
- beego.Router("/api/stock/good/info/list", &ManagerCenterApiController{}, "get:GetGoodInfoList")
- beego.Router("/api/info/delete", &ManagerCenterApiController{}, "post:DeleteGoodInfo")
- beego.Router("/api/stock/good/info/get", &ManagerCenterApiController{}, "get:GetGoodInfoByGoodId")
- beego.Router("/api/stock/good/info", &ManagerCenterApiController{}, "get:GetGoodInfoById")
-
- //门诊大病
- beego.Router("/api/mz/sick/create", &ManagerCenterApiController{}, "post:CreateMZSick")
- beego.Router("/api/mz/sick/modify", &ManagerCenterApiController{}, "post:ModifyMZSick")
- beego.Router("/api/mz/sick/list", &ManagerCenterApiController{}, "get:GetMZSickList")
- beego.Router("/api/mz/sick/delete", &ManagerCenterApiController{}, "post:DeleteMZSick")
- beego.Router("/api/mz/sick/get", &ManagerCenterApiController{}, "get:GetMZSick")
-
- beego.Router("/api/addition/create", &ManagerCenterApiController{}, "post:CreateAddition")
- beego.Router("/api/addition/modify", &ManagerCenterApiController{}, "post:ModifyAddition")
- beego.Router("/api/addition/list", &ManagerCenterApiController{}, "get:GetAdditionList")
- beego.Router("/api/addition/delete", &ManagerCenterApiController{}, "post:DeleteAddition")
- beego.Router("/api/addition/get", &ManagerCenterApiController{}, "get:GetAddition")
-
- //门诊诊断
- beego.Router("/api/diagnose/create", &ManagerCenterApiController{}, "post:CreateDiagnose")
- beego.Router("/api/diagnose/modify", &ManagerCenterApiController{}, "post:ModifyDiagnose")
- beego.Router("/api/diagnose/list", &ManagerCenterApiController{}, "get:GetDiagnoseList")
- beego.Router("/api/diagnose/delete", &ManagerCenterApiController{}, "post:DeleteDiagnose")
- beego.Router("/api/diagnose/get", &ManagerCenterApiController{}, "get:GetDiagnose")
- beego.Router("/api/drug/getalldruglist", &ManagerCenterApiController{}, "get:GetAllDrugList")
- beego.Router("/api/drug/postsearchdruglist", &ManagerCenterApiController{}, "get:GetSearchDrugList")
-
- }
-
- func (c *ManagerCenterApiController) CreateBaseDrugLib() {
- drug_name := c.GetString("drug_name")
- pinyin := c.GetString("pinyin")
- wubi := c.GetString("wubi")
- drug_alias := c.GetString("drug_alias")
- drug_alias_pinyin := c.GetString("drug_alias_pinyin")
- drug_alias_wubi := c.GetString("drug_alias_wubi")
- drug_category, _ := c.GetInt64("drug_category")
- drug_spec := c.GetString("drug_spec")
- drug_type, _ := c.GetInt64("drug_type")
- drug_stock_limit := c.GetString("drug_stock_limit")
- drug_origin_place := c.GetString("drug_origin_place")
- drug_dosage_form, _ := c.GetInt64("drug_dosage_form")
- medical_insurance_level, _ := c.GetInt64("medical_insurance_level")
- max_unit := c.GetString("max_unit")
- min_unit := c.GetString("min_unit")
- unit_matrixing := c.GetString("unit_matrixing")
- retail_price, _ := c.GetFloat("retail_price")
- last_price, _ := c.GetFloat("last_price")
- drug_control, _ := c.GetInt64("drug_control")
- number := c.GetString("number")
- drug_classify := c.GetString("drug_classify")
- drug_dose, _ := c.GetFloat("drug_dose")
- drug_dose_unit, _ := c.GetInt64("drug_dose_unit")
- medical_insurance_number := c.GetString("medical_insurance_number")
- provinces_code := c.GetString("provinces_code")
-
- manufacturer, _ := c.GetInt64("manufacturer")
- pharmacology_category, _ := c.GetInt64("pharmacology_category")
- statistics_category, _ := c.GetInt64("statistics_category")
- code := c.GetString("code")
- is_special_diseases, _ := c.GetInt64("is_special_diseases")
- is_record, _ := c.GetInt64("is_record")
- agent := c.GetString("agent")
- drug_status := c.GetString("drug_status")
- limit_remark := c.GetString("limit_remark")
- delivery_way := c.GetString("delivery_way")
- execution_frequency := c.GetString("execution_frequency")
- single_dose, _ := c.GetFloat("single_dose")
- fmt.Println(single_dose)
- prescribing_number, _ := c.GetFloat("prescribing_number")
- label, _ := c.GetInt64("label")
- sort, _ := c.GetInt64("sort")
- is_use_doctor_advice, _ := c.GetInt64("is_use_doctor_advice")
- is_default, _ := c.GetInt64("is_default")
- is_charge_predict, _ := c.GetInt64("is_charge_predict")
- is_statistics_work, _ := c.GetInt64("is_statistics_work")
- is_charge_use, _ := c.GetInt64("is_charge_use")
- dealer, _ := c.GetInt64("dealer")
- prescription_mark, _ := c.GetInt64("prescription_mark")
- social_security_directory_code := c.GetString("social_security_directory_code")
- record_date := c.GetString("record_date")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- drug_remark := c.GetString("drug_remark")
- dose, _ := c.GetFloat("dose")
- dose_unit := c.GetString("dose_unit")
- min_price, _ := c.GetFloat("min_price")
- min_number, _ := c.GetInt64("min_number")
- drug_day := c.GetString("drug_day")
- hosp_appr_flag, _ := c.GetInt64("hosp_appr_flag")
- lmt_used_flag, _ := c.GetInt64("lmt_used_flag")
- prescribing_number_unit := c.GetString("prescribing_number_unit")
- is_user, _ := c.GetInt64("is_user")
- adminInfo := c.GetAdminUserInfo()
- drugLib := &models.BaseDrugLib{
- DrugName: drug_name,
- Pinyin: pinyin,
- Wubi: wubi,
- DrugAlias: drug_alias,
- DrugAliasPinyin: drug_alias_pinyin,
- DrugAliasWubi: drug_alias_wubi,
- DrugCategory: drug_category,
- DrugSpec: drug_spec,
- DrugType: drug_type,
- DrugStockLimit: drug_stock_limit,
- DrugOriginPlace: drug_origin_place,
- MedicalInsuranceLevel: medical_insurance_level,
- DrugDosageForm: drug_dosage_form,
- MaxUnit: max_unit,
- MinUnit: min_unit,
- UnitMatrixing: unit_matrixing,
- RetailPrice: retail_price,
- LastPrice: last_price,
- DrugControl: drug_control,
- Number: number,
- DrugClassify: drug_classify,
- DrugDose: drug_dose,
- DrugDoseUnit: drug_dose_unit,
- MedicalInsuranceNumber: medical_insurance_number,
- ProvincesCode: provinces_code,
- Manufacturer: manufacturer,
- PharmacologyCategory: pharmacology_category,
- StatisticsCategory: statistics_category,
- Code: code,
- IsSpecialDiseases: is_special_diseases,
- IsRecord: is_record,
- Agent: agent,
- DrugStatus: drug_status,
- LimitRemark: limit_remark,
- DeliveryWay: delivery_way,
- ExecutionFrequency: execution_frequency,
- SingleDose: drug_dose,
- PrescribingNumber: prescribing_number,
- Label: label,
- Sort: sort,
- IsUseDoctorAdvice: is_use_doctor_advice,
- IsDefault: is_default,
- IsChargePredict: is_charge_predict,
- IsStatisticsWork: is_statistics_work,
- IsChargeUse: is_charge_use,
- OrgId: adminInfo.CurrentOrgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Dealer: dealer,
- PrescriptionMark: prescription_mark,
- SocialSecurityDirectoryCode: social_security_directory_code,
- RecordDate: theTime.Unix(),
- DrugRemark: drug_remark,
- DrugDay: drug_day,
- MinNumber: min_number,
- Dose: dose,
- MinPrice: min_price,
- DoseUnit: dose_unit,
- HospApprFlag: hosp_appr_flag,
- LmtUsedFlag: lmt_used_flag,
- PrescribingNumberUnit: prescribing_number_unit,
- IsUse: is_user,
- }
-
- total := service.FindAllDrugLibRecordTotal(adminInfo.CurrentOrgId)
- drug_code := strconv.FormatInt(total+1, 10)
- drug_code = "54000000" + drug_code
- drugLib.DrugCode = drug_code
-
- count := service.FindBaseDrugLibRecordCountOne(drugLib)
-
- if count == 0 {
- err := service.CreateBaseDrugLib(drugLib)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "创建成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- return
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDrugRepeatDataException)
- return
- }
-
- }
-
- func (c *ManagerCenterApiController) EditBaseDrugLib() {
- id, _ := c.GetInt64("id")
- drug_name := c.GetString("drug_name")
- pinyin := c.GetString("pinyin")
- wubi := c.GetString("wubi")
- drug_alias := c.GetString("drug_alias")
- drug_alias_pinyin := c.GetString("drug_alias_pinyin")
- drug_alias_wubi := c.GetString("drug_alias_wubi")
- drug_category, _ := c.GetInt64("drug_category")
- drug_spec := c.GetString("drug_spec")
- drug_type, _ := c.GetInt64("drug_type")
- drug_stock_limit := c.GetString("drug_stock_limit")
- drug_origin_place := c.GetString("drug_origin_place")
- drug_dosage_form, _ := c.GetInt64("drug_dosage_form")
- medical_insurance_level, _ := c.GetInt64("medical_insurance_level")
- max_unit := c.GetString("max_unit")
- min_unit := c.GetString("min_unit")
- unit_matrixing := c.GetString("unit_matrixing")
- retail_price, _ := c.GetFloat("retail_price")
- last_price, _ := c.GetFloat("last_price")
- drug_control, _ := c.GetInt64("drug_control")
- number := c.GetString("number")
- drug_classify := c.GetString("drug_classify")
- drug_dose, _ := c.GetFloat("drug_dose")
- drug_dose_unit, _ := c.GetInt64("drug_dose_unit")
- medical_insurance_number := c.GetString("medical_insurance_number")
- provinces_code := c.GetString("provinces_code")
-
- manufacturer, _ := c.GetInt64("manufacturer")
- pharmacology_category, _ := c.GetInt64("pharmacology_category")
- statistics_category, _ := c.GetInt64("statistics_category")
- code := c.GetString("code")
- is_special_diseases, _ := c.GetInt64("is_special_diseases")
- is_record, _ := c.GetInt64("is_record")
- agent := c.GetString("agent")
- drug_status := c.GetString("drug_status")
- limit_remark := c.GetString("limit_remark")
- delivery_way := c.GetString("delivery_way")
- execution_frequency := c.GetString("execution_frequency")
- single_dose, _ := c.GetFloat("single_dose")
- fmt.Println("sigle_dose", single_dose)
- prescribing_number, _ := c.GetFloat("prescribing_number")
- label, _ := c.GetInt64("label")
- sort, _ := c.GetInt64("sort")
- is_use_doctor_advice, _ := c.GetInt64("is_use_doctor_advice")
- is_default, _ := c.GetInt64("is_default")
- is_charge_predict, _ := c.GetInt64("is_charge_predict")
- is_statistics_work, _ := c.GetInt64("is_statistics_work")
- is_charge_use, _ := c.GetInt64("is_charge_use")
- drug_code := c.GetString("drug_code")
- //unit := c.GetString("unit")
- dealer, _ := c.GetInt64("dealer")
- prescription_mark, _ := c.GetInt64("prescription_mark")
- social_security_directory_code := c.GetString("social_security_directory_code")
- record_date := c.GetString("record_date")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- drug_remark := c.GetString("drug_remark")
- min_number, _ := c.GetInt64("min_number")
- drug_day := c.GetString("drug_day")
- dose, _ := c.GetFloat("dose")
- dose_unit := c.GetString("dose_unit")
- total, _ := c.GetFloat("total")
-
- min_price, _ := c.GetFloat("min_price")
- hosp_appr_flag, _ := c.GetInt64("hosp_appr_flag")
- lmt_used_flag, _ := c.GetInt64("lmt_used_flag")
- prescribing_number_unit := c.GetString("prescribing_number_unit")
- is_user, _ := c.GetInt64("is_user")
- adminInfo := c.GetAdminUserInfo()
- drug, _ := service.FindBaseDrugLibRecord(adminInfo.CurrentOrgId, id)
- drugLib := &models.BaseDrugLib{
- ID: id,
- DrugName: drug_name,
- Pinyin: pinyin,
- Wubi: wubi,
- DrugAlias: drug_alias,
- DrugAliasPinyin: drug_alias_pinyin,
- DrugAliasWubi: drug_alias_wubi,
- DrugCategory: drug_category,
- DrugSpec: drug_spec,
- DrugType: drug_type,
- DrugStockLimit: drug_stock_limit,
- DrugOriginPlace: drug_origin_place,
- MedicalInsuranceLevel: medical_insurance_level,
- DrugDosageForm: drug_dosage_form,
- MaxUnit: max_unit,
- MinUnit: min_unit,
- UnitMatrixing: unit_matrixing,
- RetailPrice: retail_price,
- LastPrice: last_price,
- DrugControl: drug_control,
- Number: number,
- DrugClassify: drug_classify,
- DrugDose: drug_dose,
- DrugDoseUnit: drug_dose_unit,
- MedicalInsuranceNumber: medical_insurance_number,
- Manufacturer: manufacturer,
- PharmacologyCategory: pharmacology_category,
- StatisticsCategory: statistics_category,
- Code: code,
- IsSpecialDiseases: is_special_diseases,
- IsRecord: is_record,
- Agent: agent,
- DrugStatus: drug_status,
- LimitRemark: limit_remark,
- DeliveryWay: delivery_way,
- ExecutionFrequency: execution_frequency,
- PrescribingNumber: prescribing_number,
- Label: label,
- Sort: sort,
- IsUseDoctorAdvice: is_use_doctor_advice,
- IsDefault: is_default,
- IsChargePredict: is_charge_predict,
- IsStatisticsWork: is_statistics_work,
- IsChargeUse: is_charge_use,
- OrgId: adminInfo.CurrentOrgId,
- Status: 1,
- Ctime: drug.Ctime,
- Mtime: time.Now().Unix(),
- DrugCode: drug_code,
- Dealer: dealer,
- PrescriptionMark: prescription_mark,
- SocialSecurityDirectoryCode: social_security_directory_code,
- RecordDate: theTime.Unix(),
- DrugRemark: drug_remark,
- DrugDay: drug_day,
- HospApprFlag: hosp_appr_flag,
- LmtUsedFlag: lmt_used_flag,
- MinNumber: min_number,
- Dose: dose,
- MinPrice: min_price,
- DoseUnit: dose_unit,
- PrescribingNumberUnit: prescribing_number_unit,
- Total: total,
- SingleDose: drug_dose,
- ProvincesCode: provinces_code,
- IsUse: is_user,
- }
-
- err := service.UpdateBaseDrugLib(drugLib)
-
- //查询是否存在
- _, errOne := service.GetDrugNameIsExist(id, adminInfo.CurrentOrgId)
- if errOne == gorm.ErrRecordNotFound {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "修改成功",
- })
- return
- } else if errOne == nil {
- //修改xt_drug_name 表
- drugName := models.XtDrugName{
- DrugName: drug_name,
- }
- service.UpdatedDrugName(id, adminInfo.CurrentOrgId, &drugName)
- }
-
- //查询是否存在
- _, errTwo := service.GetStandNameIsExist(id, adminInfo.CurrentOrgId)
- if errTwo == gorm.ErrRecordNotFound {
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "修改成功",
- })
- return
- } else if errTwo == nil {
- //修改规格xt_stand_name表
- standName := models.XtStandName{
- DrugName: drug_name,
- DrugSpec: drug_spec,
- DrugStockLimit: drug_stock_limit,
- MinUnit: min_unit,
- }
-
- service.UpdateStandName(id, adminInfo.CurrentOrgId, &standName)
- }
-
- _, errThree := service.GetSelfMedicalIsExist(id, adminInfo.CurrentOrgId)
-
- if errThree == gorm.ErrRecordNotFound {
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "修改成功",
- })
- return
- } else if errThree == nil {
- //修改药品表
- medical := models.XtSelfMedical{
- DrugName: drug_name,
- DrugSpec: drug_spec,
- ExecutionFrequency: execution_frequency,
- PrescribingNumber: prescribing_number,
- DeliveryWay: delivery_way,
- SingleDose: single_dose,
- MinUnit: min_unit,
- }
-
- service.UpdateSelfMedical(id, adminInfo.CurrentOrgId, &medical)
- }
-
- _, errFour := service.GetSelfStosckIsExist(id, adminInfo.CurrentOrgId)
- if errFour == gorm.ErrRecordNotFound {
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "修改成功",
- })
- return
- } else if errFour == nil {
- stock := models.XtSelfStock{
- DrugSpec: drug_spec,
- DrugName: drug_name,
- MinUnit: min_unit,
- }
- service.UpdatedSelfStock(&stock, id, adminInfo.CurrentOrgId)
- }
-
- _, errFive := service.GetOutSelfOutStockIsExist(id, adminInfo.CurrentOrgId)
- if errFive == gorm.ErrRecordNotFound {
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "修改成功",
- })
- return
- } else if errFive == nil {
- outStock := models.XtSelfOutStock{
- DrugName: drug_name,
- DrugSpec: drug_spec,
- }
- //修改出库表
- service.UpdatedOutSelfStock(&outStock, id, adminInfo.CurrentOrgId)
- }
-
- _, errSix := service.GetDoctorAdviceIsExist(id, adminInfo.CurrentOrgId)
- if errSix == gorm.ErrRecordNotFound {
- fmt.Println("进来了吗5")
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "修改成功",
- })
- return
- } else if errSix == nil {
- //查询未执行的医嘱
- advice := models.DoctorAdvice{
- AdviceName: drug_name,
- AdviceDesc: drug_spec,
- DeliveryWay: delivery_way,
- ExecutionFrequency: execution_frequency,
- SingleDose: single_dose,
- SingleDoseUnit: min_unit,
- }
-
- service.UpdateNoExcuteDoctorAdvice(id, adminInfo.CurrentOrgId, &advice)
- }
-
- _, errSeven := service.GetDoctorAdviceTemplateIsExist(id, adminInfo.CurrentOrgId)
-
- if errSeven == gorm.ErrRecordNotFound {
- fmt.Println("进来了吗6")
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "修改成功",
- })
- return
- } else if errSeven == nil {
- //修改医嘱模板
- template := models.DoctorAdviceTemplate{
- AdviceName: drug_name,
- AdviceDesc: drug_spec,
- DeliveryWay: delivery_way,
- ExecutionFrequency: execution_frequency,
- SingleDose: single_dose,
- SingleDoseUnit: min_unit,
- }
- service.UpdatedDoctorAdviceTemplate(id, adminInfo.CurrentOrgId, &template)
-
- }
-
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "修改成功",
- })
- return
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (c *ManagerCenterApiController) GetBaseDrugLib() {
- id, _ := c.GetInt64("id")
- adminInfo := c.GetAdminUserInfo()
- drug, err := service.FindBaseDrugLibRecord(adminInfo.CurrentOrgId, id)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "drug": drug,
- })
- return
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- }
-
- func (c *ManagerCenterApiController) GetBaseDrugLibList() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 10)
- is_use, _ := c.GetInt64("is_use", 0)
- is_charge, _ := c.GetInt64("is_charge", 0)
- is_inject, _ := c.GetInt64("is_inject", 0)
- manufacturer, _ := c.GetInt64("manufacturer")
- is_record, _ := c.GetInt64("is_record")
-
- keyword := c.GetString("keyword")
- adminInfo := c.GetAdminUserInfo()
-
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
- list, total, _ := service.GetBaseDrugLibList(adminInfo.CurrentOrgId, keyword, page, limit, is_use, is_charge, is_inject, manufacturer, is_record)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- })
- return
- }
-
- func (c *ManagerCenterApiController) CreateMedicineInsurancePercent() {
- module, _ := c.GetInt64("module", 0)
- adminInfo := c.GetAdminUserInfo()
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- var mips []*models.MedicineInsurancePercentage
- var errs error
- record_time := time.Now().Unix()
-
- if dataBody["mip"] != nil && reflect.TypeOf(dataBody["mip"]).String() == "[]interface {}" {
- mip_map, _ := dataBody["mip"].([]interface{})
- if len(mip_map) > 0 {
- for _, item := range mip_map {
- items := item.(map[string]interface{})
-
- if items["type_id"] == nil || reflect.TypeOf(items["type_id"]).String() != "float64" {
- utils.ErrorLog("type_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- type_id := int64(items["type_id"].(float64))
-
- if items["medicine_insurance_type"] == nil || reflect.TypeOf(items["medicine_insurance_type"]).String() != "float64" {
- utils.ErrorLog("medicine_insurance_type")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- types := int64(items["medicine_insurance_type"].(float64))
-
- if items["percent"] == nil || reflect.TypeOf(items["percent"]).String() != "string" {
- utils.ErrorLog("percent")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- percent, _ := strconv.ParseFloat(items["percent"].(string), 64)
- //percent := items["percent"].(float64)
- mip_temp := &models.MedicineInsurancePercentage{
- TypeId: type_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- RecordTime: record_time,
- MedicineInsuranceType: types,
- UserOrgId: adminInfo.CurrentOrgId,
- Percent: percent,
- Module: module,
- GoodId: 0,
- }
- mips = append(mips, mip_temp)
-
- }
- }
-
- for _, item := range mips {
- errs = service.CreateMedicineInsurancePercentage(item)
- }
- }
-
- if errs == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "添加成功",
- })
- return
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- }
-
- func (c *ManagerCenterApiController) CreateDrugUnitSafeguard() {
-
- }
-
- //GetPatientsList 取配置信息列表
- func (c *ManagerCenterApiController) GetConfigList() {
- adminUserInfo := c.GetAdminUserInfo()
- configList, _ := service.GetDictionaryConfigList(adminUserInfo.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "configlist": configList,
- })
- return
-
- }
-
- //CreateConfig 创建配置信息
- func (c *ManagerCenterApiController) CreateConfig() {
- adminUserInfo := c.GetAdminUserInfo()
-
- var dataconfig models.DictionaryDataconfig
- var resultConfig models.DictionaryConfigViewModel
- code := dictionaryConfigFormData(&dataconfig, c.Ctx.Input.RequestBody)
- if code > 0 {
- c.ServeFailJSONWithSGJErrorCode(code)
- return
- }
- // 验证关键字段的值是否重复
-
- thisConfig, _ := service.FindDictionaryConfigByTitle(dataconfig.Module, dataconfig.FieldName, adminUserInfo.CurrentOrgId)
- if thisConfig.ID > 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFieldExist)
- return
- }
-
- fieldValue := service.GetDictionaryChildValue(dataconfig.Module, dataconfig.ParentId, adminUserInfo.CurrentOrgId)
- dataconfig.Value = fieldValue + 1
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- dataconfig.OrgId = adminUserInfo.CurrentOrgId
- dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
- dataconfig.Status = 1
- dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
- dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
- dataconfig.Remark = string(dataBody["remark"].(string))
- if dataBody["order"] != nil {
- dataconfig.Order = int64(dataBody["order"].(float64))
- } else {
- dataconfig.Order = 0
- }
- err = service.CreateDictionaryConfig(&dataconfig)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- } else {
- resultConfig.ID = dataconfig.ID
- resultConfig.Module = dataconfig.Module
- resultConfig.Name = dataconfig.Name
- resultConfig.OrgId = dataconfig.OrgId
- resultConfig.ParentId = dataconfig.ParentId
- resultConfig.FieldName = dataconfig.FieldName
- resultConfig.CreateUserId = dataconfig.CreateUserId
- resultConfig.Title = dataconfig.Title
- resultConfig.Content = dataconfig.Content
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "dataconfig": resultConfig,
- "msg": "ok",
- })
- return
- }
-
- func (c *ManagerCenterApiController) UpdateTemplate() {
- adminUserInfo := c.GetAdminUserInfo()
- var dataconfig models.DictionaryDataconfig
- code := dictionaryConfigFormData(&dataconfig, c.Ctx.Input.RequestBody)
- if code > 0 {
- c.ServeFailJSONWithSGJErrorCode(code)
- return
- }
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- dataconfig.OrgId = adminUserInfo.CurrentOrgId
- dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
- dataconfig.Status = 1
- dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
- dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
- dataconfig.Remark = string(dataBody["remark"].(string))
- if dataBody["order"] != nil {
- dataconfig.Order = int64(dataBody["order"].(float64))
- } else {
- dataconfig.Order = 0
- }
-
- // 验证关键字段的值是否重复
- // cur_id := int64(dataBody["id"].(float64))
- // thisConfig,_:=service.FindConfigByTitleForUpdate(dataconfig.Module, dataconfig.Title,dataconfig.OrgId,cur_id)
- // if thisConfig.ID >0 {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFieldExist)
- // return
- // }
-
- configOrgId := int64(dataBody["org_id"].(float64))
- if configOrgId == 0 {
- dataconfig.DeleteIdSystem = int64(dataBody["id"].(float64))
- err := service.CreateDictionaryConfig(&dataconfig)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
- } else {
- dataconfig.ID = int64(dataBody["id"].(float64))
- err = service.UpdateDictionaryTemplate(&dataconfig)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "dataconfig": dataconfig,
- "msg": "ok",
- })
- return
- }
- func (c *ManagerCenterApiController) UpdateChildConfig() {
- adminUserInfo := c.GetAdminUserInfo()
- var dataconfig models.DictionaryDataconfig
- code := dictionaryConfigChildFormData(&dataconfig, c.Ctx.Input.RequestBody)
- if code > 0 {
- c.ServeFailJSONWithSGJErrorCode(code)
- return
- }
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- dataconfig.OrgId = adminUserInfo.CurrentOrgId
- dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
- dataconfig.Status = 1
- dataconfig.Value = int(int64(dataBody["value"].(float64)))
- dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
- dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
- dataconfig.Remark = string(dataBody["remark"].(string))
- dataconfig.Order = int64(dataBody["orders"].(float64))
- dataconfig.Code = string(dataBody["code"].(string))
- fmt.Println("dataconfitg------", dataconfig.Order)
- //if dataBody["orders"] != nil {
- // dataconfig.Order = int64(dataBody["orders"].(float64))
- // fmt.Println("dataconfig",dataconfig.Order)
- //} else {
- // dataconfig.Order = 0
- //}
- configOrgId := int64(dataBody["org_id"].(float64))
- // 验证关键字段的值是否重复
- // configId := int64(dataBody["id"].(float64))
- // thisConfig,_:=service.FindConfigByNameForUpdate(dataconfig.Module, dataconfig.Name,dataconfig.ParentId,dataconfig.OrgId,configId)
- // if thisConfig.ID >0 {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFieldExist)
- // return
- // }
-
- if configOrgId == 0 {
- dataconfig.DeleteIdSystem = int64(dataBody["id"].(float64))
- err := service.CreateDictionaryConfig(&dataconfig)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
- } else {
- dataconfig.ID = int64(dataBody["id"].(float64))
- err = service.UpdateDictionaryChildConfig(&dataconfig)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "dataconfig": dataconfig,
- "msg": "ok",
- })
- return
- }
- func (c *ManagerCenterApiController) DeleteChildConfig() {
- adminUserInfo := c.GetAdminUserInfo()
- var dataconfig models.DictionaryDataconfig
- code := dictionaryConfigChildFormData(&dataconfig, c.Ctx.Input.RequestBody)
- if code > 0 {
- c.ServeFailJSONWithSGJErrorCode(code)
- return
- }
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- dataconfig.OrgId = adminUserInfo.CurrentOrgId
- dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
- dataconfig.Status = 0
- dataconfig.Value = int(int64(dataBody["value"].(float64)))
- dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
- dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
- dataconfig.Remark = string(dataBody["remark"].(string))
- if dataBody["order"] != nil {
- dataconfig.Order = int64(dataBody["order"].(float64))
- } else {
- dataconfig.Order = 0
- }
- configOrgId := int64(dataBody["org_id"].(float64))
-
- if configOrgId == 0 {
- dataconfig.DeleteIdSystem = int64(dataBody["id"].(float64))
- err := service.CreateDictionaryConfig(&dataconfig)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
- } else {
- dataconfig.ID = int64(dataBody["id"].(float64))
- err := service.DeleteDictionaryChildConfig(&dataconfig)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "dataconfig": dataconfig,
- "msg": "ok",
- })
- return
- }
-
- //CreateChildConfig 创建子配置信息
- func (c *ManagerCenterApiController) CreateChildConfig() {
- adminUserInfo := c.GetAdminUserInfo()
-
- var dataconfig models.DictionaryDataconfig
- code := dictionaryConfigChildFormData(&dataconfig, c.Ctx.Input.RequestBody)
- if code > 0 {
- c.ServeFailJSONWithSGJErrorCode(code)
- return
- }
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- dataconfig.OrgId = adminUserInfo.CurrentOrgId
- dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
- dataconfig.Status = 1
- dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
- dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
- dataconfig.Remark = string(dataBody["remark"].(string))
- dataconfig.Code = string(dataBody["code"].(string))
- fmt.Println("3444444444", dataconfig.Code)
- if dataBody["order"] != nil {
- dataconfig.Order = int64(dataBody["order"].(float64))
- } else {
- dataconfig.Order = 0
- }
-
- // 验证关键字段的值是否重复
- // thisConfig,_:=service.FindConfigByName(dataconfig.Module, dataconfig.Name,dataconfig.ParentId,dataconfig.OrgId)
- // if thisConfig.ID >0 {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFieldExist)
- // return
- // }
-
- fieldValue := service.GetDictionaryChildValue(dataconfig.Module, dataconfig.ParentId, dataconfig.OrgId)
- dataconfig.Value = fieldValue + 1
-
- err = service.CreateDictionaryConfig(&dataconfig)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "dataconfig": dataconfig,
- "msg": "ok",
- })
- return
- }
-
- func dictionaryConfigFormData(dataconfig *models.DictionaryDataconfig, data []byte) (code int) {
- configBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(data, &configBody)
- utils.InfoLog(string(data))
- if err != nil {
- utils.ErrorLog(err.Error())
- code = enums.ErrorCodeParamWrong
- return
- }
- if configBody["module"] == nil || reflect.TypeOf(configBody["module"]).String() != "string" {
- utils.ErrorLog("module")
- code = enums.ErrorCodeParamWrong
- return
- }
- module, _ := configBody["module"].(string)
- if len(module) == 0 {
- utils.ErrorLog("len(module) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- dataconfig.Module = module
-
- if module == "education" || module == "summary" || module == "course_disease" || module == "rescue_record" || module == "nursing_record" || module == "special_record" {
- if configBody["title"] == nil || reflect.TypeOf(configBody["title"]).String() != "string" {
- utils.ErrorLog("title")
- code = enums.ErrorCodeParamWrong
- return
- }
- title, _ := configBody["title"].(string)
- if len(title) == 0 {
- utils.ErrorLog("len(title) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- dataconfig.Title = title
-
- if configBody["content"] == nil || reflect.TypeOf(configBody["content"]).String() != "string" {
- utils.ErrorLog("content")
- code = enums.ErrorCodeParamWrong
- return
- }
- content, _ := configBody["content"].(string)
- if len(content) == 0 {
- utils.ErrorLog("len(content) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- dataconfig.Content = content
- } else {
- if configBody["name"] == nil || reflect.TypeOf(configBody["name"]).String() != "string" {
- utils.ErrorLog("name")
- code = enums.ErrorCodeParamWrong
- return
- }
- name, _ := configBody["name"].(string)
- if len(name) == 0 {
- utils.ErrorLog("len(name) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- dataconfig.Name = name
-
- if configBody["field_name"] == nil || reflect.TypeOf(configBody["field_name"]).String() != "string" {
- utils.ErrorLog("field_name")
- code = enums.ErrorCodeParamWrong
- return
- }
- field_name, _ := configBody["field_name"].(string)
- if len(field_name) == 0 {
- utils.ErrorLog("len(field_name) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- dataconfig.FieldName = field_name
- }
- return
- }
-
- func dictionaryConfigChildFormData(dataconfig *models.DictionaryDataconfig, data []byte) (code int) {
- configBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(data, &configBody)
- utils.InfoLog(string(data))
- if err != nil {
- utils.ErrorLog(err.Error())
- code = enums.ErrorCodeParamWrong
- return
- }
-
- if configBody["module"] == nil || reflect.TypeOf(configBody["module"]).String() != "string" {
- utils.ErrorLog("module")
- code = enums.ErrorCodeParamWrong
- return
- }
- module, _ := configBody["module"].(string)
- if len(module) == 0 {
- utils.ErrorLog("len(module) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- dataconfig.Module = module
-
- if module == "education" || module == "summary" {
- if configBody["title"] == nil || reflect.TypeOf(configBody["title"]).String() != "string" {
- utils.ErrorLog("title")
- code = enums.ErrorCodeParamWrong
- return
- }
- title, _ := configBody["title"].(string)
- if len(title) == 0 {
- utils.ErrorLog("len(title) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- dataconfig.Title = title
-
- if configBody["content"] == nil || reflect.TypeOf(configBody["content"]).String() != "string" {
- utils.ErrorLog("content")
- code = enums.ErrorCodeParamWrong
- return
- }
- content, _ := configBody["content"].(string)
- if len(content) == 0 {
- utils.ErrorLog("len(content) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- dataconfig.Content = content
-
- } else {
- if configBody["parent_id"] == nil || reflect.TypeOf(configBody["parent_id"]).String() != "float64" {
- utils.ErrorLog("module")
- code = enums.ErrorCodeParamWrong
- return
- }
- parent_id := int64(configBody["parent_id"].(float64))
- if parent_id <= 0 {
- utils.ErrorLog("parent_id <= 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- dataconfig.ParentId = parent_id
-
- if configBody["name"] == nil || reflect.TypeOf(configBody["name"]).String() != "string" {
- utils.ErrorLog("name")
- code = enums.ErrorCodeParamWrong
- return
- }
- name, _ := configBody["name"].(string)
- if len(name) == 0 {
- utils.ErrorLog("len(name) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- dataconfig.Name = name
-
- }
- return
- }
-
- func (c *ManagerCenterApiController) CreateDealer() {
- dealer_name := c.GetString("dealer_name")
- contact := c.GetString("contact")
- contact_phone := c.GetString("contact_phone")
- platform_number := c.GetString("platform_number")
- email := c.GetString("email")
- contact_address := c.GetString("contact_address")
- remark := c.GetString("remark")
- pinyin := c.GetString("pinyin")
- wubi := c.GetString("wubi")
-
- if len(dealer_name) <= 0 {
- utils.ErrorLog("len(dealer_name) == 0")
-
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetAdminUserInfo()
-
- total := service.FindAllDealerTotal(adminUserInfo.CurrentOrgId)
- totalStr := strconv.FormatInt(total+1, 10)
- code := "1000" + totalStr
- dealer := models.Dealer{
- DealerName: dealer_name,
- Contact: contact,
- ContactPhone: contact_phone,
- ContactAddress: contact_address,
- DealerCode: code,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Remark: remark,
- Creater: adminUserInfo.AdminUser.Id,
- Email: email,
- PlatformNumber: platform_number,
- OrgId: adminUserInfo.CurrentOrgId,
- Status: 1,
- PinYin: pinyin,
- WuBi: wubi,
- }
-
- err, dealers := service.AddSigleDealer(&dealer)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "dealer": dealers,
- })
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
-
- }
-
- }
- func (c *ManagerCenterApiController) ModifyDealer() {
- id, _ := c.GetInt64("id", 0)
- dealer_name := c.GetString("dealer_name")
- contact := c.GetString("contact")
- contact_phone := c.GetString("contact_phone")
- platform_number := c.GetString("platform_number")
- dealer_code := c.GetString("dealer_code")
- email := c.GetString("email")
- contact_address := c.GetString("contact_address")
- remark := c.GetString("remark")
- pinyin := c.GetString("pinyin")
- wubi := c.GetString("wubi")
-
- if id <= 0 {
- utils.ErrorLog("id == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if len(dealer_name) <= 0 {
- utils.ErrorLog("len(dealer_name) == 0")
-
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetAdminUserInfo()
- dealer := models.Dealer{
- ID: id,
- DealerName: dealer_name,
- Contact: contact,
- ContactPhone: contact_phone,
- ContactAddress: contact_address,
- Mtime: time.Now().Unix(),
- DealerCode: dealer_code,
- Remark: remark,
- Creater: adminUserInfo.AdminUser.Id,
- Email: email,
- PlatformNumber: platform_number,
- Modifier: adminUserInfo.AdminUser.Id,
- OrgId: adminUserInfo.CurrentOrgId,
- Status: 1,
- PinYin: pinyin,
- WuBi: wubi,
- }
-
- err := service.ModifyDealer(&dealer)
-
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "dealer": dealer,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
- func (c *ManagerCenterApiController) GetDealersList() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 7)
- key, _ := c.GetInt64("key", 0)
- adminUserInfo := c.GetAdminUserInfo()
- deales, total, err := service.FindAllDealerList(adminUserInfo.CurrentOrgId, page, limit, key)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "dealer": deales,
- "total": total,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
- func (c *ManagerCenterApiController) DeleteDealer() {
- id, _ := c.GetInt64("id", 0)
- total, _ := service.FindStockInByDealerId(id)
- if total > 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteDealerWrong)
- return
- }
- err := service.DeleteDealerById(id)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "删除成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
- func (c *ManagerCenterApiController) GetDealer() {
- id, _ := c.GetInt64("id", 0)
- dealer, err := service.FindDealerById(id)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "dealer": dealer,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
- func (c *ManagerCenterApiController) CreateManufacturer() {
- manufacturer_name := c.GetString("manufacturer_name")
- contact := c.GetString("contact")
- contact_phone := c.GetString("contact_phone")
- platform_number := c.GetString("platform_number")
- email := c.GetString("email")
- contact_address := c.GetString("contact_address")
- remark := c.GetString("remark")
- pinyin := c.GetString("pinyin")
- wubi := c.GetString("wubi")
-
- if len(manufacturer_name) <= 0 {
- utils.ErrorLog("len(manufacturer_name) == 0")
-
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetAdminUserInfo()
- total := service.FindManufacturerTotal(adminUserInfo.CurrentOrgId)
- totalStr := strconv.FormatInt(total+1, 10)
- code := "2000" + totalStr
- manufacturer := models.Manufacturer{
- ManufacturerName: manufacturer_name,
- Contact: contact,
- ContactPhone: contact_phone,
- ContactAddress: contact_address,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Remark: remark,
- Creater: adminUserInfo.AdminUser.Id,
- Email: email,
- PlatformNumber: platform_number,
- OrgId: adminUserInfo.CurrentOrgId,
- Status: 1,
- ManufacturerCode: code,
- PinYin: pinyin,
- WuBi: wubi,
- }
-
- err, manufacturers := service.AddSigleManufacturer(&manufacturer)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "manufacturer": manufacturers,
- })
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
-
- }
- func (c *ManagerCenterApiController) ModifyManufacturer() {
-
- id, _ := c.GetInt64("id", 0)
- manufacturer_name := c.GetString("manufacturer_name")
- contact := c.GetString("contact")
- contact_phone := c.GetString("contact_phone")
- platform_number := c.GetString("platform_number")
- email := c.GetString("email")
- contact_address := c.GetString("contact_address")
- remark := c.GetString("remark")
- manufacturer_code := c.GetString("manufacturer_code")
- pinyin := c.GetString("pinyin")
- wubi := c.GetString("wubi")
- if id <= 0 {
- utils.ErrorLog("id == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if len(manufacturer_name) <= 0 {
- utils.ErrorLog("len(manufacturer_name) == 0")
-
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetAdminUserInfo()
- manufacturer := models.Manufacturer{
- ID: id,
- ManufacturerName: manufacturer_name,
- Contact: contact,
- ContactPhone: contact_phone,
- ContactAddress: contact_address,
- Mtime: time.Now().Unix(),
- Remark: remark,
- Creater: adminUserInfo.AdminUser.Id,
- Email: email,
- PlatformNumber: platform_number,
- Modifier: adminUserInfo.AdminUser.Id,
- OrgId: adminUserInfo.CurrentOrgId,
- ManufacturerCode: manufacturer_code,
- Status: 1,
- PinYin: pinyin,
- WuBi: wubi,
- }
-
- err := service.ModifyManufacturer(&manufacturer)
-
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "manufacturer": manufacturer,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
-
- }
- func (c *ManagerCenterApiController) GetManufacturerList() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 10)
- key, _ := c.GetInt64("key", 0)
- adminUserInfo := c.GetAdminUserInfo()
- manufacturer, total, err := service.FindAllManufacturerList(adminUserInfo.CurrentOrgId, page, limit, key)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "manufacturer": manufacturer,
- "total": total,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
- func (c *ManagerCenterApiController) DeleteManufacturer() {
- id, _ := c.GetInt64("id", 0)
- total, _ := service.FindStockInByManufacturerId(id)
- if total > 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteManufacturerWrong)
- return
- }
-
- err := service.DeleteManufacturerById(id)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "删除成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
- func (c *ManagerCenterApiController) GetManufacturer() {
- id, _ := c.GetInt64("id", 0)
- manufacturer, err := service.FindManufacturerById(id)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "manufacturer": manufacturer,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
-
- }
- func (c *ManagerCenterApiController) GetAllDealer() {
- adminUserInfo := c.GetAdminUserInfo()
- dealer, err := service.FindAllDealer(adminUserInfo.CurrentOrgId)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "dealer": dealer,
- })
- } else {
-
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
- func (c *ManagerCenterApiController) GetAllManufacturer() {
- adminUserInfo := c.GetAdminUserInfo()
- manufacturer, err := service.FindAllManufacturer(adminUserInfo.CurrentOrgId)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "manufacturer": manufacturer,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
-
- }
-
- func (c *ManagerCenterApiController) CreateGoodInfo() {
- good_id, _ := c.GetInt64("good_id", 0)
- specification_name := c.GetString("specification_name")
- register_number := c.GetString("register_number")
-
- good_unit, _ := c.GetInt64("good_unit", -1)
- buy_price, _ := c.GetFloat("buy_price", 0)
- sell_price, _ := c.GetFloat("sell_price", 0)
- remark := c.GetString("remark")
- manufacturer, _ := c.GetInt64("manufacturer", 0)
- dealer, _ := c.GetInt64("dealer", 0)
- expiry_date_warn_day_count, _ := c.GetInt64("expiry_date_warn_day_count", 0)
- stock_warn_count, _ := c.GetInt64("stock_warn_count", 0)
- is_reuse, _ := c.GetInt64("is_reuse", 0)
-
- good_name := c.GetString("good_name")
- pinyin := c.GetString("pinyin")
- wubi := c.GetString("wubi")
- good_kind, _ := c.GetInt64("good_kind", 0)
- medical_insurance_level, _ := c.GetInt64("medical_insurance_level", 0)
- retail_price, _ := c.GetFloat("retail_price", 0)
- fmt.Println(retail_price)
- medical_insurance_number := c.GetString("medical_insurance_number")
- provinces_code := c.GetString("provinces_code")
-
- is_special_diseases, _ := c.GetInt64("is_special_diseases", 0)
- is_record, _ := c.GetInt64("is_record")
- statistics_category, _ := c.GetInt64("statistics_category")
- good_status := c.GetString("good_status")
-
- default_count, _ := c.GetInt64("default_count")
- sign, _ := c.GetInt64("sign")
- is_default, _ := c.GetInt64("is_default")
- is_charge_use, _ := c.GetInt64("is_charge_use")
- is_charge_predict, _ := c.GetInt64("is_charge_predict")
- is_statistics_work, _ := c.GetInt64("is_statistics_work")
- sort, _ := c.GetInt64("sort")
- is_doctor_use, _ := c.GetInt64("is_doctor_use")
- agent := c.GetString("agent")
- good_number := c.GetString("good_number")
-
- social_security_directory_code := c.GetString("social_security_directory_code")
- production_type := c.GetString("production_type")
- special_medical := c.GetString("special_medical")
- min_number, _ := c.GetInt64("min_number")
- packing_unit := c.GetString("packing_unit")
- packing_price, _ := c.GetFloat("packing_price")
- min_unit := c.GetString("min_unit")
- default_count_unit := c.GetString("default_count_unit")
- is_user, _ := c.GetInt64("is_user")
- number := c.GetString("number")
- is_warehouse, _ := c.GetInt64("is_warehouse")
- adminUserInfo := c.GetAdminUserInfo()
-
- totals := service.FindGoodInfoByNameTwo(specification_name, adminUserInfo.CurrentOrgId, good_id, good_name)
- if totals > 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodInfoNameExistError)
- return
- }
-
- total := service.FindAllGoodInfoTotal(adminUserInfo.CurrentOrgId)
- code := strconv.FormatInt(total+1, 10)
- code = "24000000" + code
-
- goodInfo := models.GoodInfo{
- GoodCode: code,
- SpecificationName: specification_name,
- GoodTypeId: good_id,
- GoodUnit: good_unit,
- BuyPrice: buy_price,
- SellPrice: sell_price,
- Remark: remark,
- Ctime: time.Now().Unix(),
- Manufacturer: manufacturer,
- Dealer: dealer,
- ExpiryDateWarnDayCount: expiry_date_warn_day_count,
- StockWarnCount: stock_warn_count,
- IsReuse: is_reuse,
- Status: 1,
- OrgId: adminUserInfo.CurrentOrgId,
- Creater: adminUserInfo.AdminUser.Id,
- GoodName: good_name,
- Pinyin: pinyin,
- Wubi: wubi,
- GoodKind: good_kind,
- MedicalInsuranceNumber: medical_insurance_number,
- IsSpecialDiseases: is_special_diseases,
- IsRecord: is_record,
- StatisticsCategory: statistics_category,
- GoodStatus: good_status,
- DefaultCount: default_count,
- Sign: sign,
- IsDefault: is_default,
- IsChargeUse: is_charge_use,
- IsChargePredict: is_charge_predict,
- IsStatisticsWork: is_statistics_work,
- Sort: sort,
- IsDoctorUse: is_doctor_use,
- Agent: agent,
- GoodNumber: good_number,
- MedicalInsuranceLevel: medical_insurance_level,
- RetailPrice: packing_price,
- SocialSecurityDirectoryCode: social_security_directory_code,
- ProductionType: production_type,
- SpecialMedical: special_medical,
- MinNumber: min_number,
- PackingUnit: packing_unit,
- PackingPrice: packing_price,
- DefaultCountUnit: default_count_unit,
- MinUnit: min_unit,
- RegisterNumber: register_number,
- ProvincesCode: provinces_code,
- IsUser: is_user,
- Number: number,
- IsWarehouse: is_warehouse,
- }
- err, goodInfos := service.AddSigleGoodInfo(&goodInfo)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "goodInfo": goodInfos,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
-
- }
-
- func (c *ManagerCenterApiController) ModifyGoodInfo() {
- id, _ := c.GetInt64("id", 0)
- good_id, _ := c.GetInt64("good_id", 0)
- specification_name := c.GetString("specification_name")
- good_unit, _ := c.GetInt64("good_unit", -1)
- buy_price, _ := c.GetFloat("buy_price", 0)
- sell_price, _ := c.GetFloat("sell_price", 0)
- remark := c.GetString("remark")
- manufacturer, _ := c.GetInt64("manufacturer", 0)
- dealer, _ := c.GetInt64("dealer", 0)
- expiry_date_warn_day_count, _ := c.GetInt64("expiry_date_warn_day_count", 0)
- stock_warn_count, _ := c.GetInt64("stock_warn_count", 0)
- is_reuse, _ := c.GetInt64("is_reuse", 0)
- code := c.GetString("good_code")
- provinces_code := c.GetString("provinces_code")
-
- good_name := c.GetString("good_name")
- pinyin := c.GetString("pinyin")
- wubi := c.GetString("wubi")
- good_kind, _ := c.GetInt64("good_kind", 0)
- medical_insurance_level, _ := c.GetInt64("medical_insurance_level", 0)
- retail_price, _ := c.GetFloat("retail_price", 0)
- fmt.Println(retail_price)
- medical_insurance_number := c.GetString("medical_insurance_number")
- //provinces_code := c.GetString("provinces_code")
-
- is_special_diseases, _ := c.GetInt64("is_special_diseases", 0)
- is_record, _ := c.GetInt64("is_record")
- statistics_category, _ := c.GetInt64("statistics_category")
- good_status := c.GetString("good_status")
-
- default_count, _ := c.GetInt64("default_count")
- sign, _ := c.GetInt64("sign")
- is_default, _ := c.GetInt64("is_default")
- is_charge_use, _ := c.GetInt64("is_charge_use")
- is_charge_predict, _ := c.GetInt64("is_charge_predict")
- is_statistics_work, _ := c.GetInt64("is_statistics_work")
- sort, _ := c.GetInt64("sort")
- is_doctor_use, _ := c.GetInt64("is_doctor_use")
- agent := c.GetString("agent")
- good_number := c.GetString("good_number")
-
- social_security_directory_code := c.GetString("social_security_directory_code")
- production_type := c.GetString("production_type")
- special_medical := c.GetString("special_medical")
-
- min_number, _ := c.GetInt64("min_number")
- packing_unit := c.GetString("packing_unit")
- packing_price, _ := c.GetFloat("packing_price")
- default_count_unit := c.GetString("default_count_unit")
- min_unit := c.GetString("min_unit")
- total, _ := c.GetFloat("total")
- register_number := c.GetString("register_number")
- is_user, _ := c.GetInt64("is_user")
- number := c.GetString("number")
- is_warehouse, _ := c.GetInt64("is_warehouse")
- adminUserInfo := c.GetAdminUserInfo()
-
- goodInfo := models.GoodInfo{
- ID: id,
- GoodCode: code,
- SpecificationName: specification_name,
- GoodTypeId: good_id,
- GoodUnit: good_unit,
- BuyPrice: buy_price,
- SellPrice: sell_price,
- Remark: remark,
- Mtime: time.Now().Unix(),
- Manufacturer: manufacturer,
- Dealer: dealer,
- ExpiryDateWarnDayCount: expiry_date_warn_day_count,
- StockWarnCount: stock_warn_count,
- IsReuse: is_reuse,
- Status: 1,
- OrgId: adminUserInfo.CurrentOrgId,
- Modifier: adminUserInfo.AdminUser.Id,
- GoodName: good_name,
- Pinyin: pinyin,
- Wubi: wubi,
- GoodKind: good_kind,
- MedicalInsuranceNumber: medical_insurance_number,
- ProvincesCode: provinces_code,
- IsSpecialDiseases: is_special_diseases,
- IsRecord: is_record,
- StatisticsCategory: statistics_category,
- GoodStatus: good_status,
- DefaultCount: default_count,
- Sign: sign,
- IsDefault: is_default,
- IsChargeUse: is_charge_use,
- IsChargePredict: is_charge_predict,
- IsStatisticsWork: is_statistics_work,
- Sort: sort,
- IsDoctorUse: is_doctor_use,
- Agent: agent,
- GoodNumber: good_number,
- MedicalInsuranceLevel: medical_insurance_level,
- RetailPrice: packing_price,
- SpecialMedical: special_medical,
- SocialSecurityDirectoryCode: social_security_directory_code,
- ProductionType: production_type,
- MinNumber: min_number,
- PackingUnit: packing_unit,
- PackingPrice: packing_price,
- DefaultCountUnit: default_count_unit,
- MinUnit: min_unit,
- Total: total,
- RegisterNumber: register_number,
- IsUser: is_user,
- Number: number,
- IsWarehouse: is_warehouse,
- }
-
- totals := service.FindGoodInfoByNameOne(specification_name, adminUserInfo.CurrentOrgId, good_id, id, good_name)
- if totals > 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodInfoNameExistError)
- return
- }
- err, goodInfos := service.ModifyGoodInfo(&goodInfo)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "goodInfo": goodInfos,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
-
- }
- func (c *ManagerCenterApiController) GetGoodInfoList() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 7)
- keyword := c.GetString("keyword")
- is_use, _ := c.GetInt64("is_use")
- is_charge, _ := c.GetInt64("is_charge")
- good_kind, _ := c.GetInt64("good_kind")
- is_mark, _ := c.GetInt64("is_mark")
- manufacturer, _ := c.GetInt64("manufacturer")
- is_type, _ := c.GetInt64("is_type")
- adminUserInfo := c.GetAdminUserInfo()
- goodInfos, total, err := service.FindGoodInfoList(adminUserInfo.CurrentOrgId, page, limit, keyword, is_use, is_charge, good_kind, is_mark, manufacturer, is_type)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "list": goodInfos,
- "total": total,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
-
- }
- func (c *ManagerCenterApiController) DeleteGoodInfo() {
- id, _ := c.GetInt64("id", 0)
- adminUserInfo := c.GetAdminUserInfo()
-
- total, _ := service.FindWarehouseInfoTotalByGoodId(id)
- total2, _ := service.FindWarehouseOutInfoTotalByGoodId(id)
-
- if total > 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteGoodInfoFail)
- return
- }
- if total2 > 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteGoodInfoFail)
- return
- }
-
- err := service.DeleteGoodInfoById(id, adminUserInfo.AdminUser.Id)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "删除成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
-
- }
-
- func (c *ManagerCenterApiController) GetGoodInfoByGoodId() {
- id, _ := c.GetInt64("id", 0)
- goodInfo, err := service.FindGoodInfoByGoodId(id)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "list": goodInfo,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
-
- func (c *ManagerCenterApiController) GetGoodInfoById() {
- id, _ := c.GetInt64("id", 0)
- goodInfo, err := service.FindGoodInfoById(id)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "goodInfo": goodInfo,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
-
- func (c *ManagerCenterApiController) GetMedicineInsurancePercent() {
- adminUser := c.GetAdminUserInfo()
- type_id, _ := c.GetInt64("type_id", 0)
- module, _ := c.GetInt64("module", 0)
-
- mip, err := service.GetLastMedicineInsurance(adminUser.CurrentOrgId, type_id, module)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "mip": mip,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
-
- func (c *ManagerCenterApiController) CreateMZSick() {
- class_name := c.GetString("class_name")
- content_code := c.GetString("content_code")
- country_code := c.GetString("country_code")
- country_content_name := c.GetString("country_content_name")
- remark := c.GetString("remark")
- pinyin := c.GetString("pinyin")
- wubi := c.GetString("wubi")
-
- if len(class_name) <= 0 {
- utils.ErrorLog("len(class_name) == 0")
-
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if len(content_code) <= 0 {
- utils.ErrorLog("len(content_code) == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetAdminUserInfo()
-
- dealer := models.OutpatientServiceSick{
- ClassName: class_name,
- ContentCode: content_code,
- CountryCode: country_code,
- CountryContentName: country_content_name,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Remark: remark,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Status: 1,
- Pinyin: pinyin,
- Wubi: wubi,
- }
-
- err, dealers := service.AddSigleMZSick(&dealer)
- if err == nil {
-
- redis := service.RedisClient()
- defer redis.Close()
- sick_keys := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + "_sick"
- redis.Set(sick_keys, "", time.Second*60*60*18)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "sick": dealers,
- })
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
-
- }
-
- }
- func (c *ManagerCenterApiController) ModifyMZSick() {
- id, _ := c.GetInt64("id", 0)
-
- class_name := c.GetString("class_name")
- content_code := c.GetString("content_code")
- country_code := c.GetString("country_code")
- country_content_name := c.GetString("country_content_name")
- remark := c.GetString("remark")
- pinyin := c.GetString("pinyin")
- wubi := c.GetString("wubi")
-
- if id <= 0 {
- utils.ErrorLog("id == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if len(class_name) <= 0 {
- utils.ErrorLog("len(class_name) == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if len(content_code) <= 0 {
- utils.ErrorLog("len(content_code) == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetAdminUserInfo()
- dealer := models.OutpatientServiceSick{
- ID: id,
- ClassName: class_name,
- ContentCode: content_code,
- CountryCode: country_code,
- CountryContentName: country_content_name,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Remark: remark,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Pinyin: pinyin,
- Wubi: wubi,
- Status: 1,
- }
-
- err := service.ModifyMZSick(&dealer)
-
- if err == nil {
-
- redis := service.RedisClient()
- defer redis.Close()
- sick_keys := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + "_sick"
- redis.Set(sick_keys, "", time.Second*60*60*18)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "sick": dealer,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
- func (c *ManagerCenterApiController) GetMZSickList() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 7)
- adminUserInfo := c.GetAdminUserInfo()
- mzSick, total, err := service.FindAllMZSickList(adminUserInfo.CurrentOrgId, page, limit)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "sick": mzSick,
- "total": total,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
- func (c *ManagerCenterApiController) DeleteMZSick() {
- id, _ := c.GetInt64("id", 0)
- err := service.DeleteMZSickById(id)
- if err == nil {
-
- redis := service.RedisClient()
- defer redis.Close()
- sick_keys := strconv.FormatInt(c.GetAdminUserInfo().CurrentOrgId, 10) + "_sick"
- redis.Set(sick_keys, "", time.Second*60*60*18)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "删除成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
- func (c *ManagerCenterApiController) GetMZSick() {
- id, _ := c.GetInt64("id", 0)
- mzSick, err := service.FindMZSickById(id)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "sick": mzSick,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
-
- func (c *ManagerCenterApiController) DeleteBaseDrugById() {
-
- id, _ := c.GetInt64("id")
- //查询入库单
- _, errcode := service.GetDrugWareoutInfo(id)
- if errcode == gorm.ErrRecordNotFound {
- //查询出库单
- _, errcodes := service.GetDrugWareOutById(id)
- if errcodes == gorm.ErrRecordNotFound {
- //删除
- service.DeleteBaseDrugById(id)
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- c.ServeSuccessJSON(returnData)
- return
- } else if errcodes == nil {
- c.ServeFailJsonSend(enums.ErrorCodeDataException, "已出库")
- return
- }
- } else if errcode == nil {
- c.ServeFailJsonSend(enums.ErrorCodeDataException, "已入库")
- return
- }
- }
-
- func (c *ManagerCenterApiController) CreateAddition() {
- name := c.GetString("name")
- code := c.GetString("code")
- //price, _ := c.GetFloat("price")
-
- price := c.GetString("price")
- price_float, _ := strconv.ParseFloat(price, 64)
-
- if len(name) <= 0 {
- utils.ErrorLog("len(name) == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- //if len(code) <= 0 {
- // utils.ErrorLog("len(code) == 0")
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- // return
- //}
-
- adminUserInfo := c.GetAdminUserInfo()
-
- addition := models.XtHisAddtionConfig{
- Name: name,
- Code: code,
- Status: 1,
- Price: price_float,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- UserOrgId: adminUserInfo.CurrentOrgId,
- }
-
- err, additions := service.AddSigleAddition(&addition)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "addition": additions,
- })
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
-
- }
-
- }
- func (c *ManagerCenterApiController) ModifyAddition() {
- id, _ := c.GetInt64("id", 0)
-
- name := c.GetString("name")
- code := c.GetString("code")
- price, _ := c.GetFloat("price")
-
- if id <= 0 {
- utils.ErrorLog("id == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if len(name) <= 0 {
- utils.ErrorLog("len(class_name) == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- //if len(code) <= 0 {
- // utils.ErrorLog("len(content_code) == 0")
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- // return
- //}
-
- adminUserInfo := c.GetAdminUserInfo()
- addition := models.XtHisAddtionConfig{
- ID: id,
- Name: name,
- Code: code,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- UserOrgId: adminUserInfo.CurrentOrgId,
- Price: price,
- Status: 1,
- }
-
- err := service.ModifyAddition(&addition)
-
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "addition": addition,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
- func (c *ManagerCenterApiController) GetAdditionList() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 7)
- adminUserInfo := c.GetAdminUserInfo()
- addition, total, err := service.FindAllAdditionList(adminUserInfo.CurrentOrgId, page, limit)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "addition": addition,
- "total": total,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
- func (c *ManagerCenterApiController) DeleteAddition() {
- id, _ := c.GetInt64("id", 0)
-
- err := service.DeleteAdditionById(id)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "删除成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
- func (c *ManagerCenterApiController) GetAddition() {
- id, _ := c.GetInt64("id", 0)
- addition, err := service.FindAdditionById(id)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "addition": addition,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
-
- func (c *ManagerCenterApiController) CreateDiagnose() {
- class_name := c.GetString("class_name")
- content_code := c.GetString("content_code")
- country_code := c.GetString("country_code")
- country_content_name := c.GetString("country_content_name")
- remark := c.GetString("remark")
- pinyin := c.GetString("pinyin")
- wubi := c.GetString("wubi")
-
- if len(class_name) <= 0 {
- utils.ErrorLog("len(class_name) == 0")
-
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if len(content_code) <= 0 {
- utils.ErrorLog("len(content_code) == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetAdminUserInfo()
-
- dealer := models.HisXtDiagnoseConfig{
- ClassName: class_name,
- ContentCode: content_code,
- CountryCode: country_code,
- CountryContentName: country_content_name,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Remark: remark,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Status: 1,
- Pinyin: pinyin,
- Wubi: wubi,
- }
-
- err, dealers := service.AddSigleDiagnose(&dealer)
- if err == nil {
- redis := service.RedisClient()
- defer redis.Close()
- diagnose_keys := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + "_diagnose"
- redis.Set(diagnose_keys, "", time.Second*60*60*18)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "sick": dealers,
- })
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
-
- }
-
- }
- func (c *ManagerCenterApiController) ModifyDiagnose() {
- id, _ := c.GetInt64("id", 0)
-
- class_name := c.GetString("class_name")
- content_code := c.GetString("content_code")
- country_code := c.GetString("country_code")
- country_content_name := c.GetString("country_content_name")
- remark := c.GetString("remark")
- pinyin := c.GetString("pinyin")
- wubi := c.GetString("wubi")
-
- if id <= 0 {
- utils.ErrorLog("id == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if len(class_name) <= 0 {
- utils.ErrorLog("len(class_name) == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if len(content_code) <= 0 {
- utils.ErrorLog("len(content_code) == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetAdminUserInfo()
- dealer := models.HisXtDiagnoseConfig{
- ID: id,
- ClassName: class_name,
- ContentCode: content_code,
- CountryCode: country_code,
- CountryContentName: country_content_name,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Remark: remark,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Pinyin: pinyin,
- Wubi: wubi,
- Status: 1,
- }
-
- err := service.ModifyDiagnose(&dealer)
-
- if err == nil {
- redis := service.RedisClient()
- defer redis.Close()
- diagnose_keys := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + "_diagnose"
- redis.Set(diagnose_keys, "", time.Second*60*60*18)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "sick": dealer,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
- func (c *ManagerCenterApiController) GetDiagnoseList() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 7)
- adminUserInfo := c.GetAdminUserInfo()
- mzSick, total, err := service.FindAllDiagnoseList(adminUserInfo.CurrentOrgId, page, limit)
- if err == nil {
-
- c.ServeSuccessJSON(map[string]interface{}{
- "sick": mzSick,
- "total": total,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
- func (c *ManagerCenterApiController) DeleteDiagnose() {
- id, _ := c.GetInt64("id", 0)
- err := service.DeleteDiagnoseById(id)
- if err == nil {
- redis := service.RedisClient()
- defer redis.Close()
- diagnose_keys := strconv.FormatInt(c.GetAdminUserInfo().CurrentOrgId, 10) + "_diagnose"
- redis.Set(diagnose_keys, "", time.Second*60*60*18)
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "删除成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
- func (c *ManagerCenterApiController) GetDiagnose() {
- id, _ := c.GetInt64("id", 0)
- mzSick, err := service.FindDiagnoseById(id)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "sick": mzSick,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
-
- func (c *ManagerCenterApiController) GetAllDrugList() {
-
- orgId := c.GetAdminUserInfo().CurrentOrgId
-
- list, err := service.GetAllDrugList(orgId)
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- dealerList, _ := service.GetAllDealerList(orgId)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "manufacturerList": manufacturerList,
- "dealerList": dealerList,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
-
- func (c *ManagerCenterApiController) GetSearchDrugList() {
- keyword := c.GetString("keyword")
- orgId := c.GetAdminUserInfo().CurrentOrgId
- storehouse_id, _ := c.GetInt64("storehouse_id")
- list, err := service.GetSearchDrugListSix(keyword, orgId, storehouse_id)
-
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- dealerList, _ := service.GetAllDealerList(orgId)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "manufacturerList": manufacturerList,
- "dealerList": dealerList,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
|