Parcourir la source

11月8日库存管理

XMLWAN il y a 2 ans
Parent
révision
0bcac23c76

+ 24 - 2
controllers/dialysis_record_api_controller.go Voir le fichier

@@ -1549,9 +1549,31 @@ func (this *DialysisRecordAPIController) ModifyStartDialysis() {
1549 1549
 
1550 1550
 	updateErr := service.ModifyStartDialysisOrder(dialysisRecord)
1551 1551
 	redis := service.RedisClient()
1552
-	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(startDate.Unix(), 10) + ":dialysis_orders_list_all"
1552
+	key := strconv.FormatInt(tempDialysisRecord.UserOrgId, 10) + ":" + strconv.FormatInt(tempDialysisRecord.PatientId, 10) + ":" + strconv.FormatInt(tempDialysisRecord.DialysisDate, 10) + ":dialysis_order"
1553 1553
 	redis.Set(key, "", time.Second)
1554
-	redis.Close()
1554
+	keyOne := strconv.FormatInt(tempDialysisRecord.UserOrgId, 10) + ":" + strconv.FormatInt(tempDialysisRecord.DialysisDate, 10) + ":dialysis_orders_list_all"
1555
+
1556
+	//清空key 值
1557
+	redis.Set(keyOne, "", time.Second)
1558
+	scheduleDateStartOne := startDate.Format("2006-01-02")
1559
+	keyTwo := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(tempDialysisRecord.UserOrgId, 10)
1560
+
1561
+	redis.Set(keyTwo, "", time.Second)
1562
+
1563
+	keyThree := strconv.FormatInt(tempDialysisRecord.UserOrgId, 10) + ":" + strconv.FormatInt(tempDialysisRecord.DialysisDate, 10) + ":" + strconv.FormatInt(tempDialysisRecord.DialysisDate, 10) + ":doctor_advices"
1564
+	redis.Set(keyThree, "", time.Second)
1565
+	keyFour := strconv.FormatInt(tempDialysisRecord.UserOrgId, 10) + ":" + strconv.FormatInt(tempDialysisRecord.DialysisDate, 10) + ":" + strconv.FormatInt(tempDialysisRecord.DialysisDate, 10) + ":monitor_records"
1566
+	redis.Set(keyFour, "", time.Second)
1567
+
1568
+	keyFive := strconv.FormatInt(tempDialysisRecord.UserOrgId, 10) + ":" + strconv.FormatInt(tempDialysisRecord.DialysisDate, 10) + ":patient_info"
1569
+	redis.Set(keyFive, "", time.Second)
1570
+
1571
+	keySix := strconv.FormatInt(tempDialysisRecord.UserOrgId, 10) + ":" + strconv.FormatInt(tempDialysisRecord.DialysisDate, 10) + ":" + strconv.FormatInt(tempDialysisRecord.DialysisDate, 10) + ":his_doctor_advice"
1572
+	redis.Set(keySix, "", time.Second)
1573
+
1574
+	keySeven := strconv.FormatInt(tempDialysisRecord.UserOrgId, 10) + ":" + ":device_list_all"
1575
+	redis.Set(keySeven, "", time.Second)
1576
+
1555 1577
 	if updateErr != nil {
1556 1578
 		this.ErrorLog("修改上机失败:%v", updateErr)
1557 1579
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)

+ 243 - 0
controllers/drug_pharmacy_management_controller.go Voir le fichier

@@ -0,0 +1,243 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/service"
6
+	"XT_New/utils"
7
+	"fmt"
8
+	"github.com/astaxie/beego"
9
+	"strings"
10
+	"time"
11
+)
12
+
13
+type PharmacyApiController struct {
14
+	BaseAuthAPIController
15
+}
16
+
17
+func PharmacyApiControllersRegisterRouters() {
18
+
19
+	beego.Router("/api/advice/gettodayadvicelist", &PharmacyApiController{}, "Get:GetTodayAdviceList")
20
+	beego.Router("api/advice/getpharmacybasedrug", &PharmacyApiController{}, "Get:GetPharyMacyBaseDrug")
21
+	beego.Router("/api/advice/updatepharmacybasedrug", &PharmacyApiController{}, "Get:UpdatePharmacyBaseDrug")
22
+}
23
+
24
+func (this *PharmacyApiController) GetTodayAdviceList() {
25
+
26
+	keywords := this.GetString("keywords")
27
+
28
+	orgId := this.GetAdminUserInfo().CurrentOrgId
29
+
30
+	//获取药房发药药品库数据
31
+	houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
32
+	list, err := service.GetPharmacyDrugList(houseConfig.DrugStorehouseOut, orgId, keywords)
33
+	if err == nil {
34
+		this.ServeSuccessJSON(map[string]interface{}{
35
+			"list": list,
36
+		})
37
+	} else {
38
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
39
+	}
40
+}
41
+
42
+func (this *PharmacyApiController) GetPharyMacyBaseDrug() {
43
+
44
+	start_time := this.GetString("start_time")
45
+	timeLayout := "2006-01-02"
46
+	loc, _ := time.LoadLocation("Local")
47
+	var theStartTime int64
48
+	if len(start_time) > 0 {
49
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
50
+		if err != nil {
51
+			utils.ErrorLog(err.Error())
52
+		}
53
+		theStartTime = theTime.Unix()
54
+	}
55
+
56
+	drug_id, _ := this.GetInt64("drug_id")
57
+
58
+	orgId := this.GetAdminUserInfo().CurrentOrgId
59
+	//获取血透医嘱
60
+	advicelist, _ := service.GetBloodAdviceList(theStartTime, drug_id, orgId)
61
+
62
+	//获取医保医嘱
63
+	hisAdviceList, err := service.GetHisAdviceList(theStartTime, drug_id, orgId)
64
+
65
+	patient, _ := service.GetAllPatientListSix(orgId)
66
+	if err == nil {
67
+		this.ServeSuccessJSON(map[string]interface{}{
68
+			"advicelist":    advicelist,
69
+			"hisAdviceList": hisAdviceList,
70
+			"patient":       patient,
71
+		})
72
+	} else {
73
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
74
+	}
75
+}
76
+
77
+func (this *PharmacyApiController) UpdatePharmacyBaseDrug() {
78
+
79
+	bloodStr := this.GetString("bloodStr")
80
+
81
+	hisStr := this.GetString("hisStr")
82
+
83
+	if len(bloodStr) == 0 {
84
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
85
+		return
86
+	}
87
+
88
+	idArray := strings.Split(bloodStr, ",")
89
+
90
+	if len(hisStr) == 0 {
91
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
92
+		return
93
+	}
94
+
95
+	idArrayOne := strings.Split(hisStr, ",")
96
+
97
+	fmt.Println("idArray23332233223", idArray)
98
+	fmt.Println("idArrayOne23332233223", idArrayOne)
99
+
100
+	orgId := this.GetAdminUserInfo().CurrentOrgId
101
+	service.UpdatePharmacyAdviceBaseDrug(idArray, orgId)
102
+	service.UpdatePharmacyHisAdviceBaseDrug(idArray, orgId)
103
+
104
+	//出库逻辑
105
+	adviceList, _ := service.GetPharmacyAdviceList(idArray, orgId)
106
+
107
+	hisAdviceList, _ := service.GetPharmacyHisAdviceList(idArray, orgId)
108
+	fmt.Print(hisAdviceList)
109
+	//查询是否通过药房出库
110
+	pharmacyConfig, _ := service.FindPharmacyConfig(orgId)
111
+
112
+	medical, _ := service.GetBaseDrugMedical(orgId)
113
+	fmt.Print(medical)
114
+	if pharmacyConfig.IsOpen == 1 {
115
+
116
+		for _, item := range adviceList {
117
+			fmt.Print(item)
118
+			//houseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.CurrentOrgId)
119
+			////查询该药品是否有库存
120
+			//list, _ := service.GetDrugTotalCountTwenty(item.DrugId, item.UserOrgId, houseConfig.DrugStorehouseOut)
121
+			//
122
+			////查询改药品信息
123
+			//medical, _ := service.GetBaseDrugMedical(item.DrugId)
124
+			////判断单位是否相等
125
+			//if medical.MaxUnit == item.PrescribingNumberUnit {
126
+			//  prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
127
+			//  count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
128
+			//  //转化为最小单位
129
+			//  total = list.Count*medical.MinNumber + list.StockMinNumber
130
+			//  prescribing_number_total = count * medical.MinNumber
131
+			//}
132
+			//if medical.MinUnit == item.PrescribingNumberUnit {
133
+			//  prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
134
+			//  count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
135
+			//  total = list.Count*medical.MinNumber + list.StockMinNumber
136
+			//  prescribing_number_total = count
137
+			//}
138
+			//
139
+			//if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
140
+			//  c.ServeSuccessJSON(map[string]interface{}{
141
+			//    "msg":    "3",
142
+			//    "advice": advice,
143
+			//  })
144
+			//  return
145
+			//}
146
+			//if prescribing_number_total > total {
147
+			//  c.ServeSuccessJSON(map[string]interface{}{
148
+			//    "msg":    "2",
149
+			//    "advice": advice,
150
+			//  })
151
+			//  return
152
+			//}
153
+			//if prescribing_number_total <= total {
154
+			//
155
+			//  //查询是否门诊处方和临时医嘱同步到透析医嘱的开关是否开启
156
+			//
157
+			//  adviceSetting, _ := service.FindAdviceSettingById(item.UserOrgId)
158
+			//  if adviceSetting.IsAdviceOpen == 1 {
159
+			//
160
+			//    //查询是否出库按钮开启
161
+			//    prescriptionConfig, _ := service.FindPrescriptionConfigById(item.UserOrgId)
162
+			//    if prescriptionConfig.IsOpen == 1 {
163
+			//      if medical.IsUse == 2 {
164
+			//        service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
165
+			//        //查询默认仓库
166
+			//        houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
167
+			//        //查询默认仓库剩余多少库存
168
+			//        list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
169
+			//        var sum_count int64
170
+			//        var sum_in_count int64
171
+			//        for _, it := range list {
172
+			//          baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
173
+			//          if it.MaxUnit == baseDrug.MaxUnit {
174
+			//            it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
175
+			//            it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
176
+			//          }
177
+			//          sum_count += it.StockMaxNumber + it.StockMinNumber
178
+			//          sum_in_count += it.WarehousingCount
179
+			//        }
180
+			//        service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
181
+			//        break
182
+			//        c.ServeSuccessJSON(map[string]interface{}{
183
+			//          "msg":    "1",
184
+			//          "advice": advice,
185
+			//        })
186
+			//        return
187
+			//      }
188
+			//      if medical.IsUse == 1 {
189
+			//        c.ServeSuccessJSON(map[string]interface{}{
190
+			//          "msg":    "1",
191
+			//          "advice": advice,
192
+			//        })
193
+			//        return
194
+			//      }
195
+			//    } else {
196
+			//      if medical.IsUse == 1 {
197
+			//        c.ServeSuccessJSON(map[string]interface{}{
198
+			//          "msg":    "1",
199
+			//          "advice": advice,
200
+			//        })
201
+			//        return
202
+			//      }
203
+			//    }
204
+			//
205
+			//  } else {
206
+			//    if medical.IsUse == 2 {
207
+			//      service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
208
+			//      //查询默认仓库
209
+			//      houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
210
+			//      //查询默认仓库剩余多少库存
211
+			//      list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
212
+			//      var sum_count int64
213
+			//      var sum_in_count int64
214
+			//      for _, it := range list {
215
+			//        baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
216
+			//        if it.MaxUnit == baseDrug.MaxUnit {
217
+			//          it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
218
+			//          it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
219
+			//        }
220
+			//        sum_count += it.StockMaxNumber + it.StockMinNumber
221
+			//        sum_in_count += it.WarehousingCount
222
+			//      }
223
+			//      service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
224
+			//      break
225
+			//      c.ServeSuccessJSON(map[string]interface{}{
226
+			//        "msg":    "1",
227
+			//        "advice": advice,
228
+			//      })
229
+			//      return
230
+			//    }
231
+			//    if medical.IsUse == 1 {
232
+			//      c.ServeSuccessJSON(map[string]interface{}{
233
+			//        "msg":    "1",
234
+			//        "advice": advice,
235
+			//      })
236
+			//      return
237
+			//    }
238
+			//  }
239
+			//}
240
+		}
241
+	}
242
+
243
+}

