28169 11 mesi fa
parent
commit
041d816d19

+ 8 - 6
controllers/drug_stock_api_contorller.go Vedi File

@@ -1,18 +1,19 @@
1 1
 package controllers
2 2
 
3 3
 import (
4
-	"XT_New/enums"
5
-	"XT_New/models"
6
-	"XT_New/service"
7
-	"XT_New/utils"
8 4
 	"encoding/json"
9 5
 	"fmt"
10
-	"github.com/astaxie/beego"
11
-	"github.com/jinzhu/gorm"
12 6
 	"reflect"
13 7
 	"strconv"
14 8
 	"strings"
15 9
 	"time"
10
+
11
+	"XT_New/enums"
12
+	"XT_New/models"
13
+	"XT_New/service"
14
+	"XT_New/utils"
15
+	"github.com/astaxie/beego"
16
+	"github.com/jinzhu/gorm"
16 17
 )
17 18
 
18 19
 type StockDrugApiController struct {
@@ -3642,6 +3643,7 @@ func (c *StockDrugApiController) CheckWarehousingInfo() {
3642 3643
 			MinUnit:                 item.MinUnit,
3643 3644
 			StorehouseId:            item.StorehouseId,
3644 3645
 			OverCount:               sum_count,
3646
+			OperateTime:             time.Now().Unix(),
3645 3647
 		}
3646 3648
 		service.CreateDrugFlowTwo(flow)
3647 3649
 		//更新基础库剩余库存

+ 13 - 0
controllers/mobile_api_controllers/patient_api_controller.go Vedi File

@@ -2731,6 +2731,8 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
2731 2731
 			}
2732 2732
 			if adminUserInfo.Org.Id == 10579 {
2733 2733
 				newprescribe.Modifier = 0
2734
+				newprescribe.Creater = 0
2735
+				newprescribe.PrescriptionDoctor = 0
2734 2736
 			}
2735 2737
 			err := service.AddSigleRecord(&newprescribe)
2736 2738
 			//记录日志
@@ -2897,6 +2899,8 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
2897 2899
 				}
2898 2900
 				if adminUserInfo.Org.Id == 10579 {
2899 2901
 					newprescribe.Modifier = 0
2902
+					newprescribe.Creater = 0
2903
+					newprescribe.PrescriptionDoctor = 0
2900 2904
 				}
2901 2905
 				err := service.AddSigleRecord(&newprescribe)
2902 2906
 
@@ -2945,6 +2949,8 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
2945 2949
 				if appRole.UserType == 2 || appRole.UserType == 1 {
2946 2950
 					if adminUserInfo.Org.Id == 10579 {
2947 2951
 						newprescribe.Modifier = 0
2952
+						newprescribe.Creater = 0
2953
+						newprescribe.PrescriptionDoctor = 0
2948 2954
 					} else {
2949 2955
 						newprescribe.PrescriptionDoctor = adminUserInfo.AdminUser.Id
2950 2956
 					}
@@ -3060,6 +3066,8 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
3060 3066
 				}
3061 3067
 				if adminUserInfo.Org.Id == 10579 {
3062 3068
 					newprescribe.Modifier = 0
3069
+					newprescribe.Creater = 0
3070
+					newprescribe.PrescriptionDoctor = 0
3063 3071
 				}
3064 3072
 				err := service.AddSigleRecord(&newprescribe)
3065 3073
 				//记录日志
@@ -3182,7 +3190,10 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
3182 3190
 					newprescribe.DialysateFlow = 500
3183 3191
 				}
3184 3192
 				if adminUserInfo.Org.Id == 10579 {
3193
+
3185 3194
 					newprescribe.Modifier = 0
3195
+					newprescribe.Creater = 0
3196
+					newprescribe.PrescriptionDoctor = 0
3186 3197
 				}
3187 3198
 				err := service.AddSigleRecord(&newprescribe)
3188 3199
 
@@ -3225,6 +3236,8 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
3225 3236
 				}
