12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550 |
- package controllers
-
- import (
- "XT_New/enums"
- "XT_New/models"
- "XT_New/service"
- "XT_New/utils"
- "encoding/json"
- "fmt"
- "github.com/astaxie/beego"
- "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/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")
-
- }
-
- func (c *ManagerCenterApiController) CreateBaseDrugLib() {
- drug_name := c.GetString("drug_name")
- fmt.Println("0000000")
-
- fmt.Println(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")
- 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")
- 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")
-
- 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,
- 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: single_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(),
- }
-
- total := service.FindAllDrugLibRecordTotal(adminInfo.CurrentOrgId)
- drug_code := strconv.FormatInt(total+1, 10)
- drug_code = "54000000" + drug_code
- drugLib.DrugCode = drug_code
-
- count := service.FindBaseDrugLibRecordCount(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")
- fmt.Println("drug_name--------", 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")
- 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")
- 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")
- 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,
- SingleDose: single_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: drug.Ctime,
- Mtime: time.Now().Unix(),
- DrugCode: drug_code,
- }
-
- err := service.UpdateBaseDrugLib(drugLib)
-
- //修改xt_drug_name 表
-
- drugName := models.XtDrugName{
- DrugName: drug_name,
- }
- service.UpdatedDrugName(id, adminInfo.CurrentOrgId, &drugName)
-
- //修改规格xt_stand_name表
- standName := models.XtStandName{
- DrugName: drug_name,
- DrugSpec: drug_spec,
- DrugStockLimit: drug_stock_limit,
- MinUnit: unit,
- }
-
- service.UpdateStandName(id, adminInfo.CurrentOrgId, &standName)
- //修改药品表
- medical := models.XtSelfMedical{
- DrugName: drug_name,
- DrugSpec: drug_spec,
- ExecutionFrequency: execution_frequency,
- PrescribingNumber: prescribing_number,
- DeliveryWay: delivery_way,
- SingleDose: single_dose,
- MinUnit: unit,
- }
-
- service.UpdateSelfMedical(id, adminInfo.CurrentOrgId, &medical)
- //修改入库表
- nameId, err := service.GetDrugNameId(id, adminInfo.CurrentOrgId)
-
- stock := models.XtSelfStock{
- DrugSpec: drug_spec,
- DrugName: drug_name,
- MinUnit: unit,
- }
-
- service.UpdatedSelfStock(&stock, nameId.ID, adminInfo.CurrentOrgId)
- outStock := models.XtSelfOutStock{
- DrugName: drug_name,
- DrugSpec: drug_spec,
- }
- //修改出库表
- service.UpdatedOutSelfStock(&outStock, nameId.ID, adminInfo.CurrentOrgId)
-
- //查询未执行的医嘱
- advice := models.DoctorAdvice{
- AdviceName: drug_name,
- AdviceDesc: drug_spec,
- DeliveryWay: delivery_way,
- ExecutionFrequency: execution_frequency,
- SingleDose: single_dose,
- SingleDoseUnit: unit,
- }
-
- service.UpdateNoExcuteDoctorAdvice(nameId.ID, adminInfo.CurrentOrgId, &advice)
-
- 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)
- 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)
-
- 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))
- 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))
- 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)
- adminUserInfo := c.GetAdminUserInfo()
- deales, total, err := service.FindAllDealerList(adminUserInfo.CurrentOrgId, page, limit)
- 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)
- adminUserInfo := c.GetAdminUserInfo()
- manufacturer, total, err := service.FindAllManufacturerList(adminUserInfo.CurrentOrgId, page, limit)
- 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")
- 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)
- medical_insurance_number := c.GetString("medical_insurance_number")
- 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")
-
- adminUserInfo := c.GetAdminUserInfo()
-
- totals := service.FindGoodInfoByName(specification_name, adminUserInfo.CurrentOrgId)
- 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: retail_price,
- }
- 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")
-
- 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)
- medical_insurance_number := c.GetString("medical_insurance_number")
- 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")
-
- 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,
- 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: retail_price,
- }
-
- 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")
-
- adminUserInfo := c.GetAdminUserInfo()
- goodInfos, total, err := service.FindGoodInfoList(adminUserInfo.CurrentOrgId, page, limit, keyword, is_use, is_charge, good_kind)
- 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)
- }
- }
|