+ 2 - 1
controllers/drug_stock_api_contorller.go Voir le fichier

@@ -935,6 +935,7 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
935 935
 
936 936
 			}
937 937
 
938
+			// 如果当前的入库数量 等于 历史入库数量
938 939
 			if item.WarehousingCount == warehouseInfo.WarehousingCount {
939 940
 
940 941
 				item.OrgId = item.OrgId
@@ -985,7 +986,7 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
985 986
 						fmt.Println(parseDateErr)
986 987
 					}
987 988
 				}
988
-				errs = service.UpDateDrugWarehousingInfoTwo(item.ID, warehouseinfo)
989
+				errs = service.UpDateDrugWarehousingInfoSix(item.ID, warehouseinfo)
989 990
 				//查询默认仓库
990 991
 				houseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.CurrentOrgId)
991 992
 				//查询默认仓库剩余多少库存

+ 3 - 1
controllers/his_api_controller.go Voir le fichier

@@ -830,8 +830,10 @@ func (c *HisApiController) GetHisPrescriptionConfig() {
830 830
 	adminInfo := c.GetAdminUserInfo()
831 831
 	//获取医嘱模版
832 832
 	advices, _ := service.FindAllHisAdviceTemplate(adminInfo.CurrentOrgId)
833
+
834
+	houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.CurrentOrgId)
833 835
 	//获取所有基础药