3226 3237
 				if adminUserInfo.Org.Id == 10579 {
3227 3238
 					newprescribe.Modifier = 0
3239
+					newprescribe.Creater = 0
3240
+					newprescribe.PrescriptionDoctor = 0
3228 3241
 				}
3229 3242
 				err := service.UpDateDialysisPrescription(&newprescribe)
3230 3243
 

+ 11 - 6
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go Vedi File

@@ -1,19 +1,20 @@
1 1
 package new_mobile_api_controllers
2 2
 
3 3
 import (
4
+	"crypto/md5"
5
+	"encoding/json"
6
+	"fmt"
7
+	"strconv"
8
+	"strings"
9
+	"time"
10
+
4 11
 	"XT_New/enums"
5 12
 	"XT_New/models"
6 13
 	"XT_New/service"
7 14
 	"XT_New/utils"
8
-	"crypto/md5"
9
-	"encoding/json"
10
-	"fmt"
11 15
 	"github.com/astaxie/beego"
12 16
 	"github.com/jinzhu/gorm"
13 17
 	"github.com/mozillazg/go-pinyin"
14
-	"strconv"
15
-	"strings"
16
-	"time"
17 18
 )
18 19
 
19 20
 type NewDialysisApiController struct {
@@ -2986,3 +2987,7 @@ func (this *NewDialysisApiController) GetNextInspectionDetail() {
2986 2987
 		})
2987 2988
 	}
2988 2989
 }
2990
+
2991
+func (this *NewDialysisApiController) GetInspectionGroup() {
2992
+
2993
+}

+ 2 - 0
controllers/new_mobile_api_controllers/new_mobile_api_router_register.go Vedi File

@@ -188,4 +188,6 @@ func NewMobileAPIControllersRegisterRouters() {
188 188
 	beego.Router("/m/api/patient/getllastinspectiondetail", &NewDialysisApiController{}, "Get:GetLastInspectionDetail")
189 189
 	beego.Router("/m/api/patient/getnextinspectionDetail", &NewDialysisApiController{}, "Get:GetNextInspectionDetail")
190 190
 
191
+	beego.Router("/m/api/patient/getinspectiongroup", &NewDialysisApiController{}, "Get:GetInspectionGroup")
192
+
191 193
 }

+ 267 - 3
controllers/pharmacy_controller.go Vedi File

@@ -39,7 +39,11 @@ func PharmacyApiRegistRouters() {
39 39
 	beego.Router("/api/pharmacy/getgoodinventorybygoodid", &PharmacyController{}, "Get:GetGoodInventoryByGoodId")
40 40
 	beego.Router("/api/pharmacy/updateInventoryWarehouseInfo", &PharmacyController{}, "Get:UpdateInventoryWarehouseInfo")
41 41
 
42
-	beego.Router("/api/pharmacy/getdruginventoryList", &PharmacyController{}, "Get:GetDrugInventoryList")
42
+	beego.Router("/api/pharmacy/getdrugnewinventoryList", &PharmacyController{}, "Get:GetDrugInventoryList")
43
+
44
+	beego.Router("/api/pharmacy/getdruginventorybydrugid", &PharmacyController{}, "Get:GetDrugInventoryByDrugId")
45
+
46
+	beego.Router("/api/pharmacy/updatedruginventorywarehouseinfo", &PharmacyController{}, "Get:UpdateDrugInventoryWarehouseInfo")
43 47
 }
44 48
 
45 49
 // 测试
