Browse Source

库存流水展示

XMLWAN 1 year ago
parent
commit
dd4771e381

+ 31 - 1
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -685,7 +685,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
685 685
 		privateDrugConfig, _ := service.GetDrugSetByUserOrgId(adminUserInfo.Org.Id)
686 686
 
687 687
 		storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.Org.Id)
688
-		fmt.Println("drugStockConfig.IsOpen32232323232", drugStockConfig.IsOpen)
688
+
689 689
 		if drugStockConfig.IsOpen == 1 {
690 690
 			if groupno > 0 {
691 691
 				advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
@@ -1241,9 +1241,38 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1241 1241
 								if config.IsOpen != 1 {
1242 1242
 									if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
1243 1243
 										service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1244
+										fmt.Println("处方1111111111111")
1245
+										if adminInfo.Org.Id == 3877 || adminInfo.Org.Id == 10265 {
1246
+											//查询该药品是否有出库记录
1247
+											flowMap, _ := service.GetDrugFLowByAdviceById(advice.DrugId, advice.PatientId, advice.UserOrgId, advice.AdviceDate)
1248
+											if len(flowMap) == 0 {
1249
+												service.UpdateHisAdviceById(advice.ID)
1250
+												c.ServeSuccessJSON(map[string]interface{}{
1251
+													"msg":    "6",
1252
+													"advice": advice,
1253
+													"ids":    ids,
1254
+												})
1255
+												return
1256
+											}
1257
+										}
1244 1258
 									}
1245 1259
 									if pharmacyConfig.IsOpen != 1 {
1260
+										fmt.Println("处方我33333333323")
1246 1261
 										service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1262
+										if adminInfo.Org.Id == 3877 || adminInfo.Org.Id == 10265 {
1263
+											//查询该药品是否有出库记录
1264
+											flowMap, _ := service.GetDrugFLowByAdviceById(advice.DrugId, advice.PatientId, advice.UserOrgId, advice.AdviceDate)
1265
+											fmt.Println("flowMap----------", flowMap)
1266
+											if len(flowMap) == 0 {
1267
+												service.UpdateHisAdviceById(advice.ID)
1268
+												c.ServeSuccessJSON(map[string]interface{}{
1269
+													"msg":    "6",
1270
+													"advice": advice,
1271
+													"ids":    ids,
1272
+												})
1273
+												return
1274
+											}
1275
+										}
1247 1276
 									}
1248 1277
 
1249 1278
 									//更新字典里面的库存
@@ -1263,6 +1292,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1263 1292
 							}
1264 1293
 						}
1265 1294
 					}
1295
+
1266 1296
 					//
1267 1297
 					//if config.IsOpen == 1 && item.UserOrgId == 10088 {
1268 1298
 					//

+ 1 - 1
controllers/patient_api_controller.go View File

@@ -1323,7 +1323,7 @@ func (c *PatientApiController) CreateGroupAdvice() {
1323 1323
 			return
1324 1324
 		}
1325 1325
 		adviceName, _ := adviceNameM["advice_name"].(string)
1326
-		fmt.Println("adviceceNMAE--------------------------------", adviceName)
1326
+
1327 1327
 		if len(adviceName) == 0 {
1328 1328
 			utils.ErrorLog("len(advice_name) == 0")
1329 1329
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)

+ 12 - 0
service/warhouse_service.go View File

@@ -7475,3 +7475,15 @@ func UpdateAutomaticReduce(patient_id int64, record_date int64, good_id int64, p
7475 7475
 	err := XTWriteDB().Model(&models.AutomaticReduceDetail{}).Where("patient_id = ? and record_time =? and good_id = ? and project_id = ? and status = 1", patient_id, record_date, good_id, project_id).Update(map[string]interface{}{"status": 0}).Error
7476 7476
 	return err
7477 7477
 }
7478
+
7479
+func GetDrugFLowByAdviceById(drug_id int64, patient_id int64, user_org_id int64, advice_date int64) (outInfo []*models.DrugWarehouseOutInfo, err error) {
7480
+
7481
+	err = XTReadDB().Where("drug_id = ? and patient_id = ? and org_id = ? and sys_record_time = ? and status= 1", drug_id, patient_id, user_org_id, advice_date).Find(&outInfo).Error
7482
+	return outInfo, err
7483
+}
7484
+
7485
+func UpdateHisAdviceById(id int64) error {
7486
+
7487
+	err := XTWriteDB().Model(&models.HisDoctorAdviceInfo{}).Where("id = ?", id).Updates(map[string]interface{}{"execution_time": "", "execution_staff": "", "execution_state": 2}).Error
7488
+	return err
7489
+}