834
-	drugs, _ := service.GetAllDrugLibList(adminInfo.CurrentOrgId)
836
+	drugs, _ := service.GetAllDrugLibListSix(adminInfo.CurrentOrgId, houseConfig.DrugStorehouseOut)
835 837
 
836 838
 	_, config := service.FindHisStockPriceRecordByOrgId(adminInfo.CurrentOrgId)
837 839
 	if config.ID > 0 && config.IsOpen == 1 {

+ 2 - 1
controllers/his_project_api_controller.go Voir le fichier

@@ -828,7 +828,8 @@ func (this *HisProjectApiController) GetHisProject() {
828 828
 	adminUserInfo := this.GetAdminUserInfo()
829 829
 	orgId := adminUserInfo.CurrentOrgId
830 830
 	project, err := service.GetHisProject(orgId)
831
-	good_info, err := service.GetGoodInfoMation(orgId)
831
+	houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
832
+	good_info, err := service.GetGoodInfoMationSix(orgId, houseConfig.StorehouseOutInfo)
832 833
 	_, config := service.FindHisStockPriceRecordByOrgId(orgId)
833 834
 	if config.ID > 0 && config.IsOpen == 1 {
834 835
 		//处理耗材不同批号价格问题

+ 2 - 1
controllers/mobile_api_controllers/dialysis_api_controller.go Voir le fichier

@@ -3800,9 +3800,10 @@ func (c *DialysisAPIController) GetSchedule() {
3800 3800
 	//scheduleTime := theStartTime.Unix()
3801 3801
 	scheduleTime, _ := c.GetInt64("record_date")
3802 3802
 	deviceNumber, _ := service.GetAllDeviceNumbers(adminUserInfo.Org.Id, scheduleTime, schedual_type)
3803
-
3803
+	list, _ := service.GetAllBedNumberSeven(adminUserInfo.Org.Id)
3804 3804
 	c.ServeSuccessJSON(map[string]interface{}{
3805 3805
 		"number": deviceNumber,
3806
+		"list":   list,
3806 3807
 	})
3807 3808
 
3808 3809
 }

+ 17 - 0
models/device_models.go Voir le fichier

@@ -1135,3 +1135,20 @@ type ScheduleDeviceNumber struct {
1135 1135
 func (ScheduleDeviceNumber) TableName() string {
1136 1136
 	return "xt_device_number"
1137 1137
 }
1138
+
1139
+type SgjDeviceNumber struct {
1140
+	ID      int64       `gorm:"column:id" json:"id" form:"id"`
1141
+	OrgId   int64       `gorm:"column:org_id" json:"org_id" form:"org_id"`
1142
+	Number  string      `gorm:"column:number" json:"number" form:"number"`
1143
+	GroupId int64       `gorm:"column:group_id" json:"group_id" form:"group_id"`
1144
+	ZoneId  int64       `gorm:"column:zone_id" json:"zone_id" form:"zone_id"`
1145
+	Status  int64       `gorm:"column:status" json:"status" form:"status"`
1146
+	Ctime   int64       `gorm:"column:ctime" json:"ctime" form:"ctime"`
1147
+	Mtime   int64       `gorm:"column:mtime" json:"mtime" form:"mtime"`
1148
+	Sort    int64       `gorm:"column:sort" json:"sort" form:"sort"`
1149
+	Zone    *DeviceZone `gorm:"ForeignKey:ZoneId" json:"zone"`
1150
+}
1151
+
1152
+func (SgjDeviceNumber) TableName() string {
1153
+	return "xt_device_number"
1154
+}

+ 215 - 0
models/drug_pharmacy_management_models.go Voir le fichier

@@ -0,0 +1,215 @@
1
+package models
2
+
3
+type PharmacyBaseDrug struct {
4
+	ID                          int64                  `gorm:"column:id" json:"id" form:"id"`
5
+	DrugName                    string                 `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
6
+	Pinyin                      string                 `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
7
+	Wubi                        string                 `gorm:"column:wubi" json:"wubi" form:"wubi"`
8
+	DrugAlias                   string                 `gorm:"column:drug_alias" json:"drug_alias" form:"drug_alias"`
9
+	DrugAliasPinyin             string                 `gorm:"column:drug_alias_pinyin" json:"drug_alias_pinyin" form:"drug_alias_pinyin"`
10
+	DrugAliasWubi               string                 `gorm:"column:drug_alias_wubi" json:"drug_alias_wubi" form:"drug_alias_wubi"`
11
+	DrugCategory                int64                  `gorm:"column:drug_category" json:"drug_category" form:"drug_category"`
12
+	DrugSpec                    string                 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
13
+	DrugType                    int64                  `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
14
+	DrugStockLimit              string                 `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
15
+	DrugOriginPlace             string                 `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
16
+	DrugDosageForm              int64                  `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
17
+	MedicalInsuranceLevel       int64                  `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
18
+	MaxUnit                     string                 `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
19
+	MinUnit                     string                 `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
20
+	UnitMatrixing               string                 `gorm:"column:unit_matrixing" json:"unit_matrixing" form:"unit_matrixing"`
21
+	RetailPrice                 float64                `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
22
+	LastPrice                   float64                `gorm:"column:last_price" json:"last_price" form:"last_price"`
23
+	DrugControl                 int64                  `gorm:"column:drug_control" json:"drug_control" form:"drug_control"`
24
+	Number                      string                 `gorm:"column:number" json:"number" form:"number"`
25
+	DrugClassify                string                 `gorm:"column:drug_classify" json:"drug_classify" form:"drug_classify"`
26
+	DrugDose                    float64                `gorm:"column:drug_dose" json:"drug_dose" form:"drug_dose"`
27
+	DrugDoseUnit                int64                  `gorm:"column:drug_dose_unit" json:"drug_dose_unit" form:"drug_dose_unit"`
28
+	MedicalInsuranceNumber      string                 `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
29
+	Manufacturer                int64                  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
30
+	PharmacologyCategory        int64                  `gorm:"column:pharmacology_category" json:"pharmacology_category" form:"pharmacology_category"`
31
+	StatisticsCategory          int64                  `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
32
+	Code                        string                 `gorm:"column:code" json:"code" form:"code"`
33
+	IsSpecialDiseases           int64                  `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
34
+	IsRecord                    int64                  `gorm:"column:is_record" json:"is_record" form:"is_record"`
35
+	Agent                       string                 `gorm:"column:agent" json:"agent" form:"agent"`
36
+	DrugStatus                  string                 `gorm:"column:drug_status" json:"drug_status" form:"drug_status"`
37
+	LimitRemark                 string                 `gorm:"column:limit_remark" json:"limit_remark" form:"limit_remark"`
38
+	DeliveryWay                 string                 `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
39
+	ExecutionFrequency          string                 `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
40
+	SingleDose                  float64                `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
41
+	PrescribingNumber           float64                `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
42
+	Label                       int64                  `gorm:"column:label" json:"label" form:"label"`
43
+	Sort                        int64                  `gorm:"column:sort" json:"sort" form:"sort"`
44
+	IsUseDoctorAdvice           int64                  `gorm:"column:is_use_doctor_advice" json:"is_use_doctor_advice" form:"is_use_doctor_advice"`
45
+	IsDefault                   int64                  `gorm:"column:is_default" json:"is_default" form:"is_default"`
46
+	IsChargePredict             int64                  `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
47
+	IsStatisticsWork            int64                  `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
48
+	IsChargeUse                 int64                  `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
49
+	Status                      int64                  `gorm:"column:status" json:"status" form:"status"`
50
+	Ctime                       int64                  `gorm:"column:ctime" json:"ctime" form:"ctime"`
51
+	Mtime                       int64                  `gorm:"column:mtime" json:"mtime" form:"mtime"`
52
+	OrgId                       int64                  `gorm:"column:org_id" json:"org_id" form:"org_id"`
53
+	DrugCode                    string                 `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
54
+	Dealer                      int64                  `gorm:"column:dealer" json:"dealer" form:"dealer"`
55
+	DoseCode                    string                 `gorm:"column:dose_code" json:"dose_code" form:"dose_code"`
56
+	RecordDate                  int64                  `gorm:"column:record_date" json:"record_date" form:"record_date"`
57
+	DrugRemark                  string                 `gorm:"column:drug_remark" json:"drug_remark" form:"drug_remark"`
58
+	SocialSecurityDirectoryCode string                 `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
59
+	IsMark                      int64                  `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
60
+	PrescriptionMark            int64                  `gorm:"column:prescription_mark" json:"prescription_mark" form:"prescription_mark"`
61
+	HospApprFlag                int64                  `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
62
+	LmtUsedFlag                 int64                  `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
63
+	Total                       float64                `gorm:"column:total" json:"total" form:"total"`
64
+	PrescribingNumberUnit       string                 `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
65
+	MinNumber                   int64                  `gorm:"column:min_number" json:"min_number" form:"min_number"`
66
+	Dose                        float64                `gorm:"column:dose" json:"dose" form:"dose"`
67
+	DoseUnit                    string                 `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
68
+	DrugDay                     string                 `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
69
+	MinPrice                    float64                `gorm:"column:min_price" json:"min_price" form:"min_price"`
70
+	ProvincesCode               string                 `gorm:"column:provinces_code" json:"provinces_code" form:"provinces_code"`
71
+	IsUser                      int64                  `gorm:"column:is_user" json:"is_user" form:"is_user"`
72
+	SumCount                    int64                  `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
73
+	BatchRetaiPrice             float64                `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
74
+	SumInCount                  int64                  `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
75
+	IsPharmacy                  int64                  `gorm:"column:is_pharmacy" json:"is_pharmacy" form:"is_pharmacy"`
76
+	DrugWarehouseInfo           []*XtDrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_info"`
77
+}
78
+
79
+func (PharmacyBaseDrug) TableName() string {
80
+	return "xt_base_drug"
81
+}
82
+
83
+type PharmacyDoctorAdvice struct {
84
+	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
85
+	UserOrgId             int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
86
+	PatientId             int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
87
+	AdviceType            int64   `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
88
+	AdviceDate            int64   `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
89
+	StartTime             int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
90
+	AdviceName            string  `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
91
+	AdviceDesc            string  `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
92
+	ReminderDate          int64   `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
93
+	SingleDose            float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
94
+	SingleDoseUnit        string  `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
95
+	PrescribingNumber     float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
96
+	PrescribingNumberUnit string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
97
+	DeliveryWay           string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
98
+	ExecutionFrequency    string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
99
+	AdviceDoctor          int64   `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
100
+	Status                int64   `gorm:"column:status" json:"status" form:"status"`
101
+	CreatedTime           int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
102
+	UpdatedTime           int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
103
+	AdviceAffirm          string  `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
104
+	Remark                string  `gorm:"column:remark" json:"remark" form:"remark"`
105
+	StopTime              int64   `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
106
+	StopReason            string  `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
107
+	StopDoctor            int64   `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
108
+	StopState             int64   `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
109
+	ParentId              int64   `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
110
+	ExecutionTime         int64   `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
111
+	ExecutionStaff        int64   `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
112
+	ExecutionState        int64   `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
113
+	Checker               int64   `gorm:"column:checker" json:"checker" form:"checker"`
114
+	RecordDate            int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
115
+	DialysisOrderId       int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
116
+	CheckTime             int64   `gorm:"column:check_time" json:"check_time" form:"check_time"`
117
+	CheckState            int64   `gorm:"column:check_state" json:"check_state" form:"check_state"`
118
+	DrugSpec              float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
119
+	DrugSpecUnit          string  `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
120
+	Groupno               int64   `gorm:"column:groupno" json:"groupno" form:"groupno"`
121
+	RemindType            int64   `gorm:"column:remind_type" json:"remind_type" form:"remind_type"`
122
+	FrequencyType         int64   `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
123
+	DayCount              int64   `gorm:"column:day_count" json:"day_count" form:"day_count"`
124
+	WeekDay               string  `gorm:"column:week_day" json:"week_day" form:"week_day"`
125
+	TemplateId            string  `gorm:"column:template_id" json:"template_id" form:"template_id"`
126
+	Modifier              int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
127
+	Way                   int64   `gorm:"column:way" json:"way" form:"way"`
128
+	DrugId                int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
129
+	DrugNameId            int64   `gorm:"column:drug_name_id" json:"drug_name_id" form:"drug_name_id"`
130
+	SyncAdviceId          int64   `gorm:"column:sync_advice_id" json:"sync_advice_id" form:"sync_advice_id"`
131
+	IsSync                int64   `gorm:"column:is_sync" json:"is_sync" form:"is_sync"`
132
+	IsMedicine            int64   `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
133
+	Mtime                 int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
134
+}
135
+
136
+func (PharmacyDoctorAdvice) TableName() string {
137
+	return "xt_doctor_advice"
138
+}
139
+
140
+type PharmacyHisDoctorAdviceInfo struct {
141
+	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
142
+	UserOrgId             int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
143
+	PatientId             int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
144
+	HisPatientId          int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
145
+	AdviceType            int64   `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
146
+	AdviceDate            int64   `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
147
+	StartTime             int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
148
+	AdviceName            string  `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
149
+	AdviceDesc            string  `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
150
+	ReminderDate          int64   `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
151
+	SingleDose            float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
152
+	SingleDoseUnit        string  `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
153
+	PrescribingNumber     float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
154
+	PrescribingNumberUnit string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
155
+	DeliveryWay           string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
156
+	ExecutionFrequency    string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
157
+	AdviceDoctor          int64   `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
158
+	Status                int64   `gorm:"column:status" json:"status" form:"status"`
159
+	CreatedTime           int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
160
+	UpdatedTime           int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
161
+	AdviceAffirm          string  `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
162
+	Remark                string  `gorm:"column:remark" json:"remark" form:"remark"`
163
+	StopTime              int64   `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
164
+	StopReason            string  `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
165
+	StopDoctor            int64   `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
166
+	StopState             int64   `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
167
+	ParentId              int64   `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
168
+	ExecutionTime         int64   `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
169
+	ExecutionStaff        int64   `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
170
+	ExecutionState        int64   `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
171
+	Checker               int64   `gorm:"column:checker" json:"checker" form:"checker"`
172
+	RecordDate            int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
173
+	DialysisOrderId       int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
174
+	CheckTime             int64   `gorm:"column:check_time" json:"check_time" form:"check_time"`
175
+	CheckState            int64   `gorm:"column:check_state" json:"check_state" form:"check_state"`
176
+	DrugSpec              float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
177
+	DrugSpecUnit          string  `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
178
+	Groupno               int64   `gorm:"column:groupno" json:"groupno" form:"groupno"`
179
+	RemindType            int64   `gorm:"column:remind_type" json:"remind_type" form:"remind_type"`
180
+	FrequencyType         int64   `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
181
+	DayCount              int64   `gorm:"column:day_count" json:"day_count" form:"day_count"`
182
+	WeekDay               string  `gorm:"column:week_day" json:"week_day" form:"week_day"`
183
+	TemplateId            string  `gorm:"column:template_id" json:"template_id" form:"template_id"`
184
+	Modifier              int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
185
+	DrugId                int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
186
+	Price                 float64 `gorm:"column:price" json:"price" form:"price"`
187
+	PrescriptionId        int64   `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
188
+	MedListCodg           string  `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
189
+	FeedetlSn             string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
190
+	Day                   int64   `gorm:"column:day" json:"day" form:"day"`
191
+	Diagnosis             int64   `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
192
+	HospApprFlag          int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
193
+	LmtUsedFlag           int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
194
+	Way                   int64   `gorm:"column:way" json:"way" form:"way"`
195
+	IsMedicine            int64   `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
196
+	Mtime                 int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
197
+	AdviceId              int64   `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
198
+}
199
+
200
+func (PharmacyHisDoctorAdviceInfo) TableName() string {
201
+	return "his_doctor_advice_info"
202
+}
203
+
204
+type PharmacyConfig struct {
205
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
206
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
207
+	IsOpen    int64 `gorm:"column:is_open" json:"is_open" form:"is_open"`
208
+	Status    int64 `gorm:"column:status" json:"status" form:"status"`
209
+	Ctime     int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
210
+	Mtime     int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
211
+}
212
+
213
+func (PharmacyConfig) TableName() string {
214
+	return "xt_pharmacy_config"
215
+}

+ 1 - 0
routers/router.go Voir le fichier

@@ -82,4 +82,5 @@ func init() {
82 82
 	controllers.SecondaryOrderApiRegistRouters()
83 83
 	controllers.HisDepositApiRegistRouters()
84 84
 	controllers.HisSummaryApiRegistRouters()
85
+	controllers.PharmacyApiControllersRegisterRouters()
85 86
 }

+ 6 - 0
service/device_service.go Voir le fichier

@@ -767,3 +767,9 @@ func GetAllBedNumberSix(orgId int64) (devicenumber []*models.ScheduleDeviceNumbe
767 767
 	err = XTReadDB().Where("org_id = ? and status = 1", orgId).Find(&devicenumber).Error
768 768
 	return devicenumber, err
769 769
 }
770
+
771
+func GetAllBedNumberSeven(orgId int64) (devicenumber []*models.SgjDeviceNumber, err error) {
772
+
773
+	err = XTReadDB().Where("org_id = ? and status= 1", orgId).Preload("Zone", "status = 1").Find(&devicenumber).Error
774
+	return devicenumber, err
775
+}

+ 7 - 0
service/dialysis_service.go Voir le fichier

@@ -1382,6 +1382,13 @@ func GetGoodInfoMation(orgid int64) (goodinfo []*models.GoodInfo, err error) {
1382 1382
 	return goodinfo, err
1383 1383
 }
1384 1384
 
1385
+func GetGoodInfoMationSix(orgid int64, storehouse_id int64) (goodinfo []*models.GoodInfo, err error) {
1386
+
1387
+	err = XTReadDB().Model(&goodinfo).Where("org_id = ? and status = 1 AND  find_in_set('停用',good_status) = 0", orgid).Preload("GoodSotckInfo", "stock_count > 0 and status = 1 and storehouse_id = ?", storehouse_id).Find(&goodinfo).Error
1388
+	//err = XTReadDB().Model(&goodinfo).Where("org_id = ? and status = 1 AND  find_in_set('停用',good_status) = 0", orgid).Find(&goodinfo).Error
1389
+	return goodinfo, err
1390
+}
1391
+
1385 1392
 func GetDialysisBeforePrepare(goodTypeId int64, goodId int64, orgid int64, patientId int64) (*models.DialysisBeforePrepare, error) {
1386 1393
 
1387 1394
 	prepare := models.DialysisBeforePrepare{}

+ 69 - 0
service/drug_pharmacy_management_service.go Voir le fichier

@@ -0,0 +1,69 @@
1
+package service
2
+
3
+import (
4
+	"XT_New/models"
5
+	"github.com/jinzhu/gorm"
6
+)
7
+
8
+func GetPharmacyDrugList(storehouse_id int64, orgid int64, keywords string) (drug []*models.PharmacyBaseDrug, err error) {
9
+
10
+	db := XTReadDB().Model(&drug).Where("org_id=? and status=1  and drug_status<>'停用  and is_pharmacy = 1'", orgid)
11
+	if len(keywords) > 0 {
12
+		likekey := "%" + keywords + "%"
13
+		err = db.Where("(drug_name LIKE ?)", likekey).Preload("DrugWarehouseInfo", func(db *gorm.DB) *gorm.DB {
14
+			return XTReadDB().Where("org_id=? and status = 1 and warehousing_count <> 0 and storehouse_id = ?", orgid, storehouse_id).Group("id")
15
+		}).Find(&drug).Error
16
+	} else {
17
+		err = db.Preload("DrugWarehouseInfo", func(db *gorm.DB) *gorm.DB {
18
+			return XTReadDB().Where("org_id=? and status = 1 and warehousing_count <> 0 and storehouse_id = ?", orgid, storehouse_id).Group("id")
19
+		}).Find(&drug).Error
20
+	}
21
+	return
22
+}
23
+
24
+func GetBloodAdviceList(advice_date int64, drug_id int64, org_id int64) (advice []*models.PharmacyDoctorAdvice, err error) {
25
+
26
+	err = XTReadDB().Where("advice_date = ? and drug_id = ? and user_org_id = ? and status = 1 and advice_type =2 and is_medicine= 0", advice_date, drug_id, org_id).Find(&advice).Error
27
+	return advice, err
28
+}
29
+
30
+func GetHisAdviceList(advice_date int64, drug_id int64, org_id int64) (advice []*models.PharmacyHisDoctorAdviceInfo, err error) {
31
+
32
+	err = XTReadDB().Where("advice_date = ? and drug_id =? and user_org_id =? and status = 1 and is_medicine = 0", advice_date, drug_id, org_id).Order("prescription_id asc").Find(&advice).Error
33
+	return advice, err
34
+}
35
+
36
+func UpdatePharmacyAdviceBaseDrug(ids []string, orgid int64) (models.PharmacyDoctorAdvice, error) {
37
+
38
+	drug := models.PharmacyDoctorAdvice{}
39
+
40
+	err := XTWriteDB().Where("id in(?) and user_org_id = ? and status = 1", ids, orgid).Update(map[string]interface{}{"is_medicine": 1}).Error
41
+
42
+	return drug, err
43
+}
44
+
45
+func UpdatePharmacyHisAdviceBaseDrug(ids []string, orgid int64) (models.PharmacyHisDoctorAdviceInfo, error) {
46
+
47
+	info := models.PharmacyHisDoctorAdviceInfo{}
48
+	err := XTWriteDB().Where("id in(?) and user_org_id = ? and status = 1", ids, orgid).Update(map[string]interface{}{"is_medicine": 1}).Error
49
+	return info, err
50
+}
51
+
52
+func GetPharmacyAdviceList(ids []string, orgid int64) (advice []*models.PharmacyDoctorAdvice, err error) {
53
+
54
+	err = XTReadDB().Where("id in(?) and user_org_id = ?", ids, orgid).Find(&advice).Error
55
+	return advice, err
56
+}
57
+
58
+func GetPharmacyHisAdviceList(ids []string, orgid int64) (advice []*models.PharmacyHisDoctorAdviceInfo, err error) {
59
+
60
+	err = XTReadDB().Where("id in(?) and user_org_id = ?", ids, orgid).Find(&advice).Error
61
+	return advice, err
62
+}
63
+
64
+func FindPharmacyConfig(orgid int64) (models.PharmacyConfig, error) {
65
+
66
+	config := models.PharmacyConfig{}
67
+	err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&config).Error
68
+	return config, err
69
+}

+ 9 - 0
service/his_service.go Voir le fichier

@@ -797,6 +797,15 @@ func GetAllDrugLibList(org_id int64) (list []*BaseDrugLib, err error) {
797 797
 	return
798 798
 }
799 799
 
800
+func GetAllDrugLibListSix(org_id int64, storehouse_id int64) (list []*BaseDrugLib, err error) {
801
+	err = readDb.Model(&BaseDrugLib{}).Where("org_id = ?  AND status = 1 AND  find_in_set('停用',drug_status) = 0", org_id).Preload("OtherDrugWarehouseInfo", func(db *gorm.DB) *gorm.DB {
802
+		return db.Where("(status = 1 and stock_max_number > 0 and  storehouse_id = ? )  or  (status = 1  AND stock_min_number >0 and  storehouse_id = ?)", storehouse_id, storehouse_id)
803
+	}).Find(&list).Error
804
+
805
+	//err = readDb.Model(&BaseDrugLib{}).Where("org_id = ?  AND status = 1 AND  find_in_set('停用',drug_status) = 0", org_id).Find(&list).Error
806
+	return
807
+}
808
+
800 809
 func GetAllDrugLibs(org_id int64) (drugs []*Drugs, err error) {
801 810
 	db := readDb.Model(&models.BaseDrugLib{}).Preload("Drugs", "status = 1 AND org_id = ? AND find_in_set('停用',drug_status) = 0", org_id).Where("org_id = ?  AND status = 1 AND find_in_set('停用',drug_status) = 0", org_id).Group("drug_name")
802 811
 	err = db.Find(&drugs).Error

+ 5 - 0
service/stock_service.go Voir le fichier

@@ -2239,6 +2239,11 @@ func UpDateDrugWarehousingInfoTwo(id int64, info *models.DrugWarehouseInfo) (err
2239 2239
 	return err
2240 2240
 }
2241 2241
 
2242
+func UpDateDrugWarehousingInfoSix(id int64, info *models.DrugWarehouseInfo) (err error) {
2243
+	err = writeDb.Model(&info).Where("id= ? and status = 1", id).Updates(map[string]interface{}{"number": info.Number, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "price": info.Price, "total_price": info.TotalPrice, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "remark": info.Remark, "batch_number": info.BatchNumber, "max_unit": info.MaxUnit, "min_unit": info.MinUnit, "retail_price": info.RetailPrice, "storehouse_id": info.StorehouseId}).Error
2244
+	return err
2245
+}
2246
+
2242 2247
 func GetDrugWarehouseOrderOne(id int64, drug_id int64) (models.DrugWarehouseInfo, error) {
2243 2248
 
2244 2249
 	info := models.DrugWarehouseInfo{}

+ 62 - 53
service/warhouse_service.go Voir le fichier

@@ -1215,7 +1215,7 @@ func ConsumablesDeliveryTotal(orgID int64, patient_id int64, record_time int64,
1215 1215
 func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods *models.DialysisBeforePrepare, warehouseOut *models.WarehouseOut, count int64) (err error) {
1216 1216
 
1217 1217
 	//开事务
1218
-	tx := XTWriteDB().Begin()
1218
+	//tx := XTWriteDB().Begin()
1219 1219
 	var deliver_number int64 = 0
1220 1220
 	var stock_number int64 = 0
1221 1221
 	var maxNumber int64 = 0
@@ -1458,11 +1458,14 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1458 1458
 		ModifyGoodReduceInformationSix(goods.GoodId, goods.Count, orgID, warehouse.PackingPrice)
1459 1459
 		errThree := UpDateWarehouseInfoByStock(&warehouse)
1460 1460
 		if errThree != nil {
1461
-			utils.ErrorLog("事务失败,原因为: %v", err.Error())
1462
-			tx.Rollback()
1463
-		} else {
1464
-			tx.Commit()
1461
+			return errThree
1465 1462
 		}
1463
+		//if errThree != nil {
1464
+		//	utils.ErrorLog("事务失败,原因为: %v", err.Error())
1465
+		//	tx.Rollback()
1466
+		//} else {
1467
+		//	tx.Commit()
1468
+		//}
1466 1469
 
1467 1470
 		return nil
1468 1471
 	} else {
@@ -1650,11 +1653,14 @@ func ConsumablesDelivery(orgID int64, patient_id int64, record_time int64, goods
1650 1653
 		warehouse.Mtime = time.Now().Unix()
1651 1654
 		errThree := UpDateWarehouseInfoByStock(&warehouse)
1652 1655
 		if errThree != nil {
1653
-			utils.ErrorLog("事务失败,原因为: %v", err.Error())
1654
-			tx.Rollback()
1655
-		} else {
1656
-			tx.Commit()
1656
+			return errThree
1657 1657
 		}
1658
+		//if errThree != nil {
1659
+		//	utils.ErrorLog("事务失败,原因为: %v", err.Error())
1660
+		//	tx.Rollback()
1661
+		//} else {
1662
+		//	tx.Commit()
1663
+		//}
1658 1664
 
1659 1665
 		// 清零完该库存后,还有剩余出库未出完,进行对应的递归操作
1660 1666
 		goods.Count = deliver_number - stock_number
@@ -1787,8 +1793,8 @@ func GetWarehouseById(id int64) (models.WarehouseOut, error) {
1787 1793
 //耗材出库
1788 1794
 func ConsumablesDeliveryOne(orgID int64, record_time int64, goods *models.WarehouseOutInfo, warehouseOut *models.WarehouseOut, count int64, creator int64) (err error) {
1789 1795
 
1790
-	//开事务
1791
-	tx := XTWriteDB().Begin()
1796
+	////开事务
1797
+	//tx := XTWriteDB().Begin()
1792 1798
 
1793 1799
 	var deliver_number int64 = 0
1794 1800
 	var stock_number int64 = 0
@@ -1894,12 +1900,13 @@ func ConsumablesDeliveryOne(orgID int64, record_time int64, goods *models.Wareho
1894 1900
 
1895 1901
 		//扣减库存
1896 1902
 		errThree := UpDateWarehouseInfoByStock(&warehouse)
1897
-		if errThree != nil {
1898
-			utils.ErrorLog("事务失败,原因为: %v", errThree.Error())
1899
-			tx.Rollback()
1900
-		} else {
1901
-			tx.Commit()
1902
-		}
1903
+		fmt.Println(errThree)
1904
+		//if errThree != nil {
1905
+		//	utils.ErrorLog("事务失败,原因为: %v", errThree.Error())
1906
+		//	tx.Rollback()
1907
+		//} else {
1908
+		//	tx.Commit()
1909
+		//}
1903 1910
 
1904 1911
 		//查询该机构默认仓库
1905 1912
 		storeConfig, _ := GetAllStoreHouseConfig(goods.OrgId)
@@ -2016,13 +2023,13 @@ func ConsumablesDeliveryOne(orgID int64, record_time int64, goods *models.Wareho
2016 2023
 		warehouse.Mtime = time.Now().Unix()
2017 2024
 
2018 2025
 		errThree := UpDateWarehouseInfoByStock(&warehouse)
2019
-
2020
-		if errThree != nil {
2021
-			utils.ErrorLog("事务失败,原因为: %v", errThree.Error())
2022
-			tx.Rollback()
2023
-		} else {
2024
-			tx.Commit()
2025
-		}
2026
+		fmt.Println(errThree)
2027
+		//if errThree != nil {
2028
+		//	utils.ErrorLog("事务失败,原因为: %v", errThree.Error())
2029
+		//	tx.Rollback()
2030
+		//} else {
2031
+		//	tx.Commit()
2032
+		//}
2026 2033
 		// 清零完该库存后,还有剩余出库未出完,进行对应的递归操作
2027 2034
 		goods.Count = deliver_number - stock_number
2028 2035
 		ConsumablesDeliveryOne(orgID, record_time, goods, warehouseOut, count, creator)
@@ -2034,8 +2041,8 @@ func ConsumablesDeliveryOne(orgID int64, record_time int64, goods *models.Wareho
2034 2041
 //退库逻辑
2035 2042
 func ConsumablesDeliveryTwo(orgID int64, goods *models.WarehouseOutInfo, count int64) (err error) {
2036 2043
 
2037
-	//开事务
2038
-	tx := XTWriteDB().Begin()
2044
+	////开事务
2045
+	//tx := XTWriteDB().Begin()
2039 2046
 	var deliver_number int64 = 0
2040 2047
 	var stock_number int64 = 0
2041 2048
 	var maxNumber int64 = 0
@@ -2095,13 +2102,13 @@ func ConsumablesDeliveryTwo(orgID int64, goods *models.WarehouseOutInfo, count i
2095 2102
 			return errors.New("库存数量不足")
2096 2103
 		}
2097 2104
 		errThree := UpDateWarehouseInfoByStock(&warehouse)
2098
-
2099
-		if errThree != nil {
2100
-			utils.ErrorLog("事务失败,原因为: %v", err.Error())
2101
-			tx.Rollback()
2102
-		} else {
2103
-			tx.Commit()
2104
-		}
2105
+		fmt.Println(errThree)
2106
+		//if errThree != nil {
2107
+		//	utils.ErrorLog("事务失败,原因为: %v", err.Error())
2108
+		//	tx.Rollback()
2109
+		//} else {
2110
+		//	tx.Commit()
2111
+		//}
2105 2112
 
2106 2113
 		return
2107 2114
 	} else {
@@ -2138,13 +2145,14 @@ func ConsumablesDeliveryTwo(orgID int64, goods *models.WarehouseOutInfo, count i
2138 2145
 		warehouse.StockCount = 0
2139 2146
 		warehouse.Mtime = time.Now().Unix()
2140 2147
 		errThree := UpDateWarehouseInfoByStock(&warehouse)
2141
-		if errThree != nil {
2142
-			utils.ErrorLog("事务失败,原因为: %v", err.Error())
2143
-			tx.Rollback()
2144
-		} else {
2145
-			tx.Commit()
2146
-		}
2148
+		//if errThree != nil {
2149
+		//	utils.ErrorLog("事务失败,原因为: %v", err.Error())
2150
+		//	tx.Rollback()
2151
+		//} else {
2152
+		//	tx.Commit()
2153
+		//}
2147 2154
 
2155
+		fmt.Println(errThree)
2148 2156
 		// 清零完该库存后,还有剩余出库未出完,进行对应的递归操作
2149 2157
 		goods.Count = deliver_number - stock_number
2150 2158
 
@@ -4559,7 +4567,7 @@ func AutoDrugDeliverInfoTwenty(orgID int64, prescribingNumber int64, warehouseou
4559 4567
 // 药品手动出库 递归方式
4560 4568
 func AutoDrugDeliverInfoTwentyOne(orgID int64, prescribingNumber int64, warehouseout *models.DrugWarehouseOut, drup *models.BaseDrugLib, advice *models.DrugWarehouseOutInfo) (err error) {
4561 4569
 	//开事务
4562
-	tx := XTWriteDB().Begin()
4570
+	//tx := XTWriteDB().Begin()
4563 4571
 	// 判断处方里药品单位是拆零单位还是包装单位,	如果是包装单位,则根据规格,将包装数量转为拆零数量
4564 4572
 	var deliver_number int64 = 0
4565 4573
 	var stock_number int64 = 0
@@ -4727,13 +4735,13 @@ func AutoDrugDeliverInfoTwentyOne(orgID int64, prescribingNumber int64, warehous
4727 4735
 		}
4728 4736
 
4729 4737
 		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
4730
-
4731
-		if errThree != nil {
4732
-			utils.ErrorLog("事务失败,原因为: %v", err.Error())
4733
-			tx.Rollback()
4734
-		} else {
4735
-			tx.Commit()
4736
-		}
4738
+		fmt.Println(errThree)
4739
+		//if errThree != nil {
4740
+		//	utils.ErrorLog("事务失败,原因为: %v", err.Error())
4741
+		//	tx.Rollback()
4742
+		//} else {
4743
+		//	tx.Commit()
4744
+		//}
4737 4745
 
4738 4746
 		//查询默认仓库
4739 4747
 		houseConfig, _ := GetAllStoreHouseConfig(orgID)
@@ -4833,12 +4841,13 @@ func AutoDrugDeliverInfoTwentyOne(orgID int64, prescribingNumber int64, warehous
4833 4841
 		warehouse.Mtime = time.Now().Unix()
4834 4842
 
4835 4843
 		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
4836
-		if errThree != nil {
4837
-			utils.ErrorLog("事务失败,原因为: %v", err.Error())
4838
-			tx.Rollback()
4839
-		} else {
4840
-			tx.Commit()
4841
-		}
4844
+		fmt.Println(errThree)
4845
+		//if errThree != nil {
4846
+		//	utils.ErrorLog("事务失败,原因为: %v", err.Error())
4847
+		//	tx.Rollback()
4848
+		//} else {
4849
+		//	tx.Commit()
4850
+		//}
4842 4851
 
4843 4852
 		//查询默认仓库
4844 4853
 		houseConfig, _ := GetAllStoreHouseConfig(orgID)