@@ -1082,10 +1086,270 @@ func (this *PharmacyController) UpdateInventoryWarehouseInfo() {
1082 1086
 
1083 1087
 func (this *PharmacyController) GetDrugInventoryList() {
1084 1088
 
1089
+	keywords := this.GetString("keywords")
1090
+	orgId := this.GetAdminUserInfo().CurrentOrgId
1091
+	drugList, _ := service.GetDrugNewInventoryList(orgId, keywords)
1092
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
1093
+	this.ServeSuccessJSON(map[string]interface{}{
1094
+		"drugList":         drugList,
1095
+		"manufacturerList": manufacturerList,
1096
+	})
1097
+}
1098
+
1099
+func (this *PharmacyController) GetDrugInventoryByDrugId() {
1100
+
1085 1101
 	orgId := this.GetAdminUserInfo().CurrentOrgId
1086
-	drugList, _ := service.GetDrugNewInventoryList(orgId)
1102
+
1103
+	id, _ := this.GetInt64("id")
1104
+
1105
+	infoList, _ := service.GetDrugInvetoryByDrugId(orgId, id)
1106
+
1107
+	this.ServeSuccessJSON(map[string]interface{}{
1108
+		"infoList": infoList,
1109
+	})
1110
+}
1111
+
1112
+func (this *PharmacyController) UpdateDrugInventoryWarehouseInfo() {
1113
+
1114
+	id, _ := this.GetInt64("id")
1115
+	stock_max_number, _ := this.GetInt64("stock_max_number")
1116
+	stock_min_number, _ := this.GetInt64("stock_min_number")
1117
+	last_stock_max_number, _ := this.GetInt64("last_stock_max_number")
1118
+	last_stock_min_number, _ := this.GetInt64("last_stock_min_number")
1119
+
1120
+	drug_id, _ := this.GetInt64("drug_id")
1121
+	storehouse_id, _ := this.GetInt64("storehouse_id")
1122
+	is_type, _ := this.GetInt64("is_type")
1123
+
1124
+	specification_name := this.GetString("specification_name")
1125
+	orgId := this.GetAdminUserInfo().CurrentOrgId
1126
+
1127
+	base, _ := service.GetBasedrugByIdOne(drug_id, orgId)
1128
+
1129
+	var ord_total int64
1130
+	var new_total int64
1131
+	var consumable_count int64
1132
+
1133
+	ord_total = stock_max_number*base.MinNumber + stock_min_number
1134
+	new_total = last_stock_max_number*base.MinNumber + last_stock_min_number
1135
+
1136
+	//更新入库单
1137
+	service.UpdateNewDrugWarehouseInfoById(id, last_stock_max_number, last_stock_min_number)
1138
+
1139
+	//查询默认仓库
1140
+	houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
1141
+	//查询默认仓库剩余多少库存
1142
+	list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, orgId, drug_id)
1143
+	var sum_count int64
1144
+	for _, it := range list {
1145
+		baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
1146
+		if it.MaxUnit == baseDrug.MaxUnit {
1147
+			it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
1148
+			it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
1149
+		}
1150
+		sum_count += it.StockMaxNumber + it.StockMinNumber
1151
+
1152
+	}
1153
+	//更新剩余库存
1154
+	service.UpdateMedicalSumCountOne(drug_id, sum_count, orgId)
1155
+
1156
+	//更新剩余库存
1157
+	service.UpdateDrugStockCount(drug_id, orgId, houseConfig.DrugStorehouseOut, sum_count)
1158
+
1159
+	drugWarehouseInfoOne, _ := service.GetDrugWarehouseInfoOne(id)
1160
+
1161
+	manufacturer, _ := service.GetManufactureById(drugWarehouseInfoOne.Manufacturer)
1162
+
1163
+	recordDateStr := time.Now().Format("2006-01-02")
1164
+
1165
+	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
1166
+
1167
+	fmt.Println("ord_total-----------------------------", ord_total)
1168
+	fmt.Println("new_total-----------------------------", new_total)
1169
+	//盘亏
1170
+	if ord_total > new_total {
1171
+
1172
+		consumable_count = ord_total - new_total
1173
+
1174
+		inventory := models.XtDrugInventory{
1175
+			DrugName:           base.DrugName,
1176
+			SpecificationName:  specification_name,
1177
+			WarehousingUnit:    drugWarehouseInfoOne.MaxUnit,
1178
+			Count:              consumable_count,
1179
+			LastPrice:          drugWarehouseInfoOne.Price,
1180
+			RetailPrice:        drugWarehouseInfoOne.RetailPrice,
1181
+			NewPrice:           0,
1182
+			Manufacturer:       manufacturer.ManufacturerName,
1183
+			Dealer:             "",
1184
+			Remark:             "",
1185
+			DrugId:             drug_id,
1186
+			UserOrgId:          orgId,
1187
+			Ctime:              time.Now().Unix(),
1188
+			Mtime:              0,
1189
+			Status:             1,
1190
+			WarehousingOrder:   drugWarehouseInfoOne.WarehousingOrder,
1191
+			LicenseNumber:      "",
1192
+			StartTime:          recordDate.Unix(),
1193
+			Creater:            this.GetAdminUserInfo().AdminUser.Id,
1194
+			Checker:            0,
1195
+			CheckerStatus:      0,
1196
+			CheckerTime:        0,
1197
+			ExpiryDate:         drugWarehouseInfoOne.ExpiryDate,
1198
+			ProductDate:        drugWarehouseInfoOne.ProductDate,
1199
+			Number:             "",
1200
+			BatchNumber:        drugWarehouseInfoOne.BatchNumber,
1201
+			Total:              "",
1202
+			DrugOriginPlace:    "",
1203
+			WarehouseInfoId:    id,
1204
+			ProofCount:         0,
1205
+			StockMaxNumber:     stock_max_number,
1206
+			StockMinNumber:     stock_min_number,
1207
+			MinCount:           0,
1208
+			MinUnit:            drugWarehouseInfoOne.MinUnit,
1209
+			LastStockMaxNumber: last_stock_max_number,
1210
+			LastStockMinNumber: last_stock_min_number,
1211
+			InventoryType:      11,
1212
+			Type:               is_type,
1213
+			StorehouseId:       storehouse_id,
1214
+			RecordDate:         recordDate.Unix(),
1215
+		}
1216
+
1217
+		service.CreateDrugInventory(inventory)
1218
+
1219
+		flow := models.DrugFlow{
1220
+			WarehousingId:           id,
1221
+			DrugId:                  drug_id,
1222
+			Number:                  "",
1223
+			BatchNumber:             drugWarehouseInfoOne.BatchNumber,
1224
+			Count:                   consumable_count,
1225
+			UserOrgId:               orgId,
1226
+			PatientId:               0,
1227
+			SystemTime:              recordDate.Unix(),
1228
+			ConsumableType:          11,
1229
+			IsSys:                   1,
1230
+			WarehousingOrder:        drugWarehouseInfoOne.WarehousingOrder,
1231
+			WarehouseOutId:          0,
1232
+			WarehouseOutOrderNumber: "",
1233
+			IsEdit:                  0,
1234
+			CancelStockId:           0,
1235
+			CancelOrderNumber:       "",
1236
+			Manufacturer:            manufacturer.ID,
1237
+			Dealer:                  0,
1238
+			Creator:                 this.GetAdminUserInfo().AdminUser.Id,
1239
+			UpdateCreator:           0,
1240
+			Status:                  1,
1241
+			Ctime:                   time.Now().Unix(),
1242
+			Mtime:                   0,
1243
+			Price:                   drugWarehouseInfoOne.Price,
1244
+			WarehousingDetailId:     id,
1245
+			WarehouseOutDetailId:    0,
1246
+			CancelOutDetailId:       0,
1247
+			ExpireDate:              drugWarehouseInfoOne.ExpiryDate,
1248
+			ProductDate:             0,
1249
+			MaxUnit:                 drugWarehouseInfoOne.MaxUnit,
1250
+			MinUnit:                 drugWarehouseInfoOne.MinUnit,
1251
+			StorehouseId:            storehouse_id,
1252
+			OverCount:               sum_count,
1253
+		}
1254
+		service.CreateDrugFlowOne(flow)
1255
+
1256
+		//添加出库数据
1257
+		service.AddDrugWarehouseOut(drug_id, consumable_count, storehouse_id, orgId)
1258
+
1259
+	}
1260
+
1261
+	//盘盈
1262
+	if ord_total < new_total {
1263
+
1264
+		consumable_count = new_total - ord_total
1265
+
1266
+		inventory := models.XtDrugInventory{
1267
+			DrugName:           base.DrugName,
1268
+			SpecificationName:  specification_name,
1269
+			WarehousingUnit:    drugWarehouseInfoOne.MaxUnit,
1270
+			Count:              consumable_count,
1271
+			LastPrice:          drugWarehouseInfoOne.Price,
1272
+			RetailPrice:        drugWarehouseInfoOne.RetailPrice,
1273
+			NewPrice:           0,
1274
+			Manufacturer:       manufacturer.ManufacturerName,
1275
+			Dealer:             "",
1276
+			Remark:             "",
1277
+			DrugId:             drug_id,
1278
+			UserOrgId:          orgId,
1279
+			Ctime:              time.Now().Unix(),
1280
+			Mtime:              0,
1281
+			Status:             1,
1282
+			WarehousingOrder:   drugWarehouseInfoOne.WarehousingOrder,
1283
+			LicenseNumber:      "",
1284
+			StartTime:          recordDate.Unix(),
1285
+			Creater:            this.GetAdminUserInfo().AdminUser.Id,
1286
+			Checker:            0,
1287
+			CheckerStatus:      0,
1288
+			CheckerTime:        0,
1289
+			ExpiryDate:         drugWarehouseInfoOne.ExpiryDate,
1290
+			ProductDate:        drugWarehouseInfoOne.ProductDate,
1291
+			Number:             "",
1292
+			BatchNumber:        drugWarehouseInfoOne.BatchNumber,
1293
+			Total:              "",
1294
+			DrugOriginPlace:    "",
1295
+			WarehouseInfoId:    id,
1296
+			ProofCount:         0,
1297
+			StockMaxNumber:     stock_max_number,
1298
+			StockMinNumber:     stock_min_number,
1299
+			MinCount:           0,
1300
+			MinUnit:            drugWarehouseInfoOne.MinUnit,
1301
+			LastStockMaxNumber: last_stock_max_number,
1302
+			LastStockMinNumber: last_stock_min_number,
1303
+			InventoryType:      10,
1304
+			Type:               is_type,
1305
+			StorehouseId:       storehouse_id,
1306
+			RecordDate:         recordDate.Unix(),
1307
+		}
1308
+
1309
+		service.CreateDrugInventory(inventory)
1310
+
1311
+		flow := models.DrugFlow{
1312
+			WarehousingId:           id,
1313
+			DrugId:                  drug_id,
1314
+			Number:                  "",
1315
+			BatchNumber:             drugWarehouseInfoOne.BatchNumber,
1316
+			Count:                   consumable_count,
1317
+			UserOrgId:               orgId,
1318
+			PatientId:               0,
1319
+			SystemTime:              recordDate.Unix(),
1320
+			ConsumableType:          10,
1321
+			IsSys:                   1,
1322
+			WarehousingOrder:        drugWarehouseInfoOne.WarehousingOrder,
1323
+			WarehouseOutId:          0,
1324
+			WarehouseOutOrderNumber: "",
1325
+			IsEdit:                  0,
1326
+			CancelStockId:           0,
1327
+			CancelOrderNumber:       "",
1328
+			Manufacturer:            manufacturer.ID,
1329
+			Dealer:                  0,
1330
+			Creator:                 this.GetAdminUserInfo().AdminUser.Id,
1331
+			UpdateCreator:           0,
1332
+			Status:                  1,
1333
+			Ctime:                   time.Now().Unix(),
1334
+			Mtime:                   0,
1335
+			Price:                   drugWarehouseInfoOne.Price,
1336
+			WarehousingDetailId:     id,
1337
+			WarehouseOutDetailId:    0,
1338
+			CancelOutDetailId:       0,
1339
+			ExpireDate:              drugWarehouseInfoOne.ExpiryDate,
1340
+			ProductDate:             0,
1341
+			MaxUnit:                 drugWarehouseInfoOne.MaxUnit,
1342
+			MinUnit:                 drugWarehouseInfoOne.MinUnit,
1343
+			StorehouseId:            storehouse_id,
1344
+			OverCount:               sum_count,
1345
+		}
1346
+		service.CreateDrugFlowOne(flow)
1347
+
1348
+		//减少出库数据
1349
+		service.ReduceDrugWarehouseOut(drug_id, consumable_count, storehouse_id, orgId)
1350
+	}
1087 1351
 
1088 1352
 	this.ServeSuccessJSON(map[string]interface{}{
1089
-		"drugList": drugList,
1353
+		"msg": "msg",
1090 1354
 	})
1091 1355
 }

+ 1 - 1
controllers/self_drug_api_congtroller.go Vedi File

@@ -1802,7 +1802,7 @@ func (this *SelfDrugApiController) SaveDrugInventory() {
1802 1802
 	fmt.Println(err)
1803 1803
 
1804 1804
 	tableData, _ := dataBody["tableData"].([]interface{})
1805
-	fmt.Println("999939433443", tableData)
1805
+
1806 1806
 	if len(tableData) > 0 {
1807 1807
 		for _, item := range tableData {
1808 1808
 			items := item.(map[string]interface{})

+ 1 - 0
controllers/stock_in_api_controller.go Vedi File

@@ -7717,6 +7717,7 @@ func (this *StockManagerApiController) CheckWarehouseInfo() {
7717 7717
 				BatchNumberCount:        item.WarehousingCount,
7718 7718
 				IsCheck:                 1,
7719 7719
 				OverCount:               flush_count,
7720
+				OperateTime:             time.Now().Unix(),
7720 7721
 			}
7721 7722
 			//创建出库流水
7722 7723
 			service.CreateStockFlowOne(stockFlow)

+ 23 - 0
models/drug.go Vedi File

@@ -111,6 +111,29 @@ func (BaseDrugLibSeven) TableName() string {
111 111
 	return "xt_base_drug"
112 112
 }
113 113
 
114
+type BaseDrugLibTwentyOne struct {
115
+	ID           int64   `gorm:"column:id" json:"id" form:"id"`
116
+	DrugName     string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
117
+	MaxUnit      string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
118
+	MinUnit      string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
119
+	RetailPrice  float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
120
+	LastPrice    float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
121
+	DrugDose     float64 `gorm:"column:drug_dose" json:"drug_dose" form:"drug_dose"`
122
+	DrugDoseUnit int64   `gorm:"column:drug_dose_unit" json:"drug_dose_unit" form:"drug_dose_unit"`
123
+	Manufacturer int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
124
+	Status       int64   `gorm:"column:status" json:"status" form:"status"`
125
+	OrgId        int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
126
+	MinNumber    int64   `gorm:"column:min_number" json:"min_number" form:"min_number"`
127
+	Dose         string  `gorm:"column:dose" json:"dose" form:"dose"`
128
+	DoseUnit     string  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
129
+	DrugDay      string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
130
+	MinPrice     float64 `gorm:"column:min_price" json:"min_price" form:"min_price"`
131
+}
132
+
133
+func (BaseDrugLibTwentyOne) TableName() string {
134
+	return "xt_base_drug"
135
+}
136
+
114 137
 type BaseDrugLibEleven struct {
115 138
 	ID               int64  `gorm:"column:id" json:"id" form:"id"`
116 139
 	DrugName         string `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`

+ 1 - 0
models/self_drug_models.go Vedi File

@@ -888,6 +888,7 @@ type XtDrugInventory struct {
888 888
 	StorehouseId       int64             `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
889 889
 	BaseDrugLib        BaseDrugLib       `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId"json:"drug" `
890 890
 	DrugWarehouseInfo  DrugWarehouseInfo `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseInfoId"json:"drug_warehouse_info" `
891
+	RecordDate         int64             `gorm:"column:record_date" json:"record_date" form:"record_date"`
891 892
 }
892 893
 
893 894
 func (XtDrugInventory) TableName() string {

+ 9 - 0
service/his_service.go Vedi File

@@ -3432,3 +3432,12 @@ func GetBaseGoodById(good_id int64, user_org_id int64) (models.GoodInfo, error)
3432 3432
 
3433 3433
 	return info, err
3434 3434
 }
3435
+
3436
+func GetBasedrugByIdOne(drug_id int64, user_org_id int64) (models.BaseDrugLib, error) {
3437
+
3438
+	lib := models.BaseDrugLib{}
3439
+
3440
+	err := XTReadDB().Where("id = ? and org_id =? and status=1", drug_id, user_org_id).Find(&lib).Error
3441
+
3442
+	return lib, err
3443
+}

+ 11 - 2
service/new_stock_service.go Vedi File

@@ -634,9 +634,18 @@ func AddGoodNewCancelSumCountOne(storehouse_id int64, good_id int64, user_org_id
634 634
 	return err
635 635
 }
636 636
 
637
-func GetDrugNewInventoryList(org_id int64) (drug []*models.BaseDrugLibTwentyOne, err error) {
637
+func GetDrugNewInventoryList(org_id int64, keyword string) (drug []*models.BaseDrugLibTwentyOne, err error) {
638 638
 
639
-	err = XTReadDB().Where("org_id = ? and status =1", org_id).Find(&drug).Error
639
+	likeKey := "%" + keyword + "%"
640
+
641
+	db := XTReadDB().Where("status=1")
642
+	if org_id > 0 {
643
+		db = db.Where("org_id = ?", org_id)
644
+	}
645
+	if len(keyword) > 0 {
646
+		db = db.Where("drug_name like ?", likeKey)
647
+	}
648
+	err = db.Order("id desc").Find(&drug).Error
640 649
 
641 650
 	return drug, err
642 651
 }

+ 30 - 0
service/new_warehouse_service.go Vedi File

@@ -5250,3 +5250,33 @@ func ReduceNewGoodCountTwo(good_id int64, org_id int64, storehouse_id int64, out
5250 5250
 	}
5251 5251
 	return err
5252 5252
 }
5253
+
5254
+func AddDrugWarehouseOut(drug_id int64, total_count int64, storehouse_id int64, user_org_id int64) error {
5255
+
5256
+	ut := XTWriteDB().Begin()
5257
+
5258
+	err = ut.Model(&models.XtDrugStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id  = ? and drug_id =?", storehouse_id, user_org_id, drug_id).UpdateColumn("sum_out_count", gorm.Expr("sum_out_count + ?", total_count)).Error
5259
+
5260
+	err = ut.Model(&models.XtDrugStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id  = ? and drug_id =?", storehouse_id, user_org_id, drug_id).UpdateColumn("sum_act_out_count", gorm.Expr("sum_act_out_count + ?", total_count)).Error
5261
+	if err != nil {
5262
+		ut.Rollback()
5263
+		return err
5264
+	}
5265
+	ut.Commit()
5266
+	return err
5267
+}
5268
+
5269
+func ReduceDrugWarehouseOut(drug_id int64, total_count int64, storehouse_id int64, user_org_id int64) error {
5270
+
5271
+	ut := XTWriteDB().Begin()
5272
+
5273
+	err = ut.Model(&models.XtDrugStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id  = ? and drug_id =?", storehouse_id, user_org_id, drug_id).UpdateColumn("sum_out_count", gorm.Expr("sum_out_count - ?", total_count)).Error
5274
+
5275
+	err = ut.Model(&models.XtDrugStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id  = ? and drug_id =?", storehouse_id, user_org_id, drug_id).UpdateColumn("sum_act_out_count", gorm.Expr("sum_act_out_count - ?", total_count)).Error
5276
+	if err != nil {
5277
+		ut.Rollback()
5278
+		return err
5279
+	}
5280
+	ut.Commit()
5281
+	return err
5282
+}

+ 35 - 1
service/stock_service.go Vedi File

@@ -4770,7 +4770,7 @@ func GetOutExprotList(orgid int64, ids []string, startime int64, endtime int64)
4770 4770
 		db = db.Where("x.ctime<=?", endtime)
4771 4771
 	}
4772 4772
 
4773
-	err = db.Select("x.id,x.warehouse_out_id,x.good_id,x.good_type_id,x.warehousing_out_target,x.count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.number,x.license_number,t.good_name,t.specification_name,t.min_number,t.packing_price,t.min_unit,t.packing_unit,x.manufacturer,x.dealer,p.warehouse_out_time").Joins("left join xt_warehouse_out as p on p.id =x.warehouse_out_id").Joins("left join xt_good_information as t on t.id = x.good_id").Scan(&out).Error
4773
+	err = db.Select("x.id,x.warehouse_out_id,x.good_id,x.good_type_id,x.warehousing_out_target,x.count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.remark,x.number,x.license_number,x.warehouse_out_order_number,t.good_name,t.specification_name,t.min_number,t.packing_price,t.min_unit,t.packing_unit,x.manufacturer,x.dealer,p.warehouse_out_time").Joins("left join xt_warehouse_out as p on p.id =x.warehouse_out_id").Joins("left join xt_good_information as t on t.id = x.good_id").Scan(&out).Error
4774 4774
 	return out, err
4775 4775
 
4776 4776
 }
@@ -5846,6 +5846,15 @@ func GetDrugWarehouseInfo(id int64) (models.XtDrugWarehouseInfo, error) {
5846 5846
 	return info, err
5847 5847
 }
5848 5848
 
5849
+func GetDrugWarehouseInfoOne(id int64) (models.XtDrugWarehouseInfo, error) {
5850
+
5851
+	info := models.XtDrugWarehouseInfo{}
5852
+
5853
+	err := XTReadDB().Where("status = 1 and id=?", id).Find(&info).Error
5854
+
5855
+	return info, err
5856
+}
5857
+
5849 5858
 //func GetDrugWarehouseInfoTX(id int64,tx *gorm.DB) (models.XtDrugWarehouseInfo, error) {
5850 5859
 //	info := models.XtDrugWarehouseInfo{}
5851 5860
 //	db := tx.Model(&info).Where("status = 1")
@@ -7327,6 +7336,17 @@ func UpdateMedicalSumCount(drug_id int64, sum_count int64, sum_in_count int64, o
7327 7336
 	return err
7328 7337
 }
7329 7338
 
7339
+func UpdateMedicalSumCountOne(drug_id int64, sum_count int64, orgid int64) error {
7340
+	tx := XTWriteDB().Begin()
7341
+	err := tx.Model(&models.BaseDrugLib{}).Where("id = ? and org_id = ? and status = 1", drug_id, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
7342
+	if err != nil {
7343
+		tx.Rollback()
7344
+		return err
7345
+	}
7346
+	tx.Commit()
7347
+	return err
7348
+}
7349
+
7330 7350
 //func UpdateMedicalSumCountTX(drug_id int64, sum_count int64, sum_in_count int64, orgid int64,tx *gorm.DB) error {
7331 7351
 //	err := tx.Model(&models.BaseDrugLib{}).Where("id = ? and org_id = ? and status = 1", drug_id, orgid).Update(map[string]interface{}{"sum_count": sum_count, "sum_in_count": sum_in_count}).Error
7332 7352
 //	return err
@@ -9205,3 +9225,17 @@ func ModifyNewGoodWarehouseInfoStockMinNumber(count int64, goodid int64, orgid i
9205 9225
 	}
9206 9226
 	return err
9207 9227
 }
9228
+
9229
+func GetDrugInvetoryByDrugId(user_org_id int64, drug_id int64) (info []*models.XtDrugWarehouseInfo, err error) {
9230
+
9231
+	err = XTReadDB().Where("org_id = ? and drug_id = ? and status=1", user_org_id, drug_id).Preload("XtBaseDrug", "org_id = ? and status=1", user_org_id).Order("id desc").Find(&info).Error
9232
+
9233
+	return info, err
9234
+}
9235
+
9236
+func UpdateNewDrugWarehouseInfoById(id int64, last_stock_max_number int64, last_stock_min_number int64) error {
9237
+
9238
+	err := XTWriteDB().Model(&models.XtDrugWarehouseInfo{}).Where("id = ? and status =1", id).Updates(map[string]interface{}{"stock_max_number": last_stock_max_number, "stock_min_number": last_stock_min_number}).Error
9239
+
9240
+	return err
9241
+}