Sfoglia il codice sorgente

11月8日库存管理

XMLWAN 2 anni fa
parent
commit
8b285aeb6d

+ 1 - 1
conf/app.conf Vedi File

@@ -1,5 +1,5 @@
1 1
 appname = 血透
2
-httpport = 9529
2
+httpport = 9531
3 3
 runmode = dev
4 4
 
5 5
 #

File diff suppressed because it is too large
+ 1502 - 1398
controllers/drug_stock_api_contorller.go


+ 1 - 1
controllers/gobal_config_api_controller.go Vedi File

@@ -2245,7 +2245,7 @@ func (c *GobalConfigApiController) GetDrugOutOrderPrint() {
2245 2245
 	warehousing, _ := service.GetExportOutOrderDrugListOne(ids)
2246 2246
 
2247 2247
 	drug_warhouse_out, _ := service.GetDrugWarehouseOutTenty(ids, admin.CurrentOrgId)
2248
-
2248
+	fmt.Println("drug_warhouse_out9999999", drug_warhouse_out)
2249 2249
 	c.ServeSuccessJSON(map[string]interface{}{
2250 2250
 		"info":              info,
2251 2251
 		"warehousing":       warehousing,

+ 164 - 559
controllers/his_api_controller.go Vedi File

@@ -834,7 +834,7 @@ func (c *HisApiController) GetHisPrescriptionConfig() {
834 834
 	houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.CurrentOrgId)
835 835
 	if adminInfo.CurrentOrgId == 9675 || adminInfo.CurrentOrgId == 9671 || adminInfo.CurrentOrgId == 10215 {
836 836
 		//获取所有基础药
837
-		drugs, _ := service.GetAllDrugLibListSeven(adminInfo.CurrentOrgId, houseConfig.DrugStorehouseOut)
837
+		drugs, _ := service.GetAllDrugLibListSix(adminInfo.CurrentOrgId, houseConfig.DrugStorehouseOut)
838 838
 		_, config := service.FindHisStockPriceRecordByOrgId(adminInfo.CurrentOrgId)
839 839
 		if config.ID > 0 && config.IsOpen == 1 {
840 840
 			for _, item := range drugs {
@@ -978,7 +978,7 @@ func (c *HisApiController) CreateHisPrescription() {
978 978
 								var drug_id int64
979 979
 								var prescribing_number float64
980 980
 								var prescribingNumberUnit string
981
-								var prescribingNumber string
981
+								//var prescribingNumber string
982 982
 
983 983
 								var adviceId int64
984 984
 								if advice.(map[string]interface{})["id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["id"]).String() == "float64" {
@@ -987,7 +987,7 @@ func (c *HisApiController) CreateHisPrescription() {
987 987
 								if advice.(map[string]interface{})["prescribing_number"] != nil || reflect.TypeOf(advice.(map[string]interface{})["prescribing_number"]).String() == "string" {
988 988
 									prescribing_number_str := advice.(map[string]interface{})["prescribing_number"].(string)
989 989
 									prescribing_number, _ = strconv.ParseFloat(prescribing_number_str, 64)
990
-									prescribingNumber = advice.(map[string]interface{})["prescribing_number"].(string)
990
+									//prescribingNumber = advice.(map[string]interface{})["prescribing_number"].(string)
991 991
 								}
992 992
 
993 993
 								if advice.(map[string]interface{})["prescribing_number_unit"] != nil && reflect.TypeOf(advice.(map[string]interface{})["prescribing_number_unit"]).String() == "string" {
@@ -1003,8 +1003,10 @@ func (c *HisApiController) CreateHisPrescription() {
1003 1003
 									c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1004 1004
 									return
1005 1005
 								}
1006
+								//查询默认出库仓库库存
1007
+								storeConfig, _ := service.GetAllStoreHouseConfig(adminInfo.CurrentOrgId)
1006 1008
 								//查询药品的所有库存
1007
-								list, _ := service.GetDrugWarehouseInfoPrescriptionSeven(drug_id, adminInfo.CurrentOrgId)
1009
+								list, _ := service.GetDrugWarehouseInfoPrescriptionSeven(drug_id, adminInfo.CurrentOrgId, storeConfig.DrugStorehouseOut)
1008 1010
 								var total_count int64
1009 1011
 								for _, it := range list {
1010 1012
 									total_count += it.StockMaxNumber*drug.MinNumber + it.StockMinNumber
@@ -1012,7 +1014,7 @@ func (c *HisApiController) CreateHisPrescription() {
1012 1014
 								totals := strconv.FormatInt(total_count, 10)
1013 1015
 								//查询该药品是否存在开药记录
1014 1016
 								advicelist, _ := service.GetHisAdviceListByDrugIdEight(drug_id, patient_id, recordDateTime, adviceId)
1015
-
1017
+								fmt.Println("advicleise23223323233223w", advicelist.PrescribingNumber)
1016 1018
 								//新增处方
1017 1019
 								if advicelist.ID == 0 {
1018 1020
 									all_count, _ := strconv.ParseFloat(totals, 64)
@@ -1021,84 +1023,65 @@ func (c *HisApiController) CreateHisPrescription() {
1021 1023
 											c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
1022 1024
 											return
1023 1025
 										}
1024
-									} else {
1025
-										if prescribingNumberUnit == drug.MaxUnit {
1026
-											num := prescribing_number * float64(drug.MinNumber)
1027
-											if num > all_count {
1028
-												c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
1029
-												return
1030
-											}
1031
-										}
1032
-									}
1033
-								}
1034
-								//修改处方
1035
-								if advicelist.ID > 0 {
1036
-									var device_number int64
1037 1026
 
1038
-									if advicelist.PrescribingNumberUnit == drug.MaxUnit {
1039
-										prescribingNumberOne := strconv.FormatFloat(advicelist.PrescribingNumber, 'f', -1, 64)
1040
-										prescribingNumberInt, _ := strconv.ParseInt(prescribingNumberOne, 10, 64)
1041
-										device_number = prescribingNumberInt * drug.MinNumber
1042 1027
 									}
1043
-									if advicelist.PrescribingNumberUnit == drug.MinUnit {
1044
-										prescribingNumberOne := strconv.FormatFloat(advicelist.PrescribingNumber, 'f', -1, 64)
1045
-										prescribingNumberInt, _ := strconv.ParseInt(prescribingNumberOne, 10, 64)
1046
-										device_number = prescribingNumberInt
1047
-									}
1048
-
1049
-									var number_count int64
1050 1028
 									if prescribingNumberUnit == drug.MaxUnit {
1051
-										prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1052
-										number_count = prescribingNumberInt * drug.MinNumber
1053
-									}
1054
-									if prescribingNumberUnit == drug.MinUnit {
1055
-										prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1056
-										number_count = prescribingNumberInt
1057
-									}
1058
-
1059
-									//如果修改的数量大于之前修改的数量
1060
-									if (number_count - device_number) > 0 {
1061
-										//如果修改的差数量 大于库存数量
1062
-										if (number_count - device_number) > total_count {
1029
+										num := prescribing_number * float64(drug.MinNumber)
1030
+										if num > all_count {
1063 1031
 											c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
1064 1032
 											return
1065 1033
 										}
1066 1034
 									}
1067 1035
 
1068
-									if device_number != number_count {
1069
-
1070
-										// 查询该药品最后一次出库记录
1071
-										druginfo, _ := service.GetLastDrugWarehouseOutByDrugId(drug_id, patient_id, recordDateTime, adviceId)
1072
-
1073
-										//回退库存
1074
-										if druginfo.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
1075
-
1076
-											service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, number_count)
1077
-										}
1078
-										if druginfo.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
1079
-											var stock_max_number int64
1080
-											var stock_min_number int64
1081
-
1082
-											if number_count >= drug.MinNumber {
1083
-
1084
-												stock_max_number = device_number / drug.MinNumber
1085
-												service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, stock_max_number)
1086
-												stock_min_number = device_number % drug.MinNumber
1087
-												service.ModefyDrugByWarehouseInfoOne(druginfo.WarehouseInfoId, stock_min_number)
1088
-
1089
-											} else {
1090
-
1091
-												service.ModefyDrugByWarehouseInfoOne(druginfo.WarehouseInfoId, device_number)
1092
-											}
1093
-										}
1094
-
1095
-										if druginfo.CountUnit == drug.MaxUnit && druginfo.CountUnit == drug.MinUnit && drug.MaxUnit == drug.MinUnit {
1096
-											service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, device_number)
1097
-										}
1098
-										//删除记录
1099
-										service.DeleteDrugAutoWarehouseSeven(drug_id, patient_id, recordDateTime, adviceId)
1100
-									}
1101 1036
 								}
1037
+								//修改处方
1038
+								//if advicelist.ID > 0 {
1039
+								//all_count, _ := strconv.ParseFloat(totals, 64) //总库存
1040
+								//var  his_count int64 //历史出库数据
1041
+								//if(advicelist.PrescribingNumberUnit == drug.MaxUnit){
1042
+								//  strPrescribingNumber := strconv.FormatFloat(advicelist.PrescribingNumber, 'E', -1, 64)
1043
+								//  intPrescribingNumber, _ := strconv.ParseInt(strPrescribingNumber, 10, 64)
1044
+								//  his_count = intPrescribingNumber * drug.MinNumber
1045
+								//}
1046
+								//if(advicelist.PrescribingNumberUnit == drug.MinUnit){
1047
+								//  strPrescribingNumber := strconv.FormatFloat(advicelist.PrescribingNumber, 'E', -1, 64)
1048
+								//  intPrescribingNumber, _ := strconv.ParseInt(strPrescribingNumber, 10, 64)
1049
+								//  his_count = intPrescribingNumber
1050
+								//}
1051
+								//
1052
+								//
1053
+								// if prescribingNumberUnit == drug.MinUnit {
1054
+								//
1055
+								//   float_prescribing_number := strconv.FormatFloat(prescribing_number, 'f', -1, 64)
1056
+								//   int_prescribing_number, _ := strconv.ParseInt(float_prescribing_number, 10, 64)
1057
+								//   float_all_count := strconv.FormatFloat(all_count, 'f', -1, 64)
1058
+								//   int_all_count, _ := strconv.ParseInt(float_all_count, 10, 64)
1059
+								//
1060
+								//   fmt.Println("总库存我的",int_all_count)
1061
+								//   fmt.Println("现在出库库存",int_prescribing_number)
1062
+								//   fmt.Println("历史出库数据",his_count)
1063
+								//   if (int_prescribing_number - his_count) > int_all_count {
1064
+								//     c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
1065
+								//     return
1066
+								//   }
1067
+								//
1068
+								// }
1069
+								// if prescribingNumberUnit == drug.MaxUnit {
1070
+								//   float_all_count := strconv.FormatFloat(all_count, 'f', -1, 64)
1071
+								//   int_all_count, _ := strconv.ParseInt(float_all_count, 10, 64)
1072
+								//   num := prescribing_number * float64(drug.MinNumber)
1073
+								//   num_str_count := strconv.FormatFloat(num, 'f', -1, 64)
1074
+								//   num_int_count, _ := strconv.ParseInt(num_str_count, 10, 64)
1075
+								//   fmt.Println("总库存我的",int_all_count)
1076
+								//   fmt.Println("现在出库库存",num_str_count)
1077
+								//   fmt.Println("历史出库数据",his_count)
1078
+								//   if (num_int_count - his_count)  > int_all_count {
1079
+								//     c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
1080
+								//     return
1081
+								//   }
1082
+								// }
1083
+								//}
1084
+
1102 1085
 							}
1103 1086
 						}
1104 1087
 					}
@@ -1151,10 +1134,6 @@ func (c *HisApiController) CreateHisPrescription() {
1151 1134
 
1152 1135
 									//查找该耗材的出库记录
1153 1136
 									goodWarehouseInfo, _ := service.GetAutoRecordByGoodIdSevenEight(project_id, patient_id, recordDateTime)
1154
-									//var total_count int64
1155
-									//for _, it := range goodWarehouseInfo {
1156
-									//	total_count += it.Count
1157
-									//}
1158 1137
 
1159 1138
 									if len(goodWarehouseInfo) == 0 {
1160 1139
 										//查询耗材库存
@@ -1401,6 +1380,7 @@ func (c *HisApiController) CreateHisPrescription() {
1401 1380
 				//更改患者挂号状态
1402 1381
 				_, err2 := service.UpdateHisPatientIsReturn(patient_id, recordDateTime, adminInfo.CurrentOrgId)
1403 1382
 				fmt.Println("更改失败", err2)
1383
+
1404 1384
 				if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
1405 1385
 					advices := items["advices"].([]interface{})
1406 1386
 					//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
@@ -1434,6 +1414,23 @@ func (c *HisApiController) CreateHisPrescription() {
1434 1414
 							}
1435 1415
 
1436 1416
 							s.StartTime = pTime
1417
+							var total_count int64 //处方总库存
1418
+							//查询改药品信息
1419
+							medical, _ := service.GetBaseDrugMedical(s.DrugId)
1420
+							prescribingNumberSix := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
1421
+							prescribingNumberSeven, _ := strconv.ParseInt(prescribingNumberSix, 10, 64)
1422
+
1423
+							if s.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
1424
+								total_count += prescribingNumberSeven * medical.MinNumber
1425
+							}
1426
+
1427
+							if s.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
1428
+								total_count += prescribingNumberSeven
1429
+							}
1430
+
1431
+							if s.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
1432
+								total_count += prescribingNumberSeven
1433
+							}
1437 1434
 							service.CreateHisDoctorAdvice(&s)
1438 1435
 
1439 1436
 							//存储切片中
@@ -1460,8 +1457,10 @@ func (c *HisApiController) CreateHisPrescription() {
1460 1457
 							keyEight := "scheduals_" + record_date + "_" + strconv.FormatInt(adminInfo.CurrentOrgId, 10)
1461 1458
 							redis.Set(keyEight, "", time.Second)
1462 1459
 							defer redis.Close()
1460
+
1463 1461
 						}
1464 1462
 					}
1463
+
1465 1464
 				}
1466 1465
 				if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
1467 1466
 					projects := items["project"].([]interface{})
@@ -1593,6 +1592,54 @@ func (c *HisApiController) CreateHisPrescription() {
1593 1592
 				//}
1594 1593
 
1595 1594
 			}
1595
+
1596
+		}
1597
+
1598
+		//查询今日该患者开的药品处方
1599
+		hisdoctorlist, _ := service.GetHisAdviceListByDrugIdTwo(patient_id, recordDateTime, adminInfo.CurrentOrgId)
1600
+		storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.CurrentOrgId)
1601
+		drugOutConfig, _ := service.GetDrugOpenConfigOne(adminInfo.CurrentOrgId)
1602
+		for _, item := range hisdoctorlist {
1603
+			drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, item.DrugId)
1604
+
1605
+			// 查询该药品最后一次出库记录
1606
+			druginfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(item.DrugId, patient_id, recordDateTime, item.ID)
1607
+			fmt.Println("drugiNfo23323233232323233223", len(druginfo))
1608
+
1609
+			if len(druginfo) > 0 {
1610
+				//回退库存
1611
+				for _, it := range druginfo {
1612
+					fmt.Println("it", it.Count)
1613
+					fmt.Println("countuntit", it.CountUnit)
1614
+					if it.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
1615
+						service.ModifyDrugWarehouseInfoStockMaxNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId)
1616
+					}
1617
+					if it.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
1618
+						service.ModifyDrugWarehouseInfoStockMinNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId)
1619
+					}
1620
+					if it.CountUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
1621
+						service.ModifyDrugWarehouseInfoStockMaxNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId)
1622
+					}
1623
+				}
1624
+			}
1625
+
1626
+			//删除记录
1627
+			service.DeleteDrugAutoWarehouseSeven(item.DrugId, patient_id, recordDateTime, item.ID)
1628
+			if drugOutConfig.IsOpen == 1 {
1629
+				//出库
1630
+				if drug.IsUse == 2 {
1631
+					creater := adminInfo.AdminUser.Id
1632
+					service.HisDrugsDelivery(item.UserOrgId, creater, item)
1633
+				}
1634
+
1635
+				//更新字典里面的库存
1636
+				stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1637
+				var sum_count int64
1638
+				for _, its := range stockInfo {
1639
+					sum_count += its.StockMaxNumber*drug.MinNumber + its.StockMinNumber
1640
+				}
1641
+				service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
1642
+			}
1596 1643
 		}
1597 1644
 	}
1598 1645
 
@@ -1926,6 +1973,7 @@ func (c *HisApiController) DeletePrescription() {
1926 1973
 						ReturnTime:   item.RecordDate,
1927 1974
 						Type:         1,
1928 1975
 						StorehouseId: houseConfig.StorehouseOutInfo,
1976
+						IsCheck:      1,
1929 1977
 					}
1930 1978
 					_, msgerrkonde := service.GetCancelStockDetailByOrderNumberOne(item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
1931 1979
 					if msgerrkonde == gorm.ErrRecordNotFound {
@@ -1962,6 +2010,7 @@ func (c *HisApiController) DeletePrescription() {
1962 2010
 							PatientId:       info.PatientId,
1963 2011
 							RecordDate:      info.SysRecordTime,
1964 2012
 							StorehouseId:    houseConfig.StorehouseOutInfo,
2013
+							IsCheck:         1,
1965 2014
 						}
1966 2015
 
1967 2016
 						service.CreateCancelStockInfoOne(&cancelStockInfo)
@@ -2052,6 +2101,7 @@ func (c *HisApiController) DeletePrescription() {
2052 2101
 									Type:                    1,
2053 2102
 									IsSys:                   1,
2054 2103
 									StorehouseId:            houseConfig.StorehouseOutInfo,
2104
+									IsCheck:                 1,
2055 2105
 								}
2056 2106
 								err := service.AddSigleWarehouseOut(&warehouseOut)
2057 2107
 								if err != nil {
@@ -2095,262 +2145,24 @@ func (c *HisApiController) DeletePrescription() {
2095 2145
 		err := service.DelelteHisPrescription(prescription_id, c.GetAdminUserInfo().CurrentOrgId)
2096 2146
 		fmt.Println(err)
2097 2147
 	}
2148
+	err := service.DelelteHisPrescription(prescription_id, c.GetAdminUserInfo().CurrentOrgId)
2149
+	fmt.Println(err)
2150
+	if len(advices) > 0 {
2151
+		for _, item := range advices {
2152
+			redis := service.RedisClient()
2153
+			keyFive := strconv.FormatInt(item.UserOrgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
2154
+			redis.Set(keyFive, "", time.Second)
2155
+			keyOne := strconv.FormatInt(item.UserOrgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
2156
+			redis.Set(keyOne, "", time.Second)
2157
+			redis.Close()
2098 2158
 
2159
+		}
2160
+	}
2099 2161
 	if drugStockConfig.IsOpen == 1 {
2100
-		err := service.DelelteHisPrescription(prescription_id, c.GetAdminUserInfo().CurrentOrgId)
2101
-		fmt.Println(err)
2102 2162
 		if len(advices) > 0 {
2103
-
2104 2163
 			for _, item := range advices {
2105
-				drug, _ := service.FindBaseDrugLibRecord(c.GetAdminUserInfo().CurrentOrgId, item.DrugId)
2106
-				redis := service.RedisClient()
2107
-
2108
-				keyFive := strconv.FormatInt(item.UserOrgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
2109
-				redis.Set(keyFive, "", time.Second)
2110
-				keyOne := strconv.FormatInt(item.UserOrgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
2111
-				redis.Set(keyOne, "", time.Second)
2112
-				redis.Close()
2113
-
2114
-				//查询该药品是否存在出库记录
2115
-				info, errcode := service.GetDrugAutoWarehouseOutSeven(item.PatientId, item.AdviceDate, item.DrugId, item.ID)
2116
-
2117
-				if errcode == gorm.ErrRecordNotFound {
2118
-
2119
-				} else if errcode == nil {
2120
-					if item.PrescribingNumberUnit == drug.MinUnit {
2121
-
2122
-						floatPrescrip := strconv.FormatFloat(item.PrescribingNumber, 'f', -1, 32)
2123
-						prescribingNumber, _ := strconv.ParseInt(floatPrescrip, 10, 64)
2124
-
2125
-						//退库
2126
-						warehouseInfo := models.DrugWarehouseInfo{
2127
-							StockMinNumber: prescribingNumber,
2128
-						}
2129
-
2130
-						service.UpdateDrugWarehouse(info.WarehouseInfoId, warehouseInfo)
2131
-
2132
-						adminUserInfo := c.GetAdminUserInfo()
2133
-						operation_time := time.Now().Unix()
2134
-						creater := adminUserInfo.AdminUser.Id
2135
-
2136
-						ctime := time.Now().Unix()
2137
-						timeStr := time.Now().Format("2006-01-02")
2138
-						timeArr := strings.Split(timeStr, "-")
2139
-						total, _ := service.FindAllDrugCancelStockTotal(adminUserInfo.CurrentOrgId)
2140
-						total = total + 1
2141
-						orderNumber := "CKTKD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
2142
-						houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
2143
-						cancelStock := models.DrugCancelStock{
2144
-							OrderNumber:  orderNumber,
2145
-							OperaTime:    operation_time,
2146
-							OrgId:        adminUserInfo.CurrentOrgId,
2147
-							Creater:      creater,
2148
-							Ctime:        ctime,
2149
-							Status:       1,
2150
-							ReturnTime:   item.AdviceDate,
2151
-							Dealer:       info.Dealer,
2152
-							Manufacturer: info.Manufacturer,
2153
-							Type:         1,
2154
-							StorehouseId: houseConfig.DrugStorehouseOut,
2155
-						}
2156
-						service.AddSigleDrugCancelStock(&cancelStock)
2157
-
2158
-						manufactureName, _ := service.GetManufactureById(info.Manufacturer)
2159
-						dealer, _ := service.GetDealerById(info.Dealer)
2160
-						cancelInfo, _ := service.GetLastDrugCancelStockById(adminUserInfo.CurrentOrgId)
2161
-						cancelStockInfo := models.DrugCancelStockInfo{
2162
-							OrderNumber:      cancelInfo.OrderNumber,
2163
-							CancelStockId:    cancelInfo.ID,
2164
-							DrugId:           info.DrugId,
2165
-							Count:            prescribingNumber,
2166
-							Status:           1,
2167
-							Ctime:            ctime,
2168
-							OrgId:            adminUserInfo.CurrentOrgId,
2169
-							Type:             1,
2170
-							Manufacturer:     manufactureName.ManufacturerName,
2171
-							Dealer:           dealer.DealerName,
2172
-							Total:            0,
2173
-							RetailPrice:      info.RetailPrice,
2174
-							RetailTotalPrice: info.RetailTotalPrice,
2175
-							Price:            info.Price,
2176
-							RegisterAccount:  "",
2177
-							Remark:           info.Remark,
2178
-							BatchNumber:      info.BatchNumber,
2179
-							MaxUnit:          info.CountUnit,
2180
-							ProductDate:      info.ProductDate,
2181
-							ExpiryDate:       info.ExpiryDate,
2182
-							BatchNumberId:    info.WarehouseInfoId,
2183
-							StorehouseId:     houseConfig.DrugStorehouseOut,
2184
-						}
2185
-
2186
-						flow := models.DrugFlow{
2187
-							WarehousingId:           0,
2188
-							DrugId:                  info.DrugId,
2189
-							Number:                  "",
2190
-							BatchNumber:             info.BatchNumber,
2191
-							Count:                   prescribingNumber,
2192
-							UserOrgId:               adminUserInfo.CurrentOrgId,
2193
-							PatientId:               0,
2194
-							SystemTime:              info.SysRecordTime,
2195
-							ConsumableType:          7,
2196
-							IsSys:                   0,
2197
-							WarehousingOrder:        "",
2198
-							WarehouseOutId:          0,
2199
-							WarehouseOutOrderNumber: info.WarehouseOutOrderNumber,
2200
-							IsEdit:                  0,
2201
-							CancelStockId:           cancelStock.ID,
2202
-							CancelOrderNumber:       cancelStock.OrderNumber,
2203
-							Manufacturer:            info.Manufacturer,
2204
-							Dealer:                  info.Dealer,
2205
-							Creator:                 adminUserInfo.AdminUser.Id,
2206
-							UpdateCreator:           0,
2207
-							Status:                  1,
2208
-							Ctime:                   time.Now().Unix(),
2209
-							Mtime:                   0,
2210
-							Price:                   info.Price,
2211
-							WarehousingDetailId:     0,
2212
-							WarehouseOutDetailId:    0,
2213
-							CancelOutDetailId:       0,
2214
-							ExpireDate:              info.ExpiryDate,
2215
-							ProductDate:             info.ProductDate,
2216
-							MaxUnit:                 info.CountUnit,
2217
-							MinUnit:                 "",
2218
-							AdviceId:                info.AdviceId,
2219
-							StorehouseId:            houseConfig.DrugStorehouseOut,
2220
-						}
2221
-						service.CreatedCancelStock(cancelStockInfo)
2222
-						service.CreateDrugFlowOne(flow)
2223
-
2224
-						//删除出库记录
2225
-						service.UpdateDrugFlowSeven(info.PatientId, info.SysRecordTime, info.DrugId, item.ID)
2226
-						//删除流水
2227
-						service.UpdateDrugFlowTens(info.PatientId, info.WarehouseOutOrderNumber, info.DrugId, item.ID)
2228
-					} else {
2229
-						houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
2230
-						floatPrescrip := strconv.FormatFloat(item.PrescribingNumber, 'f', -1, 32)
2231
-
2232
-						prescribingNumber, _ := strconv.ParseInt(floatPrescrip, 10, 64)
2233
-
2234
-						if item.PrescribingNumberUnit == drug.MaxUnit {
2235
-							warehouseInfo := models.DrugWarehouseInfo{
2236
-								StockMaxNumber: prescribingNumber,
2237
-							}
2238
-							service.UpdateDrugWarehouseOne(info.WarehouseInfoId, warehouseInfo)
2239
-
2240
-						}
2241
-
2242
-						adminUserInfo := c.GetAdminUserInfo()
2243
-						operation_time := time.Now().Unix()
2244
-						creater := adminUserInfo.AdminUser.Id
2245
-
2246
-						ctime := time.Now().Unix()
2247
-						timeStr := time.Now().Format("2006-01-02")
2248
-						timeArr := strings.Split(timeStr, "-")
2249
-						total, _ := service.FindAllDrugCancelStockTotal(adminUserInfo.CurrentOrgId)
2250
-						total = total + 1
2251
-						orderNumber := "CKTKD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
2252
-
2253
-						cancelStock := models.DrugCancelStock{
2254
-							OrderNumber:  orderNumber,
2255
-							OperaTime:    operation_time,
2256
-							OrgId:        adminUserInfo.CurrentOrgId,
2257
-							Creater:      creater,
2258
-							Ctime:        ctime,
2259
-							Status:       1,
2260
-							ReturnTime:   item.AdviceDate,
2261
-							Dealer:       info.Dealer,
2262
-							Manufacturer: info.Manufacturer,
2263
-							Type:         1,
2264
-							StorehouseId: houseConfig.DrugStorehouseOut,
2265
-						}
2266
-						service.AddSigleDrugCancelStock(&cancelStock)
2267
-
2268
-						manufactureName, _ := service.GetManufactureById(info.Manufacturer)
2269
-						dealer, _ := service.GetDealerById(info.Dealer)
2270
-						cancelInfo, _ := service.GetLastDrugCancelStockById(adminUserInfo.CurrentOrgId)
2271
-						cancelStockInfo := models.DrugCancelStockInfo{
2272
-							OrderNumber:   cancelInfo.OrderNumber,
2273
-							CancelStockId: cancelInfo.ID,
2274
-							DrugId:        info.DrugId,
2275
-							//	Count:            info.Count,
2276
-							Count:            prescribingNumber,
2277
-							Status:           1,
2278
-							Ctime:            ctime,
2279
-							OrgId:            adminUserInfo.CurrentOrgId,
2280
-							Type:             1,
2281
-							Manufacturer:     manufactureName.ManufacturerName,
2282
-							Dealer:           dealer.DealerName,
2283
-							Total:            0,
2284
-							RetailPrice:      info.RetailPrice,
2285
-							RetailTotalPrice: info.RetailTotalPrice,
2286
-							Price:            info.Price,
2287
-							RegisterAccount:  "",
2288
-							Remark:           info.Remark,
2289
-							BatchNumber:      info.BatchNumber,
2290
-							MaxUnit:          info.CountUnit,
2291
-							ProductDate:      info.ProductDate,
2292
-							ExpiryDate:       info.ExpiryDate,
2293
-							BatchNumberId:    info.WarehouseInfoId,
2294
-							StorehouseId:     houseConfig.DrugStorehouseOut,
2295
-						}
2296
-
2297
-						flow := models.DrugFlow{
2298
-							WarehousingId: 0,
2299
-							DrugId:        info.DrugId,
2300
-							Number:        "",
2301
-							BatchNumber:   info.BatchNumber,
2302
-							//Count:                   info.Count,
2303
-							Count:                   prescribingNumber,
2304
-							UserOrgId:               adminUserInfo.CurrentOrgId,
2305
-							PatientId:               0,
2306
-							SystemTime:              info.SysRecordTime,
2307
-							ConsumableType:          7,
2308
-							IsSys:                   0,
2309
-							WarehousingOrder:        "",
2310
-							WarehouseOutId:          0,
2311
-							WarehouseOutOrderNumber: info.WarehouseOutOrderNumber,
2312
-							IsEdit:                  0,
2313
-							CancelStockId:           cancelStock.ID,
2314
-							CancelOrderNumber:       cancelStock.OrderNumber,
2315
-							Manufacturer:            info.Manufacturer,
2316
-							Dealer:                  info.Dealer,
2317
-							Creator:                 adminUserInfo.AdminUser.Id,
2318
-							UpdateCreator:           0,
2319
-							Status:                  1,
2320
-							Ctime:                   time.Now().Unix(),
2321
-							Mtime:                   0,
2322
-							Price:                   info.Price,
2323
-							WarehousingDetailId:     0,
2324
-							WarehouseOutDetailId:    0,
2325
-							CancelOutDetailId:       0,
2326
-							ExpireDate:              info.ExpiryDate,
2327
-							ProductDate:             info.ProductDate,
2328
-							MaxUnit:                 info.CountUnit,
2329
-							MinUnit:                 "",
2330
-							AdviceId:                info.AdviceId,
2331
-							StorehouseId:            houseConfig.DrugStorehouseOut,
2332
-						}
2333
-						service.CreatedCancelStock(cancelStockInfo)
2334
-						service.CreateDrugFlowOne(flow)
2335
-						//删除出库记录
2336
-						service.UpdateDrugFlowSeven(info.PatientId, info.SysRecordTime, info.DrugId, item.ID)
2337
-						//删除流水
2338
-						service.UpdateDrugFlowTens(info.PatientId, info.WarehouseOutOrderNumber, info.DrugId, item.ID)
2339
-
2340
-					}
2341
-				}
2342
-
2343
-				if item.PrescribingNumberUnit == drug.MinUnit {
2344
-					drug.Total = drug.Total + item.PrescribingNumber
2345
-					service.UpdateBaseDrugLib(&drug)
2346
-				} else {
2347
-					if item.PrescribingNumberUnit == drug.MaxUnit {
2348
-						item.PrescribingNumber = item.PrescribingNumber * float64(drug.MinNumber)
2349
-						drug.Total = drug.Total + item.PrescribingNumber
2350
-						service.UpdateBaseDrugLib(&drug)
2351
-					}
2352
-				}
2353
-
2164
+				creater := c.GetAdminUserInfo().AdminUser.Id
2165
+				service.DrugAutoAddCancelInfo(item, creater)
2354 2166
 			}
2355 2167
 		}
2356 2168
 	}
@@ -2377,238 +2189,24 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2377 2189
 	defer redis.Close()
2378 2190
 	if err == nil {
2379 2191
 		if drugStockConfig.IsOpen == 1 {
2380
-			//判断该医嘱是否执行了
2381
-			if advice.ExecutionState == 1 {
2382
-
2383
-				//查询该病人该药品是否有库存记录
2384
-				info, errcode := service.GetDrugAutoWarehouseOutSeven(advice.PatientId, advice.AdviceDate, advice.DrugId, advice.ID)
2385
-				if errcode == gorm.ErrRecordNotFound {
2386 2192
 
2387
-				} else {
2388
-					//退库
2389
-					drug, _ := service.FindBaseDrugLibRecord(c.GetAdminUserInfo().CurrentOrgId, advice.DrugId)
2390
-					if advice.PrescribingNumberUnit == drug.MinUnit {
2193
+			//查询是否在处方中出库
2194
+			openConfig, _ := service.GetDrugOpenConfig(c.GetAdminUserInfo().CurrentOrgId)
2195
+			if openConfig.IsOpen != 1 {
2391 2196
 
2392
-						floatPrescrip := strconv.FormatFloat(advice.PrescribingNumber, 'f', -1, 32)
2393
-						prescribingNumber, _ := strconv.ParseInt(floatPrescrip, 10, 64)
2394
-
2395
-						//退库
2396
-						warehouseInfo := models.DrugWarehouseInfo{
2397
-							StockMinNumber: prescribingNumber,
2398
-						}
2399
-
2400
-						service.UpdateDrugWarehouse(info.WarehouseInfoId, warehouseInfo)
2401
-
2402
-						adminUserInfo := c.GetAdminUserInfo()
2403
-						operation_time := time.Now().Unix()
2404
-						creater := adminUserInfo.AdminUser.Id
2405
-
2406
-						ctime := time.Now().Unix()
2407
-						timeStr := time.Now().Format("2006-01-02")
2408
-						timeArr := strings.Split(timeStr, "-")
2409
-						total, _ := service.FindAllDrugCancelStockTotal(adminUserInfo.CurrentOrgId)
2410
-						total = total + 1
2411
-						orderNumber := "CKTKD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
2412
-						houseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.CurrentOrgId)
2413
-						cancelStock := models.DrugCancelStock{
2414
-							OrderNumber:  orderNumber,
2415
-							OperaTime:    operation_time,
2416
-							OrgId:        adminUserInfo.CurrentOrgId,
2417
-							Creater:      creater,
2418
-							Ctime:        ctime,
2419
-							Status:       1,
2420
-							ReturnTime:   advice.AdviceDate,
2421
-							Dealer:       info.Dealer,
2422
-							Manufacturer: info.Manufacturer,
2423
-							Type:         1,
2424
-							StorehouseId: houseConfig.DrugStorehouseOut,
2425
-						}
2426
-						service.AddSigleDrugCancelStock(&cancelStock)
2427
-
2428
-						manufactureName, _ := service.GetManufactureById(info.Manufacturer)
2429
-						dealer, _ := service.GetDealerById(info.Dealer)
2430
-						cancelInfo, _ := service.GetLastDrugCancelStockById(adminUserInfo.CurrentOrgId)
2431
-						cancelStockInfo := models.DrugCancelStockInfo{
2432
-							OrderNumber:      cancelInfo.OrderNumber,
2433
-							CancelStockId:    cancelInfo.ID,
2434
-							DrugId:           info.DrugId,
2435
-							Count:            info.Count,
2436
-							Status:           1,
2437
-							Ctime:            ctime,
2438
-							OrgId:            adminUserInfo.CurrentOrgId,
2439
-							Type:             1,
2440
-							Manufacturer:     manufactureName.ManufacturerName,
2441
-							Dealer:           dealer.DealerName,
2442
-							Total:            0,
2443
-							RetailPrice:      info.RetailPrice,
2444
-							RetailTotalPrice: info.RetailTotalPrice,
2445
-							Price:            info.Price,
2446
-							RegisterAccount:  "",
2447
-							Remark:           info.Remark,
2448
-							BatchNumber:      info.BatchNumber,
2449
-							MaxUnit:          info.CountUnit,
2450
-							ProductDate:      info.ProductDate,
2451
-							ExpiryDate:       info.ExpiryDate,
2452
-							BatchNumberId:    info.WarehouseInfoId,
2453
-							StorehouseId:     houseConfig.DrugStorehouseOut,
2454
-						}
2455
-
2456
-						flow := models.DrugFlow{
2457
-							WarehousingId:           0,
2458
-							DrugId:                  info.DrugId,
2459
-							Number:                  "",
2460
-							BatchNumber:             info.BatchNumber,
2461
-							Count:                   info.Count,
2462
-							UserOrgId:               adminUserInfo.CurrentOrgId,
2463
-							PatientId:               0,
2464
-							SystemTime:              info.SysRecordTime,
2465
-							ConsumableType:          7,
2466
-							IsSys:                   0,
2467
-							WarehousingOrder:        "",
2468
-							WarehouseOutId:          0,
2469
-							WarehouseOutOrderNumber: info.WarehouseOutOrderNumber,
2470
-							IsEdit:                  0,
2471
-							CancelStockId:           cancelStock.ID,
2472
-							CancelOrderNumber:       cancelStock.OrderNumber,
2473
-							Manufacturer:            info.Manufacturer,
2474
-							Dealer:                  info.Dealer,
2475
-							Creator:                 adminUserInfo.AdminUser.Id,
2476
-							UpdateCreator:           0,
2477
-							Status:                  1,
2478
-							Ctime:                   time.Now().Unix(),
2479
-							Mtime:                   0,
2480
-							Price:                   info.Price,
2481
-							WarehousingDetailId:     0,
2482
-							WarehouseOutDetailId:    0,
2483
-							CancelOutDetailId:       0,
2484
-							ExpireDate:              info.ExpiryDate,
2485
-							ProductDate:             info.ProductDate,
2486
-							MaxUnit:                 info.CountUnit,
2487
-							MinUnit:                 "",
2488
-							AdviceId:                info.AdviceId,
2489
-							StorehouseId:            houseConfig.DrugStorehouseOut,
2490
-						}
2491
-						service.CreatedCancelStock(cancelStockInfo)
2492
-						service.CreateDrugFlowOne(flow)
2493
-
2494
-						//删除出库记录
2495
-						service.UpdateDrugFlowSeven(info.PatientId, info.SysRecordTime, info.DrugId, advice.ID)
2496
-						//删除流水
2497
-						service.UpdateDrugFlowTens(info.PatientId, info.WarehouseOutOrderNumber, info.DrugId, advice.ID)
2498
-					} else {
2499
-						adminUserInfo := c.GetAdminUserInfo()
2500
-						houseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.CurrentOrgId)
2501
-						floatPrescrip := strconv.FormatFloat(advice.PrescribingNumber, 'f', -1, 32)
2502
-
2503
-						prescribingNumber, _ := strconv.ParseInt(floatPrescrip, 10, 64)
2504
-
2505
-						if advice.PrescribingNumberUnit == drug.MaxUnit {
2506
-							warehouseInfo := models.DrugWarehouseInfo{
2507
-								StockMaxNumber: prescribingNumber,
2508
-							}
2509
-							service.UpdateDrugWarehouseOne(info.WarehouseInfoId, warehouseInfo)
2510
-
2511
-						}
2512
-
2513
-						operation_time := time.Now().Unix()
2514
-						creater := adminUserInfo.AdminUser.Id
2515
-
2516
-						ctime := time.Now().Unix()
2517
-						timeStr := time.Now().Format("2006-01-02")
2518
-						timeArr := strings.Split(timeStr, "-")
2519
-						total, _ := service.FindAllDrugCancelStockTotal(adminUserInfo.CurrentOrgId)
2520
-						total = total + 1
2521
-						orderNumber := "CKTKD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
2522
-
2523
-						cancelStock := models.DrugCancelStock{
2524
-							OrderNumber:  orderNumber,
2525
-							OperaTime:    operation_time,
2526
-							OrgId:        adminUserInfo.CurrentOrgId,
2527
-							Creater:      creater,
2528
-							Ctime:        ctime,
2529
-							Status:       1,
2530
-							ReturnTime:   advice.AdviceDate,
2531
-							Dealer:       info.Dealer,
2532
-							Manufacturer: info.Manufacturer,
2533
-							Type:         1,
2534
-							StorehouseId: houseConfig.DrugStorehouseOut,
2535
-						}
2536
-						service.AddSigleDrugCancelStock(&cancelStock)
2537
-
2538
-						manufactureName, _ := service.GetManufactureById(info.Manufacturer)
2539
-						dealer, _ := service.GetDealerById(info.Dealer)
2540
-						cancelInfo, _ := service.GetLastDrugCancelStockById(adminUserInfo.CurrentOrgId)
2541
-						cancelStockInfo := models.DrugCancelStockInfo{
2542
-							OrderNumber:      cancelInfo.OrderNumber,
2543
-							CancelStockId:    cancelInfo.ID,
2544
-							DrugId:           info.DrugId,
2545
-							Count:            info.Count,
2546
-							Status:           1,
2547
-							Ctime:            ctime,
2548
-							OrgId:            adminUserInfo.CurrentOrgId,
2549
-							Type:             1,
2550
-							Manufacturer:     manufactureName.ManufacturerName,
2551
-							Dealer:           dealer.DealerName,
2552
-							Total:            0,
2553
-							RetailPrice:      info.RetailPrice,
2554
-							RetailTotalPrice: info.RetailTotalPrice,
2555
-							Price:            info.Price,
2556
-							RegisterAccount:  "",
2557
-							Remark:           info.Remark,
2558
-							BatchNumber:      info.BatchNumber,
2559
-							MaxUnit:          info.CountUnit,
2560
-							ProductDate:      info.ProductDate,
2561
-							ExpiryDate:       info.ExpiryDate,
2562
-							BatchNumberId:    info.WarehouseInfoId,
2563
-							StorehouseId:     houseConfig.DrugStorehouseOut,
2564
-						}
2565
-
2566
-						flow := models.DrugFlow{
2567
-							WarehousingId:           0,
2568
-							DrugId:                  info.DrugId,
2569
-							Number:                  "",
2570
-							BatchNumber:             info.BatchNumber,
2571
-							Count:                   info.Count,
2572
-							UserOrgId:               adminUserInfo.CurrentOrgId,
2573
-							PatientId:               0,
2574
-							SystemTime:              info.SysRecordTime,
2575
-							ConsumableType:          7,
2576
-							IsSys:                   0,
2577
-							WarehousingOrder:        "",
2578
-							WarehouseOutId:          0,
2579
-							WarehouseOutOrderNumber: info.WarehouseOutOrderNumber,
2580
-							IsEdit:                  0,
2581
-							CancelStockId:           cancelStock.ID,
2582
-							CancelOrderNumber:       cancelStock.OrderNumber,
2583
-							Manufacturer:            info.Manufacturer,
2584
-							Dealer:                  info.Dealer,
2585
-							Creator:                 adminUserInfo.AdminUser.Id,
2586
-							UpdateCreator:           0,
2587
-							Status:                  1,
2588
-							Ctime:                   time.Now().Unix(),
2589
-							Mtime:                   0,
2590
-							Price:                   info.Price,
2591
-							WarehousingDetailId:     0,
2592
-							WarehouseOutDetailId:    0,
2593
-							CancelOutDetailId:       0,
2594
-							ExpireDate:              info.ExpiryDate,
2595
-							ProductDate:             info.ProductDate,
2596
-							MaxUnit:                 info.CountUnit,
2597
-							MinUnit:                 "",
2598
-							AdviceId:                info.AdviceId,
2599
-							StorehouseId:            houseConfig.DrugStorehouseOut,
2600
-						}
2601
-						service.CreatedCancelStock(cancelStockInfo)
2602
-						service.CreateDrugFlowOne(flow)
2603
-						//删除出库记录
2604
-						service.UpdateDrugFlowSeven(info.PatientId, info.SysRecordTime, info.DrugId, advice.ID)
2605
-						//删除流水
2606
-						service.UpdateDrugFlowTens(info.PatientId, info.WarehouseOutOrderNumber, info.DrugId, advice.ID)
2607
-
2608
-					}
2197
+				//判断该医嘱是否执行了
2198
+				if advice.ExecutionState == 1 {
2199
+					creater := c.GetAdminUserInfo().AdminUser.Id
2200
+					service.DrugAutoAddCancelInfo(&advice, creater)
2609 2201
 				}
2610 2202
 			}
2611 2203
 
2204
+			//开启保存处方扣减功能
2205
+			if openConfig.IsOpen == 1 {
2206
+				creater := c.GetAdminUserInfo().AdminUser.Id
2207
+				service.DrugAutoAddCancelInfo(&advice, creater)
2208
+
2209
+			}
2612 2210
 		}
2613 2211
 
2614 2212
 		c.ServeSuccessJSON(map[string]interface{}{
@@ -2638,12 +2236,11 @@ func (c *HisApiController) DeleteProject() {
2638 2236
 			err := service.DelelteProject(id, c.GetAdminUserInfo().CurrentOrgId)
2639 2237
 			fmt.Println(err)
2640 2238
 		}
2239
+
2641 2240
 		if project.Type == 3 {
2642 2241
 			houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
2643 2242
 			good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
2644 2243
 			f_count, _ := strconv.ParseFloat(project.Count, 64)
2645
-			good.Total = good.Total + f_count
2646
-			service.UpdateGoodInfo(&good)
2647 2244
 
2648 2245
 			operation_time := time.Now().Unix()
2649 2246
 			creater := adminInfo.AdminUser.Id
@@ -2823,6 +2420,14 @@ func (c *HisApiController) DeleteProject() {
2823 2420
 					}
2824 2421
 
2825 2422
 				}
2423
+
2424
+				stockList, _ := service.GetStockCountByGoodId(project.ProjectId, houseConfig.StorehouseOutInfo, project.UserOrgId)
2425
+				var total_count_one int64
2426
+				for _, it := range stockList {
2427
+					total_count_one += it.StockCount
2428
+				}
2429
+				//基础库插入数据
2430
+				service.UpdateGoodInfoSumCount(project.ProjectId, total_count_one, project.UserOrgId)
2826 2431
 			}
2827 2432
 			err := service.DelelteProject(id, c.GetAdminUserInfo().CurrentOrgId)
2828 2433
 			fmt.Println(err)

+ 1 - 1
controllers/mobile_api_controllers/check_weight_api_controller.go Vedi File

@@ -264,7 +264,7 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
264 264
 
265 265
 	template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
266 266
 
267
-	if template.TemplateId == 22 || template.TemplateId == 17 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 27 || template.TemplateId == 34 || template.TemplateId == 30 || template.TemplateId == 32 || template.TemplateId == 36 || template.TemplateId == 40 || template.TemplateId == 38 || template.TemplateId == 43 || template.TemplateId == 46 {
267
+	if template.TemplateId == 22 || template.TemplateId == 17 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 27 || template.TemplateId == 34 || template.TemplateId == 30 || template.TemplateId == 32 || template.TemplateId == 36 || template.TemplateId == 40 || template.TemplateId == 38 || template.TemplateId == 43 || template.TemplateId == 46 || template.TemplateId == 48 || adminUserInfo.Org.Id == 10345 {
268 268
 		dewater_amount = dewater_amount * 1000
269 269
 	}
270 270
 

+ 140 - 75
controllers/mobile_api_controllers/dialysis_api_controller.go Vedi File

@@ -4008,7 +4008,6 @@ func (c *DialysisAPIController) CreateConsumables() {
4008 4008
 
4009 4009
 		//查询是否有库存
4010 4010
 		for _, item := range dialysisBefor {
4011
-			fmt.Println("houseconfig233232323232232332323223233", houseConfig.StorehouseOutInfo)
4012 4011
 			_, err := service.FindFirstWarehousingInfoByStock(item.GoodId, item.GoodTypeId, houseConfig.StorehouseOutInfo)
4013 4012
 
4014 4013
 			if err == gorm.ErrRecordNotFound {
@@ -4031,8 +4030,6 @@ func (c *DialysisAPIController) CreateConsumables() {
4031 4030
 			}
4032 4031
 		}
4033 4032
 
4034
-		//fmt.Println("dialysisBefor9999999999999999999", dialysisBefor, active)
4035
-
4036 4033
 		//新增
4037 4034
 		if active == 1 && len(goods) > 0 {
4038 4035
 			for _, item := range dialysisBefor {
@@ -4053,15 +4050,25 @@ func (c *DialysisAPIController) CreateConsumables() {
4053 4050
 				service.DeleteDialysisBefor(adminUser.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4054 4051
 				err = service.CreateDialysisBeforePrepareOne(&dialyPrepareOne)
4055 4052
 				//查询默认仓库
4056
-				houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.Org.Id)
4057
-				goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.GoodId, adminUser.Org.Id)
4058
-				var sum_count int64
4059
-				var sum_in_count int64
4060
-				for _, it := range goodList {
4061
-					sum_count += it.StockCount
4062
-					sum_in_count += it.WarehousingCount
4053
+				//houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.Org.Id)
4054
+				//goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.GoodId, adminUser.Org.Id)
4055
+				//var sum_count int64
4056
+				//var sum_in_count int64
4057
+				//for _, it := range goodList {
4058
+				//	sum_count += it.StockCount
4059
+				//	sum_in_count += it.WarehousingCount
4060
+				//}
4061
+				//service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, adminUser.Org.Id)
4062
+				//查询默认仓库
4063
+				storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminUser.Org.Id)
4064
+				stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, adminUser.Org.Id)
4065
+				var total_count int64
4066
+				for _, it := range stockList {
4067
+					total_count += it.StockCount
4063 4068
 				}
4064
-				service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, adminUser.Org.Id)
4069
+				//基础库插入数据
4070
+				service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, adminUser.Org.Id)
4071
+
4065 4072
 			}
4066 4073
 			if err == nil {
4067 4074
 				c.ServeSuccessJSON(map[string]interface{}{
@@ -4153,15 +4160,24 @@ func (c *DialysisAPIController) CreateConsumables() {
4153 4160
 
4154 4161
 							service.CreateDialysisBeforePrepareOne(&prepare)
4155 4162
 							//查询默认仓库
4156
-							houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.Org.Id)
4157
-							goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.GoodId, adminUser.Org.Id)
4158
-							var sum_count int64
4159
-							var sum_in_count int64
4160
-							for _, it := range goodList {
4161
-								sum_count += it.StockCount
4162
-								sum_in_count += it.WarehousingCount
4163
+							//houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.Org.Id)
4164
+							//goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.GoodId, adminUser.Org.Id)
4165
+							//var sum_count int64
4166
+							//var sum_in_count int64
4167
+							//for _, it := range goodList {
4168
+							//	sum_count += it.StockCount
4169
+							//	sum_in_count += it.WarehousingCount
4170
+							//}
4171
+							//service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, adminUser.Org.Id)
4172
+
4173
+							storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminUser.Org.Id)
4174
+							stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, adminUser.Org.Id)
4175
+							var total_count int64
4176
+							for _, it := range stockList {
4177
+								total_count += it.StockCount
4163 4178
 							}
4164
-							service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, adminUser.Org.Id)
4179
+							//基础库插入数据
4180
+							service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, adminUser.Org.Id)
4165 4181
 						}
4166 4182
 					}
4167 4183
 
@@ -4189,15 +4205,23 @@ func (c *DialysisAPIController) CreateConsumables() {
4189 4205
 
4190 4206
 							service.CreateDialysisBeforePrepareOne(&prepare)
4191 4207
 							//查询默认仓库
4192
-							houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.Org.Id)
4193
-							goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.GoodId, adminUser.Org.Id)
4194
-							var sum_count int64
4195
-							var sum_in_count int64
4196
-							for _, it := range goodList {
4197
-								sum_count += it.StockCount
4198
-								sum_in_count += it.WarehousingCount
4208
+							//houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.Org.Id)
4209
+							//goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.GoodId, adminUser.Org.Id)
4210
+							//var sum_count int64
4211
+							//var sum_in_count int64
4212
+							//for _, it := range goodList {
4213
+							//	sum_count += it.StockCount
4214
+							//	sum_in_count += it.WarehousingCount
4215
+							//}
4216
+							//service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, adminUser.Org.Id)
4217
+							storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminUser.Org.Id)
4218
+							stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, adminUser.Org.Id)
4219
+							var total_count int64
4220
+							for _, it := range stockList {
4221
+								total_count += it.StockCount
4199 4222
 							}
4200
-							service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, adminUser.Org.Id)
4223
+							//基础库插入数据
4224
+							service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, adminUser.Org.Id)
4201 4225
 						}
4202 4226
 						if err != nil {
4203 4227
 							goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
@@ -4307,6 +4331,7 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
4307 4331
 				Type:                    1,
4308 4332
 				IsSys:                   1,
4309 4333
 				StorehouseId:            houseConfig.StorehouseOutInfo,
4334
+				IsCheck:                 1,
4310 4335
 			}
4311 4336
 			err := service.AddSigleWarehouseOut(&warehouseOut)
4312 4337
 			if err != nil {
@@ -4339,16 +4364,16 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
4339 4364
 					//清空准备表数据
4340 4365
 					service.DeleteDialysisBefor(adminInfo.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4341 4366
 					service.CreateDialysisBeforePrepareOne(&prepare)
4367
+
4342 4368
 					//查询默认仓库
4343
-					houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4344
-					goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.GoodId, adminInfo.Org.Id)
4345
-					var sum_count int64
4346
-					var sum_in_count int64
4347
-					for _, it := range goodList {
4348
-						sum_count += it.StockCount
4349
-						sum_in_count += it.WarehousingCount
4369
+					storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4370
+					stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, adminInfo.Org.Id)
4371
+					var total_count int64
4372
+					for _, it := range stockList {
4373
+						total_count += it.StockCount
4350 4374
 					}
4351
-					service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, adminInfo.Org.Id)
4375
+					//基础库插入数据
4376
+					service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, adminInfo.Org.Id)
4352 4377
 				}
4353 4378
 			}
4354 4379
 			//
@@ -4379,16 +4404,16 @@ func (c *DialysisAPIController) CreateStockOutInfo() {
4379 4404
 					//清空准备表数据
4380 4405
 					service.DeleteDialysisBefor(adminInfo.Org.Id, patient_id, record_time, item.GoodId, item.GoodTypeId)
4381 4406
 					service.CreateDialysisBeforePrepareOne(&prepare)
4407
+
4382 4408
 					//查询默认仓库
4383
-					houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4384
-					goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.GoodId, adminInfo.Org.Id)
4385
-					var sum_count int64
4386
-					var sum_in_count int64
4387
-					for _, it := range goodList {
4388
-						sum_count += it.StockCount
4389
-						sum_in_count += it.WarehousingCount
4409
+					storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4410
+					stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, adminInfo.Org.Id)
4411
+					var total_count int64
4412
+					for _, it := range stockList {
4413
+						total_count += it.StockCount
4390 4414
 					}
4391
-					service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, adminInfo.Org.Id)
4415
+					//基础库插入数据
4416
+					service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, adminInfo.Org.Id)
4392 4417
 
4393 4418
 				}
4394 4419
 			}
@@ -4502,15 +4527,25 @@ func (c *DialysisAPIController) EditConsumables() {
4502 4527
 					if item.Count < goodInfo.Count {
4503 4528
 						//出库
4504 4529
 						err = ConsumablesDeliveryTotalSeven(adminInfo.Org.Id, patient_id, record_time, beforePrepares, adminInfo.AdminUser.Id, item.Count)
4505
-						houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4506
-						goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.GoodId, adminInfo.Org.Id)
4507
-						var sum_count int64
4508
-						var sum_in_count int64
4509
-						for _, it := range goodList {
4510
-							sum_count += it.StockCount
4511
-							sum_in_count += it.WarehousingCount
4530
+						//houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4531
+						//goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.GoodId, adminInfo.Org.Id)
4532
+						//var sum_count int64
4533
+						//var sum_in_count int64
4534
+						//for _, it := range goodList {
4535
+						//	sum_count += it.StockCount
4536
+						//	sum_in_count += it.WarehousingCount
4537
+						//}
4538
+						//service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, adminInfo.Org.Id)
4539
+
4540
+						//查询默认仓库
4541
+						storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4542
+						stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, adminInfo.Org.Id)
4543
+						var total_count int64
4544
+						for _, it := range stockList {
4545
+							total_count += it.StockCount
4512 4546
 						}
4513
-						service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, adminInfo.Org.Id)
4547
+						//基础库插入数据
4548
+						service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, adminInfo.Org.Id)
4514 4549
 						break
4515 4550
 					}
4516 4551
 
@@ -4555,15 +4590,23 @@ func (c *DialysisAPIController) EditConsumables() {
4555 4590
 							return
4556 4591
 						} else {
4557 4592
 							err = ConsumablesDeliveryTotalSix(adminInfo.Org.Id, patient_id, record_time, beforePrepares, newBeforePrepares, adminInfo.AdminUser.Id)
4558
-							houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4559
-							goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.GoodId, adminInfo.Org.Id)
4560
-							var sum_count int64
4561
-							var sum_in_count int64
4562
-							for _, it := range goodList {
4563
-								sum_count += it.StockCount
4564
-								sum_in_count += it.WarehousingCount
4593
+							//houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4594
+							//goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.GoodId, adminInfo.Org.Id)
4595
+							//var sum_count int64
4596
+							//var sum_in_count int64
4597
+							//for _, it := range goodList {
4598
+							//	sum_count += it.StockCount
4599
+							//	sum_in_count += it.WarehousingCount
4600
+							//}
4601
+							//service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, adminInfo.Org.Id)
4602
+							storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4603
+							stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, adminInfo.Org.Id)
4604
+							var total_count int64
4605
+							for _, it := range stockList {
4606
+								total_count += it.StockCount
4565 4607
 							}
4566
-							service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, adminInfo.Org.Id)
4608
+							//基础库插入数据
4609
+							service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, adminInfo.Org.Id)
4567 4610
 							break
4568 4611
 						}
4569 4612
 					}
@@ -4590,15 +4633,24 @@ func (c *DialysisAPIController) EditConsumables() {
4590 4633
 
4591 4634
 					service.CreateDialysisBeforePrepareOne(&prepare)
4592 4635
 					//查询默认仓库
4593
-					houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4594
-					goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, it.GoodId, adminInfo.Org.Id)
4595
-					var sum_count int64
4596
-					var sum_in_count int64
4597
-					for _, it := range goodList {
4598
-						sum_count += it.StockCount
4599
-						sum_in_count += it.WarehousingCount
4636
+					//houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4637
+					//goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, it.GoodId, adminInfo.Org.Id)
4638
+					//var sum_count int64
4639
+					//var sum_in_count int64
4640
+					//for _, it := range goodList {
4641
+					//	sum_count += it.StockCount
4642
+					//	sum_in_count += it.WarehousingCount
4643
+					//}
4644
+					//service.UpdateGoodByGoodId(it.GoodId, sum_count, sum_in_count, adminInfo.Org.Id)
4645
+
4646
+					storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4647
+					stockList, _ := service.GetStockCountByGoodId(it.GoodId, storeHouseConfig.StorehouseOutInfo, adminInfo.Org.Id)
4648
+					var total_count int64
4649
+					for _, it := range stockList {
4650
+						total_count += it.StockCount
4600 4651
 					}
4601
-					service.UpdateGoodByGoodId(it.GoodId, sum_count, sum_in_count, adminInfo.Org.Id)
4652
+					//基础库插入数据
4653
+					service.UpdateGoodInfoReduceSumCount(it.GoodId, total_count, adminInfo.Org.Id)
4602 4654
 
4603 4655
 					if err != nil {
4604 4656
 						goodObj, _ := service.GetGoodInformationByGoodId(it.GoodId)
@@ -4922,15 +4974,25 @@ func (c *DialysisAPIController) CreateOtherStockOutInfo() {
4922 4974
 		service.CreateDialysisBeforePrepareOne(&prepare)
4923 4975
 
4924 4976
 		//查询默认仓库
4925
-		houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4926
-		goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.GoodId, adminInfo.Org.Id)
4927
-		var sum_count int64
4928
-		var sum_in_count int64
4929
-		for _, it := range goodList {
4930
-			sum_count += it.StockCount
4931
-			sum_in_count += it.WarehousingCount
4977
+		//houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4978
+		//goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.GoodId, adminInfo.Org.Id)
4979
+		//var sum_count int64
4980
+		//var sum_in_count int64
4981
+		//for _, it := range goodList {
4982
+		//	sum_count += it.StockCount
4983
+		//	sum_in_count += it.WarehousingCount
4984
+		//}
4985
+		//service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, adminInfo.Org.Id)
4986
+
4987
+		//查询默认仓库
4988
+		storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
4989
+		stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, adminInfo.Org.Id)
4990
+		var total_count int64
4991
+		for _, it := range stockList {
4992
+			total_count += it.StockCount
4932 4993
 		}
4933
-		service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, adminInfo.Org.Id)
4994
+		//基础库插入数据
4995
+		service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, adminInfo.Org.Id)
4934 4996
 
4935 4997
 	}
4936 4998
 
@@ -5317,6 +5379,7 @@ func ConsumablesDeliveryDeleteFour(orgID int64, record_time int64, good_yc *mode
5317 5379
 		PatientId:               good_yc.PatientId,
5318 5380
 		ConsumableType:          2,
5319 5381
 		StorehouseId:            houseConfig.StorehouseOutInfo,
5382
+		IsCheck:                 1,
5320 5383
 	}
5321 5384
 	warehouseOutInfo.Count = count
5322 5385
 
@@ -5580,6 +5643,7 @@ func ConsumablesDeliveryTotalSix(orgID int64, patient_id int64, record_time int6
5580 5643
 				Type:                    1,
5581 5644
 				IsSys:                   1,
5582 5645
 				StorehouseId:            houseConfig.StorehouseOutInfo,
5646
+				IsCheck:                 1,
5583 5647
 			}
5584 5648
 			err := service.AddSigleWarehouseOut(&warehouseOut)
5585 5649
 			if err != nil {
@@ -5653,6 +5717,7 @@ func ConsumablesDeliveryDeleteThree(orgID int64, record_time int64, good_yc *mod
5653 5717
 			GoodTypeId:              good_yc.GoodTypeId,
5654 5718
 			GoodId:                  good_yc.GoodId,
5655 5719
 			StorehouseId:            warehouseOut.StorehouseId,
5720
+			IsCheck:                 1,
5656 5721
 		}
5657 5722
 		warehouseOutInfo.Count = delete_count
5658 5723
 		stockInInfo, _ := service.FindLastStockInInfoRecord(good_yc.GoodId, orgID)

+ 24 - 56
controllers/mobile_api_controllers/patient_api_controller.go Vedi File

@@ -686,6 +686,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
686 686
 		//自备药信息
687 687
 		privateDrugConfig, _ := service.GetDrugSetByUserOrgId(adminUserInfo.Org.Id)
688 688
 
689
+		storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.Org.Id)
689 690
 		if drugStockConfig.IsOpen == 1 {
690 691
 			if groupno > 0 {
691 692
 				advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
@@ -750,43 +751,26 @@ func (c *PatientApiController) ExecDoctorAdvice() {
750 751
 									if prescriptionConfig.IsOpen == 1 {
751 752
 										if medical.IsUse == 2 {
752 753
 											service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
753
-											//查询默认仓库
754
-											houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
755
-											//查询默认仓库剩余多少库存
756
-											list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
754
+
755
+											//更新字典里面的库存
756
+											stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
757 757
 											var sum_count int64
758
-											var sum_in_count int64
759
-											for _, it := range list {
760
-												baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
761
-												if it.MaxUnit == baseDrug.MaxUnit {
762
-													it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
763
-													it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
764
-												}
765
-												sum_count += it.StockMaxNumber + it.StockMinNumber
766
-												sum_in_count += it.WarehousingCount
758
+											for _, its := range stockInfo {
759
+												sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
767 760
 											}
768
-											service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
761
+											service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
769 762
 										}
770 763
 									}
771 764
 								} else {
772 765
 									if medical.IsUse == 2 {
773 766
 										service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
774
-										//查询默认仓库
775
-										houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
776
-										//查询默认仓库剩余多少库存
777
-										list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
767
+
768
+										stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
778 769
 										var sum_count int64
779
-										var sum_in_count int64
780
-										for _, it := range list {
781
-											baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
782
-											if it.MaxUnit == baseDrug.MaxUnit {
783
-												it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
784
-												it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
785
-											}
786
-											sum_count += it.StockMaxNumber + it.StockMinNumber
787
-											sum_in_count += it.WarehousingCount
770
+										for _, its := range stockInfo {
771
+											sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
788 772
 										}
789
-										service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
773
+										service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
790 774
 									}
791 775
 								}
792 776
 							}
@@ -863,22 +847,14 @@ func (c *PatientApiController) ExecDoctorAdvice() {
863 847
 							if prescribing_number_total <= total {
864 848
 								if medical.IsUse == 2 {
865 849
 									service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
866
-									//查询默认仓库
867
-									houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
868
-									//查询默认仓库剩余多少库存
869
-									list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
850
+
851
+									//更新字典里面的库存
852
+									stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
870 853
 									var sum_count int64
871
-									var sum_in_count int64
872
-									for _, it := range list {
873
-										baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
874
-										if it.MaxUnit == baseDrug.MaxUnit {
875
-											it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
876
-											it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
877
-										}
878
-										sum_count += it.StockMaxNumber + it.StockMinNumber
879
-										sum_in_count += it.WarehousingCount
854
+									for _, its := range stockInfo {
855
+										sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
880 856
 									}
881
-									service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
857
+									service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
882 858
 									c.ServeSuccessJSON(map[string]interface{}{
883 859
 										"msg":    "1",
884 860
 										"advice": advice,
@@ -1074,6 +1050,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1074 1050
 
1075 1051
 			//药品管理信息
1076 1052
 			_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
1053
+			storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
1077 1054
 			if drugStockConfig.IsOpen == 1 {
1078 1055
 				for _, item := range advices {
1079 1056
 					//查询改药品信息
@@ -1163,22 +1140,13 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1163 1140
 							config, _ := service.GetDrugOpenConfig(adminInfo.Org.Id)
1164 1141
 							if config.IsOpen != 1 {
1165 1142
 								service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1166
-								//查询默认仓库
1167
-								houseConfig, _ := service.GetAllStoreHouseConfig(medical.OrgId)
1168
-								//查询默认仓库剩余多少库存
1169
-								list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, medical.OrgId, medical.ID)
1143
+								//更新字典里面的库存
1144
+								stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1170 1145
 								var sum_count int64
1171
-								var sum_in_count int64
1172
-								for _, it := range list {
1173
-									baseDrug, _ := service.GetBaseDrugMedical(medical.ID)
1174
-									if it.MaxUnit == baseDrug.MaxUnit {
1175
-										it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
1176
-										it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
1177
-									}
1178
-									sum_count += it.StockMaxNumber + it.StockMinNumber
1179
-									sum_in_count += it.WarehousingCount
1146
+								for _, its := range stockInfo {
1147
+									sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
1180 1148
 								}
1181
-								service.UpdateMedicalSumCount(medical.ID, sum_count, sum_in_count, medical.OrgId)
1149
+								service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
1182 1150
 							}
1183 1151
 
1184 1152
 						}

+ 30 - 16
controllers/patient_api_controller.go Vedi File

@@ -1750,6 +1750,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1750 1750
 		//自备药信息
1751 1751
 		privateDrugConfig, _ := service.GetDrugSetByUserOrgId(adminUserInfo.CurrentOrgId)
1752 1752
 
1753
+		storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.CurrentOrgId)
1753 1754
 		if drugStockConfig.IsOpen == 1 {
1754 1755
 			var total int64
1755 1756
 			var prescribing_number_total int64
@@ -1795,6 +1796,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1795 1796
 					//查询是否门诊处方和临时医嘱同步到透析医嘱的开关是否开启
1796 1797
 
1797 1798
 					adviceSetting, _ := service.FindAdviceSettingById(item.UserOrgId)
1799
+
1798 1800
 					if adviceSetting.IsAdviceOpen == 1 {
1799 1801
 
1800 1802
 						//查询是否出库按钮开启
@@ -1818,6 +1820,12 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1818 1820
 									sum_in_count += it.WarehousingCount
1819 1821
 								}
1820 1822
 								service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
1823
+								//更新字典里面的库存
1824
+								stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1825
+								for _, its := range stockInfo {
1826
+									sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
1827
+								}
1828
+								service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
1821 1829
 								break
1822 1830
 								c.ServeSuccessJSON(map[string]interface{}{
1823 1831
 									"msg":    "1",
@@ -1845,22 +1853,29 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1845 1853
 					} else {
1846 1854
 						if medical.IsUse == 2 {
1847 1855
 							service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
1848
-							//查询默认仓库
1849
-							houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
1850
-							//查询默认仓库剩余多少库存
1851
-							list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1856
+							////查询默认仓库
1857
+							//houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
1858
+							////查询默认仓库剩余多少库存
1859
+							//list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1860
+							//var sum_count int64
1861
+							//var sum_in_count int64
1862
+							//for _, it := range list {
1863
+							//	baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
1864
+							//	if it.MaxUnit == baseDrug.MaxUnit {
1865
+							//		it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
1866
+							//		it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
1867
+							//	}
1868
+							//	sum_count += it.StockMaxNumber + it.StockMinNumber
1869
+							//	sum_in_count += it.WarehousingCount
1870
+							//}
1871
+							//service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
1872
+							//更新字典里面的库存
1852 1873
 							var sum_count int64
1853
-							var sum_in_count int64
1854
-							for _, it := range list {
1855
-								baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
1856
-								if it.MaxUnit == baseDrug.MaxUnit {
1857
-									it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
1858
-									it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
1859
-								}
1860
-								sum_count += it.StockMaxNumber + it.StockMinNumber
1861
-								sum_in_count += it.WarehousingCount
1874
+							stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
1875
+							for _, its := range stockInfo {
1876
+								sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
1862 1877
 							}
1863
-							service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.UserOrgId)
1878
+							service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
1864 1879
 							break
1865 1880
 							c.ServeSuccessJSON(map[string]interface{}{
1866 1881
 								"msg":    "1",
@@ -2124,10 +2139,9 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2124 2139
 				}
2125 2140
 				if prescribing_number_total <= total {
2126 2141
 					if medical.IsUse == 2 {
2127
-						config, _ := service.GetDrugOpenConfig(adminUserInfo.CurrentOrgId)
2142
+						config, _ := service.GetDrugOpenConfigOne(adminUserInfo.CurrentOrgId)
2128 2143
 						if config.IsOpen != 1 {
2129 2144
 							service.HisDrugsDelivery(adminUserInfo.CurrentOrgId, item.ExecutionStaff, item)
2130
-
2131 2145
 							//查询默认仓库
2132 2146
 							houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
2133 2147
 							//查询默认仓库剩余多少库存

+ 1 - 0
controllers/print_data_api_controller.go Vedi File

@@ -209,6 +209,7 @@ func (this *PrintDataAPIController) GetGoodDetailPrintList() {
209 209
 	if types == 2 {
210 210
 		//list, err := service.GetWarehouseOutInfoGoodDetailPrintList(adminUserInfo.CurrentOrgId, startTime, endTime, limit, page)
211 211
 		list, _ := service.GetWarehouseOutInfoPrintList(adminUserInfo.CurrentOrgId, startTime, endTime)
212
+		fmt.Println("list23323232233232", list)
212 213
 		stockTotal, err := service.GetOutStockTotalCountTwo(startTime, endTime, adminUserInfo.CurrentOrgId)
213 214
 		if err != nil {
214 215
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)

+ 34 - 45
controllers/secondary_order_api_contorller.go Vedi File

@@ -1086,6 +1086,7 @@ func (this *SecondaryOrderApiController) CheckSecondOrer() {
1086 1086
 						StorehouseId:            item.StorehouseOutId,
1087 1087
 						SecondWarehouseId:       item.WarehouseId,
1088 1088
 						IsSys:                   12,
1089
+						IsCheck:                 1,
1089 1090
 					}
1090 1091
 					_, drugerrcodes := service.GetDrugWarehouseBySyS(orgId, 12, item.WarehouseId, record_date)
1091 1092
 
@@ -1120,6 +1121,7 @@ func (this *SecondaryOrderApiController) CheckSecondOrer() {
1120 1121
 						WarehouseInfoId:         0,
1121 1122
 						StorehouseId:            item.StorehouseOutId,
1122 1123
 						SecondWarehouseInfoId:   item.ID,
1124
+						IsCheck:                 1,
1123 1125
 					}
1124 1126
 					drup, _ := service.FindBaseDrugLibRecord(orgId, item.ProjectId)
1125 1127
 
@@ -1140,6 +1142,7 @@ func (this *SecondaryOrderApiController) CheckSecondOrer() {
1140 1142
 						StorehouseId:      item.StorehouseInId,
1141 1143
 						IsSys:             13,
1142 1144
 						SecondWarehouseId: item.WarehouseId,
1145
+						IsCheck:           1,
1143 1146
 					}
1144 1147
 
1145 1148
 					//查询该调拨单是否有生成入库单
@@ -1175,26 +1178,19 @@ func (this *SecondaryOrderApiController) CheckSecondOrer() {
1175 1178
 						RetailPrice:           0,
1176 1179
 						StorehouseId:          item.StorehouseInId,
1177 1180
 						SecondWarehouseInfoId: item.ID,
1181
+						IsCheck:               1,
1178 1182
 					}
1179 1183
 					service.AutoDrugDeliverInfoTwelve(orgId, item.Count, &drugWarehouseOut, &drup, warehouseOutInfo, drugwarehouseInfo)
1180 1184
 
1181 1185
 					//查询默认仓库
1182
-					houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
1183
-					//查询默认仓库剩余多少库存
1184
-					list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, orgId, item.ProjectId)
1186
+					storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
1187
+					//更新字典里面的库存
1188
+					stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.ProjectId)
1185 1189
 					var sum_count int64
1186
-					var sum_in_count int64
1187
-					for _, it := range list {
1188
-						baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
1189
-						if it.MaxUnit == baseDrug.MaxUnit {
1190
-							it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
1191
-							it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
1192
-
1193
-						}
1194
-						sum_count += it.StockMaxNumber + it.StockMinNumber
1195
-						sum_in_count += it.WarehousingCount
1190
+					for _, its := range stockInfo {
1191
+						sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
1196 1192
 					}
1197
-					service.UpdateMedicalSumCount(item.ProjectId, sum_count, sum_in_count, item.UserOrgId)
1193
+					service.UpdateBaseDrugSumTwo(item.ProjectId, sum_count, item.UserOrgId)
1198 1194
 				}
1199 1195
 			}
1200 1196
 
@@ -1222,6 +1218,7 @@ func (this *SecondaryOrderApiController) CheckSecondOrer() {
1222 1218
 						StorehouseId:            item.StorehouseOutId,
1223 1219
 						IsSys:                   12,
1224 1220
 						SecondWarehouseId:       item.WarehouseId,
1221
+						IsCheck:                 1,
1225 1222
 					}
1226 1223
 
1227 1224
 					//查询今日是否存在调拨出库
@@ -1253,6 +1250,7 @@ func (this *SecondaryOrderApiController) CheckSecondOrer() {
1253 1250
 						WarehouseInfotId:        0,
1254 1251
 						StorehouseId:            item.StorehouseOutId,
1255 1252
 						SecondWarehouseInfoId:   item.ID,
1253
+						IsCheck:                 1,
1256 1254
 					}
1257 1255
 
1258 1256
 					//入库操作
@@ -1268,6 +1266,7 @@ func (this *SecondaryOrderApiController) CheckSecondOrer() {
1268 1266
 						StorehouseId:      item.StorehouseInId,
1269 1267
 						IsSys:             12,
1270 1268
 						SecondWarehouseId: item.WarehouseId,
1269
+						IsCheck:           1,
1271 1270
 					}
1272 1271
 					//查询该调拨单是否有生成入库单
1273 1272
 					_, errcodess := service.GetWarehouseBySecondWarehouseId(12, item.WarehouseId, orgId, record_date)
@@ -1299,6 +1298,7 @@ func (this *SecondaryOrderApiController) CheckSecondOrer() {
1299 1298
 						PackingPrice:          item.MinPrice,
1300 1299
 						StorehouseId:          item.StorehouseInId,
1301 1300
 						SecondWarehouseInfoId: item.ID,
1301
+						IsCheck:               1,
1302 1302
 					}
1303 1303
 
1304 1304
 					//出库逻辑
@@ -1308,15 +1308,14 @@ func (this *SecondaryOrderApiController) CheckSecondOrer() {
1308 1308
 				}
1309 1309
 
1310 1310
 				//查询默认仓库
1311
-				houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
1312
-				goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.ProjectId, item.UserOrgId)
1313
-				var sum_count int64
1314
-				var sum_in_count int64
1315
-				for _, it := range goodList {
1316
-					sum_count += it.StockCount
1317
-					sum_in_count += it.WarehousingCount
1311
+				storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
1312
+				stockList, _ := service.GetStockCountByGoodId(item.ProjectId, storeHouseConfig.StorehouseOutInfo, orgId)
1313
+				var total_count int64
1314
+				for _, it := range stockList {
1315
+					total_count += it.StockCount
1318 1316
 				}
1319
-				service.UpdateGoodByGoodId(item.ProjectId, sum_count, sum_in_count, item.UserOrgId)
1317
+				//基础库插入数据
1318
+				service.UpdateGoodInfoSumCount(item.ProjectId, total_count, orgId)
1320 1319
 			}
1321 1320
 		}
1322 1321
 	}
@@ -1485,23 +1484,14 @@ func (this *SecondaryOrderApiController) ReturnCheckSecondOrder() {
1485 1484
 				}
1486 1485
 
1487 1486
 			}
1488
-			//查询默认仓库
1489
-			houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
1490
-			//查询默认仓库剩余多少库存
1491
-			list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, orgId, item.ProjectId)
1492
-			var sum_count int64
1493
-			var sum_in_count int64
1494
-			for _, it := range list {
1495
-				baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
1496
-				if it.MaxUnit == baseDrug.MaxUnit {
1497
-					it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
1498
-					it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
1499 1487
 
1500
-				}
1501
-				sum_count += it.StockMaxNumber + it.StockMinNumber
1502
-				sum_in_count += it.WarehousingCount
1488
+			storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
1489
+			var sum_count int64
1490
+			stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.ProjectId)
1491
+			for _, its := range stockInfo {
1492
+				sum_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
1503 1493
 			}
1504
-			service.UpdateMedicalSumCount(item.ProjectId, sum_count, sum_in_count, item.UserOrgId)
1494
+			service.UpdateBaseDrugSumTwo(item.ProjectId, sum_count, item.UserOrgId)
1505 1495
 		}
1506 1496
 
1507 1497
 		//耗材
@@ -1533,15 +1523,14 @@ func (this *SecondaryOrderApiController) ReturnCheckSecondOrder() {
1533 1523
 			}
1534 1524
 
1535 1525
 			//查询默认仓库
1536
-			houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
1537
-			goodList, _ := service.GetGoodSumCountByStoreId(houseConfig.StorehouseOutInfo, item.ProjectId, item.UserOrgId)
1538
-			var sum_count int64
1539
-			var sum_in_count int64
1540
-			for _, it := range goodList {
1541
-				sum_count += it.StockCount
1542
-				sum_in_count += it.WarehousingCount
1526
+			storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
1527
+			stockList, _ := service.GetStockCountByGoodId(item.ProjectId, storeHouseConfig.StorehouseOutInfo, orgId)
1528
+			var total_count int64
1529
+			for _, it := range stockList {
1530
+				total_count += it.StockCount
1543 1531
 			}
1544
-			service.UpdateGoodByGoodId(item.ProjectId, sum_count, sum_in_count, item.UserOrgId)
1532
+			//基础库插入数据
1533
+			service.UpdateGoodInfoSumCount(item.ProjectId, total_count, orgId)
1545 1534
 
1546 1535
 		}
1547 1536
 	}

File diff suppressed because it is too large
+ 1125 - 986
controllers/stock_in_api_controller.go


+ 61 - 37
controllers/supply_order_api_contorller.go Vedi File

@@ -2230,6 +2230,7 @@ func (this *SupplyOrderApiController) GetGoodOrderCountList() {
2230 2230
 						Type:              1,
2231 2231
 						SupplyWarehouseId: id,
2232 2232
 						StorehouseId:      houseConfig.DrugStorehouseInfo,
2233
+						IsCheck:           1,
2233 2234
 					}
2234 2235
 					//查询今日是否存在入库单号
2235 2236
 					//_, errcode := service.GetSingleDrugWarehouseOrder(record_date, orgId)
@@ -2264,6 +2265,7 @@ func (this *SupplyOrderApiController) GetGoodOrderCountList() {
2264 2265
 						SupplyWarehouseId:         id,
2265 2266
 						SupplyWarehouseDetailInfo: item.ID,
2266 2267
 						StorehouseId:              houseConfig.DrugStorehouseInfo,
2268
+						IsCheck:                   1,
2267 2269
 					}
2268 2270
 					if medical.MaxUnit == medical.MinUnit {
2269 2271
 						warehouseInfoDetailOne.StockMaxNumber = item.Count
@@ -2334,6 +2336,7 @@ func (this *SupplyOrderApiController) GetGoodOrderCountList() {
2334 2336
 						Type:              1,
2335 2337
 						SupplyWarehouseId: id,
2336 2338
 						StorehouseId:      houseConfig.StorehouseInfo,
2339
+						IsCheck:           1,
2337 2340
 					}
2338 2341
 					//查询是否存在入库单
2339 2342
 					//_, errcose := service.GetSindleWarehouse(record_date, orgId)
@@ -2367,6 +2370,7 @@ func (this *SupplyOrderApiController) GetGoodOrderCountList() {
2367 2370
 						SupplyWarehouseId:         id,
2368 2371
 						SupplyWarehouseDetailInfo: item.ID,
2369 2372
 						StorehouseId:              houseConfig.StorehouseInfo,
2373
+						IsCheck:                   1,
2370 2374
 					}
2371 2375
 					warehousingInfo = append(warehousingInfo, warehouseInfo)
2372 2376
 				}
@@ -3205,50 +3209,41 @@ func (this *SupplyOrderApiController) ModefyGoodOrder() {
3205 3209
 			service.UpdateGoodWarehousing(id, orgId)
3206 3210
 		}
3207 3211
 
3208
-		// 查询入库单
3209
-		drugInfo, _ := service.GetDrugSupplyWarehouseIdSeven(id, orgId)
3210
-		for _, item := range drugInfo {
3211
-
3212
-			//查询默认仓库
3213
-			houseConfig, _ := service.GetAllStoreHouseConfig(item.OrgId)
3214
-			//查询默认仓库剩余多少库存
3215
-			list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.OrgId, item.DrugId)
3216
-			var sum_count int64
3217
-			var sum_in_count int64
3218
-			for _, it := range list {
3219
-				baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
3220
-				if it.MaxUnit == baseDrug.MaxUnit {
3221
-					it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
3222
-					it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
3223
-
3224
-				}
3225
-				sum_count += it.StockMaxNumber + it.StockMinNumber
3226
-				sum_in_count += it.WarehousingCount
3227
-			}
3228
-			service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.OrgId)
3229
-		}
3230
-
3231 3212
 		//删除药品入库单
3232 3213
 		service.UpdateDrugSupplyWarehousingInfo(id, orgId)
3233 3214
 
3234 3215
 		//删除入库流水
3235 3216
 		service.UpdateDrugSupplyFlow(id, orgId)
3217
+		// 查询入库单
3218
+		drugInfo, _ := service.GetDrugSupplyWarehouseIdSeven(id, orgId)
3219
+		if len(drugInfo) > 0 {
3220
+			for _, item := range drugInfo {
3221
+				//查询默认仓库
3222
+				houseConfig, _ := service.GetAllStoreHouseConfig(item.OrgId)
3223
+				//查询默认仓库剩余多少库存
3224
+				list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.OrgId, item.DrugId)
3225
+				var sum_count int64
3226
+				var sum_in_count int64
3227
+				for _, it := range list {
3228
+					baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
3229
+					if it.MaxUnit == baseDrug.MaxUnit {
3230
+						it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
3231
+						it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
3236 3232
 
3237
-		//查寻入库单
3238
-		info, _ := service.GetSupplySupplyWarehouseIdSeven(id, orgId)
3239
-		for _, item := range info {
3240
-			//扣减库存
3241
-			//查询该机构默认仓库
3242
-			storeConfig, _ := service.GetAllStoreHouseConfig(item.OrgId)
3243
-			//查询剩余库存
3244
-			goodList, _ := service.GetGoodSumCountByStoreId(storeConfig.StorehouseOutInfo, item.GoodId, item.OrgId)
3245
-			var sum_count int64
3246
-			var sum_in_count int64
3247
-			for _, item := range goodList {
3248
-				sum_count += item.StockCount
3249
-				sum_in_count += item.WarehousingCount
3233
+					}
3234
+					sum_count += it.StockMaxNumber + it.StockMinNumber
3235
+					sum_in_count += it.WarehousingCount
3236
+				}
3237
+				service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.OrgId)
3238
+			}
3239
+		} else {
3240
+			for _, it := range goodOrder {
3241
+				if it.IsSource == 1 {
3242
+
3243
+					service.UpdateMedicalSumCount(it.ProjectId, 0, 0, this.GetAdminUserInfo().CurrentOrgId)
3244
+				}
3250 3245
 			}
3251
-			service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, item.OrgId)
3246
+
3252 3247
 		}
3253 3248
 
3254 3249
 		//删除耗材入库单
@@ -3257,6 +3252,31 @@ func (this *SupplyOrderApiController) ModefyGoodOrder() {
3257 3252
 		//删除耗材入库流水
3258 3253
 		service.UpdateGoodSupplyFlow(id, orgId)
3259 3254
 
3255
+		//查寻入库单
3256
+		info, _ := service.GetSupplySupplyWarehouseIdSeven(id, orgId)
3257
+		if len(info) > 0 {
3258
+			for _, item := range info {
3259
+				//扣减库存
3260
+				//查询该机构默认仓库
3261
+				storeConfig, _ := service.GetAllStoreHouseConfig(item.OrgId)
3262
+				//查询剩余库存
3263
+				goodList, _ := service.GetGoodSumCountByStoreId(storeConfig.StorehouseOutInfo, item.GoodId, item.OrgId)
3264
+				var sum_count int64
3265
+				var sum_in_count int64
3266
+				for _, item := range goodList {
3267
+					sum_count += item.StockCount
3268
+					sum_in_count += item.WarehousingCount
3269
+				}
3270
+				service.UpdateGoodByGoodId(item.GoodId, sum_count, sum_in_count, item.OrgId)
3271
+			}
3272
+		} else {
3273
+			for _, it := range goodOrder {
3274
+				if it.IsSource == 2 {
3275
+					service.UpdateGoodByGoodId(it.ProjectId, 0, 0, this.GetAdminUserInfo().CurrentOrgId)
3276
+				}
3277
+			}
3278
+		}
3279
+
3260 3280
 		if err == nil {
3261 3281
 			this.ServeSuccessJSON(map[string]interface{}{
3262 3282
 				"cancelList":   cancelList,
@@ -3463,6 +3483,7 @@ func (this *SupplyOrderApiController) CheckReturnOrder() {
3463 3483
 				SupplyCancelOutId:       id,
3464 3484
 				SupplyWarehouseId:       warehouse_out_id,
3465 3485
 				StorehouseId:            houseConfig.DrugStorehouseOut,
3486
+				IsCheck:                 1,
3466 3487
 			}
3467 3488
 			// 查询今日是否存在出库单
3468 3489
 			_, errcodes := service.GetDrugWarehouseOutById(orgId, record_date)
@@ -3499,6 +3520,7 @@ func (this *SupplyOrderApiController) CheckReturnOrder() {
3499 3520
 				SysRecordTime:           record_date,
3500 3521
 				IsSource:                item.Type,
3501 3522
 				StorehouseId:            houseConfig.DrugStorehouseOut,
3523
+				IsCheck:                 1,
3502 3524
 			}
3503 3525
 
3504 3526
 			drup, _ := service.FindBaseDrugLibRecord(orgId, item.ProjectId)
@@ -3561,6 +3583,7 @@ func (this *SupplyOrderApiController) CheckReturnOrder() {
3561 3583
 				SupplyWarehouseId:       warehouse_out_id,
3562 3584
 				IsSys:                   0,
3563 3585
 				StorehouseId:            houseConfig.StorehouseOutInfo,
3586
+				IsCheck:                 1,
3564 3587
 			}
3565 3588
 			//查询是否生成出库单
3566 3589
 			_, errcodes := service.FindStockOutByIsSys(orgId, 0, record_date)
@@ -3594,6 +3617,7 @@ func (this *SupplyOrderApiController) CheckReturnOrder() {
3594 3617
 				SupplyWarehouseId:       warehouse_out_id,
3595 3618
 				IsSource:                item.Type,
3596 3619
 				StorehouseId:            houseConfig.StorehouseOutInfo,
3620
+				IsCheck:                 1,
3597 3621
 			}
3598 3622
 			//出库逻辑
3599 3623
 			parseDateErr := service.ConsumablesDeliveryNight(orgId, record_date, info, &warehouseOut, item.SupplyCount, creater, warehouse_out_id, id)

+ 7 - 2
enums/error_code.go Vedi File

@@ -249,6 +249,9 @@ const ( // ErrorCode
249 249
 	ErrorPsnNoEmpty = 310000
250 250
 
251 251
 	ErrorEmployeeNumber = 320000
252
+
253
+	ErrorCheckGoodParamSuccess = 3400000
254
+	ErrorCheckGoodParamWrong   = 3300000
252 255
 )
253 256
 
254 257
 var ErrCodeMsgs = map[int]string{
@@ -485,8 +488,10 @@ var ErrCodeMsgs = map[int]string{
485 488
 
486 489
 	ErrorCodeStockExced: "请先出库,执行失败",
487 490
 
488
-	ErrorPsnNoEmpty:     "人员编码不能为空",
489
-	ErrorEmployeeNumber: "请输入正确的工号",
491
+	ErrorPsnNoEmpty:            "人员编码不能为空",
492
+	ErrorEmployeeNumber:        "请输入正确的工号",
493
+	ErrorCheckGoodParamSuccess: "反审核成功!",
494
+	ErrorCheckGoodParamWrong:   "该入库单已出库,反审核失败!",
490 495
 }
491 496
 
492 497
 type SGJError struct {

+ 1 - 0
models/drug.go Vedi File

@@ -88,6 +88,7 @@ type BaseDrugLibSeven struct {
88 88
 	MinNumber int64  `gorm:"column:min_number" json:"min_number" form:"min_number"`
89 89
 	MinUnit   string `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
90 90
 	SumCount  int64  `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
91
+	IsUse     int64  `gorm:"column:is_user" json:"is_user" form:"is_user"`
91 92
 }
92 93
 
93 94
 func (BaseDrugLibSeven) TableName() string {

+ 178 - 126
models/drug_stock.go Vedi File

@@ -18,6 +18,7 @@ type DrugWarehouse struct {
18 18
 	StorehouseId      int64  `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
19 19
 	SecondWarehouseId int64  `gorm:"column:second_warehouse_id" json:"second_warehouse_id" form:"second_warehouse_id"`
20 20
 	IsSys             int64  `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
21
+	IsCheck           int64  `gorm:"column:is_check" json:"is_check" form:"is_check"`
21 22
 }
22 23
 
23 24
 func (DrugWarehouse) TableName() string {
@@ -86,6 +87,7 @@ type DrugWarehouseInfo struct {
86 87
 	SupplyWarehouseDetailInfo int64   `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
87 88
 	StorehouseId              int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
88 89
 	SecondWarehouseInfoId     int64   `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
90
+	IsCheck                   int64   `gorm:"column:is_check" json:"is_check" form:"is_check"`
89 91
 }
90 92
 
91 93
 func (DrugWarehouseInfo) TableName() string {
@@ -95,6 +97,8 @@ func (DrugWarehouseInfo) TableName() string {
95 97
 type DrugWarehouseInfoSeven struct {
96 98
 	StockMaxNumber int64 `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
97 99
 	StockMinNumber int64 `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
100
+	StorehouseId   int64 `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
101
+	IsCheck        int64 `gorm:"column:is_check" json:"is_check" form:"is_check"`
98 102
 }
99 103
 
100 104
 func (DrugWarehouseInfoSeven) TableName() string {
@@ -123,6 +127,7 @@ type DrugWarehouseOut struct {
123 127
 	SupplyWarehouseId       int64         `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
124 128
 	StorehouseId            int64         `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
125 129
 	SecondWarehouseId       int64         `gorm:"column:second_warehouse_id" json:"second_warehouse_id" form:"second_warehouse_id"`
130
+	IsCheck                 int64         `gorm:"column:is_check" json:"is_check" form:"is_check"`
126 131
 }
127 132
 
128 133
 func (DrugWarehouseOut) TableName() string {
@@ -130,44 +135,46 @@ func (DrugWarehouseOut) TableName() string {
130 135
 }
131 136
 
132 137
 type DrugWarehouseOutInfo struct {
133
-	ID                      int64   `gorm:"column:id" json:"id" form:"id"`
134
-	WarehouseOutId          int64   `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
135
-	DrugId                  int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
136
-	WarehousingOutTarget    int64   `gorm:"column:warehousing_out_target" json:"warehousing_out_target" form:"warehousing_out_target"`
137
-	Count                   int64   `gorm:"column:count" json:"count" form:"count"`
138
-	CountUnit               string  `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
139
-	Price                   float64 `gorm:"column:price" json:"price" form:"price"`
140
-	TotalPrice              float64 `gorm:"column:total_price" json:"total_price" form:"total_price"`
141
-	ProductDate             int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
142
-	ExpiryDate              int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
143
-	Mtime                   int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
144
-	Ctime                   int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
145
-	Status                  int64   `gorm:"column:status" json:"status" form:"status"`
146
-	OrgId                   int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
147
-	Remark                  string  `gorm:"column:remark" json:"remark" form:"remark"`
148
-	IsCancel                int64   `gorm:"column:is_cancel" json:"is_cancel" form:"is_cancel"`
149
-	WarehouseOutOrderNumber string  `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
150
-	Type                    int64   `gorm:"column:type" json:"type" form:"type"`
151
-	Dealer                  int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
152
-	Manufacturer            int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
153
-	IsSys                   int64   `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
154
-	SysRecordTime           int64   `gorm:"column:sys_record_time" json:"sys_record_time" form:"sys_record_time"`
155
-	RetailPrice             float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
156
-	RetailTotalPrice        float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
157
-	Number                  string  `gorm:"column:number" json:"number" form:"number"`
158
-	BatchNumber             string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
159
-	PatientId               int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
160
-	WarehouseInfoId         int64   `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
161
-	AdviceId                int64   `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
162
-	SupplyCancelOutId       int64   `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
163
-	SupplyWarehouseId       int64   `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
164
-	IsSource                int64   `gorm:"column:is_source" json:"is_source" form:"is_source"`
165
-	StorehouseId            int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
166
-	SecondWarehouseInfoId   int64   `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
167
-	AdminUserId             int64   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
168
-	LastPrice               float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
169
-	StockCount              string  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
170
-	PharmacyId              int64   `gorm:"column:pharmacy_id" json:"pharmacy_id" form:"pharmacy_id"`
138
+	ID                      int64       `gorm:"column:id" json:"id" form:"id"`
139
+	WarehouseOutId          int64       `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
140
+	DrugId                  int64       `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
141
+	WarehousingOutTarget    int64       `gorm:"column:warehousing_out_target" json:"warehousing_out_target" form:"warehousing_out_target"`
142
+	Count                   int64       `gorm:"column:count" json:"count" form:"count"`
143
+	CountUnit               string      `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
144
+	Price                   float64     `gorm:"column:price" json:"price" form:"price"`
145
+	TotalPrice              float64     `gorm:"column:total_price" json:"total_price" form:"total_price"`
146
+	ProductDate             int64       `gorm:"column:product_date" json:"product_date" form:"product_date"`
147
+	ExpiryDate              int64       `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
148
+	Mtime                   int64       `gorm:"column:mtime" json:"mtime" form:"mtime"`
149
+	Ctime                   int64       `gorm:"column:ctime" json:"ctime" form:"ctime"`
150
+	Status                  int64       `gorm:"column:status" json:"status" form:"status"`
151
+	OrgId                   int64       `gorm:"column:org_id" json:"org_id" form:"org_id"`
152
+	Remark                  string      `gorm:"column:remark" json:"remark" form:"remark"`
153
+	IsCancel                int64       `gorm:"column:is_cancel" json:"is_cancel" form:"is_cancel"`
154
+	WarehouseOutOrderNumber string      `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
155
+	Type                    int64       `gorm:"column:type" json:"type" form:"type"`
156
+	Dealer                  int64       `gorm:"column:dealer" json:"dealer" form:"dealer"`
157
+	Manufacturer            int64       `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
158
+	IsSys                   int64       `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
159
+	SysRecordTime           int64       `gorm:"column:sys_record_time" json:"sys_record_time" form:"sys_record_time"`
160
+	RetailPrice             float64     `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
161
+	RetailTotalPrice        float64     `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
162
+	Number                  string      `gorm:"column:number" json:"number" form:"number"`
163
+	BatchNumber             string      `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
164
+	PatientId               int64       `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
165
+	WarehouseInfoId         int64       `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
166
+	AdviceId                int64       `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
167
+	SupplyCancelOutId       int64       `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
168
+	SupplyWarehouseId       int64       `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
169
+	IsSource                int64       `gorm:"column:is_source" json:"is_source" form:"is_source"`
170
+	StorehouseId            int64       `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
171
+	SecondWarehouseInfoId   int64       `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
172
+	AdminUserId             int64       `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
173
+	LastPrice               float64     `gorm:"column:last_price" json:"last_price" form:"last_price"`
174
+	StockCount              string      `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
175
+	PharmacyId              int64       `gorm:"column:pharmacy_id" json:"pharmacy_id" form:"pharmacy_id"`
176
+	IsCheck                 int64       `gorm:"column:is_check" json:"is_check" form:"is_check"`
177
+	BaseDrugLib             BaseDrugLib `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId"json:"drug" `
171 178
 }
172 179
 
173 180
 func (DrugWarehouseOutInfo) TableName() string {
@@ -240,6 +247,7 @@ type DrugCancelStock struct {
240 247
 	Dealers             *Dealer                `gorm:"ForeignKey:Dealer;AssociationForeignKey:ID" json:"dealers"`
241 248
 	DrugCancelStockInfo []*DrugCancelStockInfo `gorm:"ForeignKey:CancelStockId;AssociationForeignKey:ID" json:"drugCancelStockInfo"`
242 249
 	StorehouseId        int64                  `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
250
+	IsCheck             int64                  `gorm:"column:is_check" json:"is_check" form:"is_check"`
243 251
 }
244 252
 
245 253
 func (DrugCancelStock) TableName() string {
@@ -247,32 +255,34 @@ func (DrugCancelStock) TableName() string {
247 255
 }
248 256
 
249 257
 type DrugCancelStockInfo struct {
250
-	ID               int64       `gorm:"column:id" json:"id" form:"id"`
251
-	DrugId           int64       `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
252
-	CancelStockId    int64       `gorm:"column:cancel_stock_id" json:"cancel_stock_id" form:"cancel_stock_id"`
253
-	Count            int64       `gorm:"column:count" json:"count" form:"count"`
254
-	Price            float64     `gorm:"column:price" json:"price" form:"price"`
255
-	Total            float64     `gorm:"column:total" json:"total" form:"total"`
256
-	ProductDate      int64       `gorm:"column:product_date" json:"product_date" form:"product_date"`
257
-	ExpiryDate       int64       `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
258
-	Ctime            int64       `gorm:"column:ctime" json:"ctime" form:"ctime"`
259
-	Mtime            int64       `gorm:"column:mtime" json:"mtime" form:"mtime"`
260
-	Status           int64       `gorm:"column:status" json:"status" form:"status"`
261
-	OrgId            int64       `gorm:"column:org_id" json:"org_id" form:"org_id"`
262
-	OrderNumber      string      `gorm:"column:order_number" json:"order_number" form:"order_number"`
263
-	Type             int64       `gorm:"column:type" json:"type" form:"type"`
264
-	Dealer           string      `gorm:"column:dealer" json:"dealer" form:"dealer"`
265
-	Manufacturer     string      `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
266
-	RetailPrice      float64     `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
267
-	RetailTotalPrice float64     `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
268
-	Number           string      `gorm:"column:number" json:"number" form:"number"`
269
-	RegisterAccount  string      `gorm:"column:register_account" json:"register_account" form:"register_account"`
270
-	Remark           string      `gorm:"column:remark" json:"remark" form:"remark"`
271
-	BatchNumber      string      `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
272
-	MaxUnit          string      `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
273
-	BaseDrugLib      BaseDrugLib `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
274
-	BatchNumberId    int64       `gorm:"column:batch_number_id" json:"batch_number_id" form:"batch_number_id"`
275
-	StorehouseId     int64       `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
258
+	ID                int64                `gorm:"column:id" json:"id" form:"id"`
259
+	DrugId            int64                `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
260
+	CancelStockId     int64                `gorm:"column:cancel_stock_id" json:"cancel_stock_id" form:"cancel_stock_id"`
261
+	Count             int64                `gorm:"column:count" json:"count" form:"count"`
262
+	Price             float64              `gorm:"column:price" json:"price" form:"price"`
263
+	Total             float64              `gorm:"column:total" json:"total" form:"total"`
264
+	ProductDate       int64                `gorm:"column:product_date" json:"product_date" form:"product_date"`
265
+	ExpiryDate        int64                `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
266
+	Ctime             int64                `gorm:"column:ctime" json:"ctime" form:"ctime"`
267
+	Mtime             int64                `gorm:"column:mtime" json:"mtime" form:"mtime"`
268
+	Status            int64                `gorm:"column:status" json:"status" form:"status"`
269
+	OrgId             int64                `gorm:"column:org_id" json:"org_id" form:"org_id"`
270
+	OrderNumber       string               `gorm:"column:order_number" json:"order_number" form:"order_number"`
271
+	Type              int64                `gorm:"column:type" json:"type" form:"type"`
272
+	Dealer            string               `gorm:"column:dealer" json:"dealer" form:"dealer"`
273
+	Manufacturer      string               `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
274
+	RetailPrice       float64              `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
275
+	RetailTotalPrice  float64              `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
276
+	Number            string               `gorm:"column:number" json:"number" form:"number"`
277
+	RegisterAccount   string               `gorm:"column:register_account" json:"register_account" form:"register_account"`
278
+	Remark            string               `gorm:"column:remark" json:"remark" form:"remark"`
279
+	BatchNumber       string               `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
280
+	MaxUnit           string               `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
281
+	BaseDrugLib       BaseDrugLib          `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" `
282
+	BatchNumberId     int64                `gorm:"column:batch_number_id" json:"batch_number_id" form:"batch_number_id"`
283
+	StorehouseId      int64                `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
284
+	IsCheck           int64                `gorm:"column:is_check" json:"is_check" form:"is_check"`
285
+	DrugWarehouseInfo []*DrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:DrugId"json:"drug_warehouse_info" `
276 286
 }
277 287
 
278 288
 func (DrugCancelStockInfo) TableName() string {
@@ -422,75 +432,117 @@ func (DrugFlow) TableName() string {
422 432
 	return "xt_drug_flow"
423 433
 }
424 434
 
435
+type DrugWarehouseOutTwenty struct {
436
+	ID                        int64                        `gorm:"column:id" json:"id" form:"id"`
437
+	WarehouseOutOrderNumber   string                       `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
438
+	OperationTime             int64                        `gorm:"column:operation_time" json:"operation_time" form:"operation_time"`
439
+	Creater                   int64                        `gorm:"column:creater" json:"creater" form:"creater"`
440
+	OrgId                     int64                        `gorm:"column:org_id" json:"org_id" form:"org_id"`
441
+	Modifier                  int64                        `gorm:"column:modifier" json:"modifier" form:"modifier"`
442
+	Remark                    string                       `gorm:"column:remark" json:"remark" form:"remark"`
443
+	Ctime                     int64                        `gorm:"column:ctime" json:"ctime" form:"ctime"`
444
+	Mtime                     int64                        `gorm:"column:mtime" json:"mtime" form:"mtime"`
445
+	Status                    int64                        `gorm:"column:status" json:"status" form:"status"`
446
+	WarehouseOutTime          int64                        `gorm:"column:warehouse_out_time" json:"warehouse_out_time" form:"warehouse_out_time"`
447
+	Dealer                    int64                        `gorm:"column:dealer" json:"dealer" form:"dealer"`
448
+	Manufacturer              int64                        `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
449
+	Type                      int64                        `gorm:"column:type" json:"type" form:"type"`
450
+	IsSys                     int64                        `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
451
+	SupplyCancelOutId         int64                        `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
452
+	SupplyWarehouseId         int64                        `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
453
+	StorehouseId              int64                        `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
454
+	SecondWarehouseId         int64                        `gorm:"column:second_warehouse_id" json:"second_warehouse_id" form:"second_warehouse_id"`
455
+	BaseDrugLib               BaseDrugLib                  `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId"json:"drug" `
456
+	DrugWarehouseOutInfoTenty []*DrugWarehouseOutInfoTenty `gorm:"ForeignKey:WarehouseOutId;AssociationForeignKey:ID"json:"xt_drug_warehouse_out_info" `
457
+}
458
+
459
+func (DrugWarehouseOutTwenty) TableName() string {
460
+	return "xt_drug_warehouse_out"
461
+}
462
+
425 463
 type DrugWarehouseOutInfoTenty struct {
426
-	ID                      int64       `gorm:"column:id" json:"id" form:"id"`
427
-	WarehouseOutId          int64       `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
428
-	DrugId                  int64       `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
429
-	WarehousingOutTarget    int64       `gorm:"column:warehousing_out_target" json:"warehousing_out_target" form:"warehousing_out_target"`
430
-	Count                   int64       `gorm:"column:count" json:"count" form:"count"`
431
-	CountUnit               string      `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
432
-	Price                   float64     `gorm:"column:price" json:"price" form:"price"`
433
-	TotalPrice              float64     `gorm:"column:total_price" json:"total_price" form:"total_price"`
434
-	ProductDate             int64       `gorm:"column:product_date" json:"product_date" form:"product_date"`
435
-	ExpiryDate              int64       `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
436
-	Mtime                   int64       `gorm:"column:mtime" json:"mtime" form:"mtime"`
437
-	Ctime                   int64       `gorm:"column:ctime" json:"ctime" form:"ctime"`
438
-	Status                  int64       `gorm:"column:status" json:"status" form:"status"`
439
-	OrgId                   int64       `gorm:"column:org_id" json:"org_id" form:"org_id"`
440
-	Remark                  string      `gorm:"column:remark" json:"remark" form:"remark"`
441
-	IsCancel                int64       `gorm:"column:is_cancel" json:"is_cancel" form:"is_cancel"`
442
-	WarehouseOutOrderNumber string      `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
443
-	Type                    int64       `gorm:"column:type" json:"type" form:"type"`
444
-	Dealer                  int64       `gorm:"column:dealer" json:"dealer" form:"dealer"`
445
-	Manufacturer            int64       `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
446
-	IsSys                   int64       `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
447
-	SysRecordTime           int64       `gorm:"column:sys_record_time" json:"sys_record_time" form:"sys_record_time"`
448
-	RetailPrice             float64     `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
449
-	RetailTotalPrice        float64     `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
450
-	Number                  string      `gorm:"column:number" json:"number" form:"number"`
451
-	BatchNumber             string      `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
452
-	PatientId               int64       `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
453
-	WarehouseInfoId         int64       `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
454
-	AdviceId                int64       `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
455
-	SupplyCancelOutId       int64       `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
456
-	SupplyWarehouseId       int64       `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
457
-	IsSource                int64       `gorm:"column:is_source" json:"is_source" form:"is_source"`
458
-	StorehouseId            int64       `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
459
-	SecondWarehouseInfoId   int64       `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
460
-	AdminUserId             int64       `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
461
-	LastPrice               float64     `gorm:"column:last_price" json:"last_price" form:"last_price"`
462
-	StockCount              string      `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
463
-	PharmacyId              int64       `gorm:"column:pharmacy_id" json:"pharmacy_id" form:"pharmacy_id"`
464
-	BaseDrugLib             BaseDrugLib `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId"json:"drug" `
464
+	ID                      int64               `gorm:"column:id" json:"id" form:"id"`
465
+	WarehouseOutId          int64               `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
466
+	DrugId                  int64               `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
467
+	WarehousingOutTarget    int64               `gorm:"column:warehousing_out_target" json:"warehousing_out_target" form:"warehousing_out_target"`
468
+	Count                   int64               `gorm:"column:count" json:"count" form:"count"`
469
+	CountUnit               string              `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
470
+	Price                   float64             `gorm:"column:price" json:"price" form:"price"`
471
+	TotalPrice              float64             `gorm:"column:total_price" json:"total_price" form:"total_price"`
472
+	ProductDate             int64               `gorm:"column:product_date" json:"product_date" form:"product_date"`
473
+	ExpiryDate              int64               `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
474
+	Mtime                   int64               `gorm:"column:mtime" json:"mtime" form:"mtime"`
475
+	Ctime                   int64               `gorm:"column:ctime" json:"ctime" form:"ctime"`
476
+	Status                  int64               `gorm:"column:status" json:"status" form:"status"`
477
+	OrgId                   int64               `gorm:"column:org_id" json:"org_id" form:"org_id"`
478
+	Remark                  string              `gorm:"column:remark" json:"remark" form:"remark"`
479
+	IsCancel                int64               `gorm:"column:is_cancel" json:"is_cancel" form:"is_cancel"`
480
+	WarehouseOutOrderNumber string              `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
481
+	Type                    int64               `gorm:"column:type" json:"type" form:"type"`
482
+	Dealer                  int64               `gorm:"column:dealer" json:"dealer" form:"dealer"`
483
+	Manufacturer            int64               `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
484
+	IsSys                   int64               `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
485
+	SysRecordTime           int64               `gorm:"column:sys_record_time" json:"sys_record_time" form:"sys_record_time"`
486
+	RetailPrice             float64             `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
487
+	RetailTotalPrice        float64             `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
488
+	Number                  string              `gorm:"column:number" json:"number" form:"number"`
489
+	BatchNumber             string              `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
490
+	PatientId               int64               `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
491
+	WarehouseInfoId         int64               `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
492
+	AdviceId                int64               `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
493
+	SupplyCancelOutId       int64               `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
494
+	SupplyWarehouseId       int64               `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
495
+	IsSource                int64               `gorm:"column:is_source" json:"is_source" form:"is_source"`
496
+	StorehouseId            int64               `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
497
+	SecondWarehouseInfoId   int64               `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
498
+	AdminUserId             int64               `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
499
+	LastPrice               float64             `gorm:"column:last_price" json:"last_price" form:"last_price"`
500
+	StockCount              string              `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
501
+	PharmacyId              int64               `gorm:"column:pharmacy_id" json:"pharmacy_id" form:"pharmacy_id"`
502
+	BaseDrugLib             BaseDrugLib         `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId"json:"drug" `
503
+	DrugWarehouseInfo       XtDrugWarehouseInfo `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseInfoId"json:"drug_warehouse_info" `
465 504
 }
466 505
 
467 506
 func (DrugWarehouseOutInfoTenty) TableName() string {
468 507
 	return "xt_drug_warehouse_out_info"
469 508
 }
470 509
 
471
-type DrugWarehouseOutTwenty struct {
472
-	ID                        int64                     `gorm:"column:id" json:"id" form:"id"`
473
-	WarehouseOutOrderNumber   string                    `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
474
-	OperationTime             int64                     `gorm:"column:operation_time" json:"operation_time" form:"operation_time"`
475
-	Creater                   int64                     `gorm:"column:creater" json:"creater" form:"creater"`
476
-	OrgId                     int64                     `gorm:"column:org_id" json:"org_id" form:"org_id"`
477
-	Modifier                  int64                     `gorm:"column:modifier" json:"modifier" form:"modifier"`
478
-	Remark                    string                    `gorm:"column:remark" json:"remark" form:"remark"`
479
-	Ctime                     int64                     `gorm:"column:ctime" json:"ctime" form:"ctime"`
480
-	Mtime                     int64                     `gorm:"column:mtime" json:"mtime" form:"mtime"`
481
-	Status                    int64                     `gorm:"column:status" json:"status" form:"status"`
482
-	WarehouseOutTime          int64                     `gorm:"column:warehouse_out_time" json:"warehouse_out_time" form:"warehouse_out_time"`
483
-	Dealer                    int64                     `gorm:"column:dealer" json:"dealer" form:"dealer"`
484
-	Manufacturer              int64                     `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
485
-	Type                      int64                     `gorm:"column:type" json:"type" form:"type"`
486
-	IsSys                     int64                     `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
487
-	SupplyCancelOutId         int64                     `gorm:"column:supply_cancel_out_id" json:"supply_cancel_out_id" form:"supply_cancel_out_id"`
488
-	SupplyWarehouseId         int64                     `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
489
-	StorehouseId              int64                     `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
490
-	SecondWarehouseId         int64                     `gorm:"column:second_warehouse_id" json:"second_warehouse_id" form:"second_warehouse_id"`
491
-	DrugWarehouseOutInfoTenty DrugWarehouseOutInfoTenty `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseOutId"json:"xt_drug_warehouse_out_info" `
510
+type DrugWarehouseInfoTwenty struct {
511
+	ID                        int64       `gorm:"column:id" json:"id" form:"id"`
512
+	WarehousingId             int64       `gorm:"column:warehousing_id" json:"warehousing_id" form:"warehousing_id"`
513
+	DrugId                    int64       `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
514
+	Number                    string      `gorm:"column:number" json:"number" form:"number"`
515
+	ProductDate               int64       `gorm:"column:product_date" json:"product_date" form:"product_date"`
516
+	ExpiryDate                int64       `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
517
+	WarehousingCount          int64       `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
518
+	Price                     float64     `gorm:"column:price" json:"price" form:"price"`
519
+	TotalPrice                float64     `gorm:"column:total_price" json:"total_price" form:"total_price"`
520
+	Dealer                    int64       `gorm:"column:dealer" json:"dealer" form:"dealer"`
521
+	Manufacturer              int64       `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
522
+	Remark                    string      `gorm:"column:remark" json:"remark" form:"remark"`
523
+	Ctime                     int64       `gorm:"column:ctime" json:"ctime" form:"ctime"`
524
+	Mtime                     int64       `gorm:"column:mtime" json:"mtime" form:"mtime"`
525
+	Status                    int64       `gorm:"column:status" json:"status" form:"status"`
526
+	OrgId                     int64       `gorm:"column:org_id" json:"org_id" form:"org_id"`
527
+	IsReturn                  int64       `gorm:"column:is_return" json:"is_return" form:"is_return"`
528
+	WarehousingOrder          string      `gorm:"column:warehousing_order" json:"warehousing_order" form:"warehousing_order"`
529
+	Type                      int64       `gorm:"column:type" json:"type" form:"type"`
530
+	RetailPrice               float64     `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
531
+	RetailTotalPrice          float64     `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
532
+	BatchNumber               string      `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
533
+	MaxUnit                   string      `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
534
+	MinUnit                   string      `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
535
+	StockMaxNumber            int64       `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
536
+	StockMinNumber            int64       `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
537
+	WarehousingInfoId         int64       `gorm:"column:warehousing_info_id" json:"warehousing_info_id" form:"warehousing_info_id"`
538
+	SupplyWarehouseId         int64       `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
539
+	SupplyWarehouseDetailInfo int64       `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
540
+	StorehouseId              int64       `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
541
+	SecondWarehouseInfoId     int64       `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
542
+	IsCheck                   int64       `gorm:"column:is_check" json:"is_check" form:"is_check"`
543
+	BaseDrugLib               BaseDrugLib `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId"json:"drug" `
492 544
 }
493 545
 
494
-func (DrugWarehouseOutTwenty) TableName() string {
495
-	return "xt_drug_warehouse_out"
546
+func (DrugWarehouseInfoTwenty) TableName() string {
547
+	return "xt_drug_warehouse_info"
496 548
 }

+ 1 - 0
models/good_models.go Vedi File

@@ -149,6 +149,7 @@ type XtCancelStockInfo struct {
149 149
 	Number          string   `gorm:"column:number" json:"number" form:"number"`
150 150
 	RegisterAccount string   `gorm:"column:register_account" json:"register_account" form:"register_account"`
151 151
 	Remark          string   `gorm:"column:remark" json:"remark" form:"remark"`
152
+	IsCheck         int64    `gorm:"column:is_check" json:"is_check" form:"is_check"`
152 153
 }
153 154
 
154 155
 func (XtCancelStockInfo) TableName() string {

+ 199 - 0
models/his_models.go Vedi File

@@ -2107,3 +2107,202 @@ type VmHisOrder struct {
2107 2107
 func (VmHisOrder) TableName() string {
2108 2108
 	return "his_order"
2109 2109
 }
2110
+
2111
+type HisOrderTenty struct {
2112
+	ID                           int64                        `gorm:"column:id" json:"id" form:"id"`
2113
+	UserOrgId                    int64                        `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2114
+	HisPatientId                 int64                        `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
2115
+	PsnCertType                  string                       `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
2116
+	SettleAccountsDate           int64                        `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
2117
+	Ctime                        int64                        `gorm:"column:ctime" json:"ctime" form:"ctime"`
2118
+	Mtime                        int64                        `gorm:"column:mtime" json:"mtime" form:"mtime"`
2119
+	Status                       int64                        `gorm:"column:status" json:"status" form:"status"`
2120
+	Number                       string                       `gorm:"column:number" json:"number" form:"number"`
2121
+	PatientId                    int64                        `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2122
+	Infcode                      int64                        `gorm:"column:infcode" json:"infcode" form:"infcode"`
2123
+	WarnMsg                      string                       `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
2124
+	Cainfo                       string                       `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
2125
+	ErrMsg                       string                       `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
2126
+	RespondTime                  string                       `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
2127
+	InfRefmsgid                  string                       `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
2128
+	OrderStatus                  int64                        `gorm:"column:order_status" json:"order_status" form:"order_status"`
2129
+	MdtrtId                      string                       `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
2130
+	SetlId                       string                       `gorm:"column:setl_id" json:"setl_id" form:"setl_id"`
2131
+	PsnNo                        string                       `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
2132
+	PsnName                      string                       `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
2133
+	Certno                       string                       `gorm:"column:certno" json:"certno" form:"certno"`
2134
+	Gend                         string                       `gorm:"column:gend" json:"gend" form:"gend"`
2135
+	Naty                         string                       `gorm:"column:naty" json:"naty" form:"naty"`
2136
+	Brdy                         time.Time                    `gorm:"column:brdy" json:"brdy" form:"brdy"`
2137
+	Age                          float64                      `gorm:"column:age" json:"age" form:"age"`
2138
+	Insutype                     string                       `gorm:"column:insutype" json:"insutype" form:"insutype"`
2139
+	PsnType                      string                       `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
2140
+	CvlservFlag                  string                       `gorm:"column:cvlserv_flag" json:"cvlserv_flag" form:"cvlserv_flag"`
2141
+	SetlTime                     string                       `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
2142
+	MdtrtCertType                string                       `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
2143
+	MedType                      string                       `gorm:"column:med_type" json:"med_type" form:"med_type"`
2144
+	MedfeeSumamt                 float64                      `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
2145
+	FulamtOwnpayAmt              float64                      `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
2146
+	OverlmtSelfPay               float64                      `gorm:"column:overlmt_self_pay" json:"overlmt_self_pay" form:"overlmt_self_pay"`
2147
+	PreselfpayAmt                float64                      `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
2148
+	InscpScpAmt                  float64                      `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
2149
+	ActPayDedc                   float64                      `gorm:"column:act_pay_dedc" json:"act_pay_dedc" form:"act_pay_dedc"`
2150
+	HifpPay                      float64                      `gorm:"column:hifp_pay" json:"hifp_pay" form:"hifp_pay"`
2151
+	CvlservPay                   float64                      `gorm:"column:cvlserv_pay" json:"cvlserv_pay" form:"cvlserv_pay"`
2152
+	PoolPropSelfpay              float64                      `gorm:"column:pool_prop_selfpay" json:"pool_prop_selfpay" form:"pool_prop_selfpay"`
2153
+	HifesPay                     float64                      `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
2154
+	HifmiPay                     float64                      `gorm:"column:hifmi_pay" json:"hifmi_pay" form:"hifmi_pay"`
2155
+	HifobPay                     float64                      `gorm:"column:hifob_pay" json:"hifob_pay" form:"hifob_pay"`
2156
+	MafPay                       float64                      `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
2157
+	OthPay                       float64                      `gorm:"column:oth_pay" json:"oth_pay" form:"oth_pay"`
2158
+	FundPaySumamt                float64                      `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
2159
+	PsnPartAmt                   float64                      `gorm:"column:psn_part_amt" json:"psn_part_amt" form:"psn_part_amt"`
2160
+	AcctPay                      float64                      `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
2161
+	PsnCashPay                   float64                      `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
2162
+	HospPartAmt                  float64                      `gorm:"column:hosp_part_amt" json:"hosp_part_amt" form:"hosp_part_amt"`
2163
+	Balc                         float64                      `gorm:"column:balc" json:"balc" form:"balc"`
2164
+	AcctMulaidPay                float64                      `gorm:"column:acct_mulaid_pay" json:"acct_mulaid_pay" form:"acct_mulaid_pay"`
2165
+	MedinsSetlId                 string                       `gorm:"column:medins_setl_id" json:"medins_setl_id" form:"medins_setl_id"`
2166
+	ClrOptins                    string                       `gorm:"column:clr_optins" json:"clr_optins" form:"clr_optins"`
2167
+	ClrWay                       string                       `gorm:"column:clr_way" json:"clr_way" form:"clr_way"`
2168
+	ClrType                      string                       `gorm:"column:clr_type" json:"clr_type" form:"clr_type"`
2169
+	SetlDetail                   string                       `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
2170
+	PayWay                       int64                        `gorm:"column:pay_way" json:"pay_way" form:"pay_way"`
2171
+	PayPrice                     float64                      `gorm:"column:pay_price" json:"pay_price" form:"pay_price"`
2172
+	PayCardNo                    string                       `gorm:"column:pay_card_no" json:"pay_card_no" form:"pay_card_no"`
2173
+	DiscountPrice                float64                      `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
2174
+	PreferentialPrice            float64                      `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
2175
+	RealityPrice                 float64                      `gorm:"column:reality_price" json:"reality_price" form:"reality_price"`
2176
+	FoundPrice                   float64                      `gorm:"column:found_price" json:"found_price" form:"found_price"`
2177
+	MedicalInsurancePrice        float64                      `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
2178
+	PrivatePrice                 float64                      `gorm:"column:private_price" json:"private_price" form:"private_price"`
2179
+	IsMedicineInsurance          int64                        `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
2180
+	SettleType                   int64                        `gorm:"column:settle_type" json:"settle_type" form:"settle_type"`
2181
+	SettleStartTime              int64                        `gorm:"column:settle_start_time" json:"settle_start_time" form:"settle_start_time"`
2182
+	SettleEndTime                int64                        `gorm:"column:settle_end_time" json:"settle_end_time" form:"settle_end_time"`
2183
+	Creator                      int64                        `gorm:"column:creator" json:"creator" form:"creator"`
2184
+	Modify                       int64                        `gorm:"column:modify" json:"modify" form:"modify"`
2185
+	SzChargeInfo                 string                       `gorm:"column:sz_charge_info" json:"sz_charge_info" form:"sz_charge_info"`
2186
+	SzProjectInfo                string                       `gorm:"column:sz_project_info" json:"sz_project_info" form:"sz_project_info"`
2187
+	SzMedicineInsuranceInfo      string                       `gorm:"column:sz_medicine_insurance_info" json:"sz_medicine_insurance_info" form:"sz_medicine_insurance_info"`
2188
+	AccountPrice                 string                       `gorm:"column:account_price" json:"account_price" form:"account_price"`
2189
+	MzNumber                     string                       `gorm:"column:mz_number" json:"mz_number" form:"mz_number"`
2190
+	OrgSetlNumber                string                       `gorm:"column:org_setl_number" json:"org_setl_number" form:"org_setl_number"`
2191
+	YiliaoNumber                 string                       `gorm:"column:yiliao_number" json:"yiliao_number" form:"yiliao_number"`
2192
+	RefundLog                    string                       `gorm:"column:refund_log" json:"refund_log" form:"refund_log"`
2193
+	DetailLog                    string                       `gorm:"column:detail_log" json:"detail_log" form:"detail_log"`
2194
+	FaPiaoCode                   string                       `gorm:"column:fa_piao_code" json:"fa_piao_code" form:"fa_piao_code"`
2195
+	FaPiaoNumber                 string                       `gorm:"column:fa_piao_number" json:"fa_piao_number" form:"fa_piao_number"`
2196
+	RequestLog                   string                       `gorm:"column:request_log" json:"request_log" form:"request_log"`
2197
+	RefundRequestLog             string                       `gorm:"column:refund_request_log" json:"refund_request_log" form:"refund_request_log"`
2198
+	PType                        int64                        `gorm:"column:p_type" json:"p_type" form:"p_type"`
2199
+	IsPre                        int64                        `gorm:"column:is_pre" json:"is_pre" form:"is_pre"`
2200
+	Diagnosis                    string                       `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
2201
+	FaPiaoBatchnumberId          int64                        `gorm:"column:fa_piao_batchnumber_id" json:"fa_piao_batchnumber_id" form:"fa_piao_batchnumber_id"`
2202
+	Decimal                      float64                      `gorm:"column:decimal" json:"decimal" form:"decimal"`
2203
+	HisOrderInfoTwenty           []*HisOrderInfoTwenty        `gorm:"ForeignKey:OrderId;AssociationForeignKey:ID" json:"order_info"`
2204
+	Patients                     Patients                     `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
2205
+	HisHospitalCheckRecordTwenty HisHospitalCheckRecordTwenty `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"hisPatient"`
2206
+}
2207
+
2208
+func (HisOrderTenty) TableName() string {
2209
+	return "his_order"
2210
+}
2211
+
2212
+type HisOrderInfoTwenty struct {
2213
+	ID                           int64                        `gorm:"column:id" json:"id" form:"id"`
2214
+	OrderNumber                  string                       `gorm:"column:order_number" json:"order_number" form:"order_number"`
2215
+	UploadDate                   int64                        `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
2216
+	AdviceId                     int64                        `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
2217
+	DetItemFeeSumamt             float64                      `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
2218
+	Cnt                          float64                      `gorm:"column:cnt" json:"cnt" form:"cnt"`
2219
+	Pric                         float64                      `gorm:"column:pric" json:"pric" form:"pric"`
2220
+	PatientId                    int64                        `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2221
+	PricUplmtAmt                 float64                      `gorm:"column:pric_uplmt_amt" json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
2222
+	SelfpayProp                  float64                      `gorm:"column:selfpay_prop" json:"selfpay_prop" form:"selfpay_prop"`
2223
+	FulamtOwnpayAmt              float64                      `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
2224
+	OverlmtAmt                   float64                      `gorm:"column:overlmt_amt" json:"overlmt_amt" form:"overlmt_amt"`
2225
+	PreselfpayAmt                float64                      `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
2226
+	BasMednFlag                  string                       `gorm:"column:bas_medn_flag" json:"bas_medn_flag" form:"bas_medn_flag"`
2227
+	MedChrgitmType               string                       `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
2228
+	HiNegoDrugFlag               string                       `gorm:"column:hi_nego_drug_flag" json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
2229
+	Status                       int64                        `gorm:"column:status" json:"status" form:"status"`
2230
+	Memo                         string                       `gorm:"column:memo" json:"memo" form:"memo"`
2231
+	FeedetlSn                    string                       `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
2232
+	Mtime                        int64                        `gorm:"column:mtime" json:"mtime" form:"mtime"`
2233
+	InscpScpAmt                  float64                      `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
2234
+	DrtReimFlag                  string                       `gorm:"column:drt_reim_flag" json:"drt_reim_flag" form:"drt_reim_flag"`
2235
+	Ctime                        int64                        `gorm:"column:ctime" json:"ctime" form:"ctime"`
2236
+	ListSpItemFlag               string                       `gorm:"column:list_sp_item_flag" json:"list_sp_item_flag" form:"list_sp_item_flag"`
2237
+	ChldMedcFlag                 string                       `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
2238
+	LmtUsedFlag                  string                       `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
2239
+	ChrgitmLv                    string                       `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
2240
+	UserOrgId                    int64                        `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2241
+	HisPatientId                 int64                        `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
2242
+	OrderId                      int64                        `gorm:"column:order_id" json:"order_id" form:"order_id"`
2243
+	ProjectId                    int64                        `gorm:"column:project_id" json:"project_id" form:"project_id"`
2244
+	Type                         int64                        `gorm:"column:type" json:"type" form:"type"`
2245
+	ItemId                       int64                        `gorm:"column:item_id" json:"item_id" form:"item_id"`
2246
+	Creator                      int64                        `gorm:"column:creator" json:"creator" form:"creator"`
2247
+	Modify                       int64                        `gorm:"column:modify" json:"modify" form:"modify"`
2248
+	OverPricPsnPay               float64                      `gorm:"column:over_pric_psn_pay" json:"over_pric_psn_pay" form:"over_pric_psn_pay"`
2249
+	AllowReimburse               float64                      `gorm:"column:allow_reimburse" json:"allow_reimburse" form:"allow_reimburse"`
2250
+	SettleType                   int64                        `gorm:"column:settle_type" json:"settle_type" form:"settle_type"`
2251
+	Patients                     Patients                     `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
2252
+	HisHospitalCheckRecordTwenty HisHospitalCheckRecordTwenty `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"hisPatient"`
2253
+	HisOrderTenty                HisOrderTenty                `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"order"`
2254
+	HisPrescriptionProject       HisPrescriptionProject       `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"his_prescription_project"`
2255
+	HisDoctorAdvice              HisDoctorAdvice              `gorm:"ForeignKey:ID;AssociationForeignKey:AdviceId" json:"his_doctor_advice"`
2256
+}
2257
+
2258
+func (HisOrderInfoTwenty) TableName() string {
2259
+	return "his_order_info"
2260
+}
2261
+
2262
+type HisHospitalCheckRecordTwenty struct {
2263
+	ID                   int64  `gorm:"column:id" json:"id" form:"id"`
2264
+	Name                 string `gorm:"column:name" json:"name" form:"name"`
2265
+	MedicalTreatmentType int64  `gorm:"column:medical_treatment_type" json:"medical_treatment_type" form:"medical_treatment_type"`
2266
+	RecordDate           int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
2267
+	IdCardNo             string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
2268
+	AdminUserId          int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
2269
+	Departments          int64  `gorm:"column:departments" json:"departments" form:"departments"`
2270
+	UserOrgId            int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2271
+	Status               int64  `gorm:"column:status" json:"status" form:"status"`
2272
+	Ctime                int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2273
+	Mtime                int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2274
+	PatientId            int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2275
+	Number               string `gorm:"column:number" json:"number" form:"number"`
2276
+	Doctor               int64  `gorm:"column:doctor" json:"doctor" form:"doctor"`
2277
+	PsnNo                string `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
2278
+	PsnCertType          string `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
2279
+	Certno               string `gorm:"column:certno" json:"certno" form:"certno"`
2280
+	PsnName              string `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
2281
+	Gend                 string `gorm:"column:gend" json:"gend" form:"gend"`
2282
+	Naty                 string `gorm:"column:naty" json:"naty" form:"naty"`
2283
+	MedType              int64  `gorm:"column:med_type" json:"med_type" form:"med_type"`
2284
+	Brdy                 string `gorm:"column:brdy" json:"brdy" form:"brdy"`
2285
+	Iinfo                string `gorm:"column:iinfo" json:"iinfo" form:"iinfo"`
2286
+	Idetinfo             string `gorm:"column:idetinfo" json:"idetinfo" form:"idetinfo"`
2287
+	IptOtpNo             string `gorm:"column:ipt_otp_no" json:"ipt_otp_no" form:"ipt_otp_no"`
2288
+	AdmBed               int64  `gorm:"column:adm_bed" json:"adm_bed" form:"adm_bed"`
2289
+	IdCardType           int64  `gorm:"column:id_card_type" json:"id_card_type" form:"id_card_type"`
2290
+	Diagnosis            string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
2291
+	InsutypeType         string `gorm:"column:insutype_type" json:"insutype_type" form:"insutype_type"`
2292
+	SickType             int64  `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
2293
+	MdtrtCertType        string `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
2294
+	InHosptialTime       string `gorm:"column:in_hosptial_time" json:"in_hosptial_time" form:"in_hosptial_time"`
2295
+	OutHosptialTime      string `gorm:"column:out_hosptial_time" json:"out_hosptial_time" form:"out_hosptial_time"`
2296
+	InHospitalStatus     int64  `gorm:"column:in_hospital_status" json:"in_hospital_status" form:"in_hospital_status"`
2297
+	Certificates         int64  `gorm:"column:certificates" json:"certificates" form:"certificates"`
2298
+	OutHospitalStatus    int64  `gorm:"column:out_hospital_status" json:"out_hospital_status" form:"out_hospital_status"`
2299
+	OutWay               int64  `gorm:"column:out_way" json:"out_way" form:"out_way"`
2300
+	Phone                string `gorm:"column:phone" json:"phone" form:"phone"`
2301
+	BalanceAccountsType  int64  `gorm:"column:balance_accounts_type" json:"balance_accounts_type" form:"balance_accounts_type"`
2302
+	PsnType              int64  `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
2303
+	InsuplcAdmdvs        string `gorm:"column:insuplc_admdvs" json:"insuplc_admdvs" form:"insuplc_admdvs"`
2304
+}
2305
+
2306
+func (HisHospitalCheckRecordTwenty) TableName() string {
2307
+	return "his_hospital_check_record"
2308
+}

+ 2 - 0
models/self_drug_models.go Vedi File

@@ -416,6 +416,7 @@ type XtDrugWarehouseInfo struct {
416 416
 	SupplyWarehouseId         int64      `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
417 417
 	SupplyWarehouseDetailInfo int64      `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
418 418
 	StorehouseId              int64      `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
419
+	IsCheck                   int64      `gorm:"column:is_check" json:"is_check" form:"is_check"`
419 420
 }
420 421
 
421 422
 func (XtDrugWarehouseInfo) TableName() string {
@@ -484,6 +485,7 @@ type BloodDrugWarehouseInfo struct {
484 485
 	DrugOriginPlace  string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
485 486
 	StorehouseId     int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
486 487
 	CountUnit        string  `json:"count_unit"`
488
+	IsCheck          string  `gorm:"column:is_check" json:"is_check" form:"is_check"`
487 489
 }
488 490
 
489 491
 type BloodDrugCancelStockInfo struct {

+ 48 - 0
models/stock_models.go Vedi File

@@ -68,6 +68,7 @@ type Warehousing struct {
68 68
 	StorehouseId      int64        `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
69 69
 	IsSys             int64        `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
70 70
 	SecondWarehouseId int64        `gorm:"column:second_warehouse_id" json:"second_warehouse_id" form:"second_warehouse_id"`
71
+	IsCheck           int64        `gorm:"column:is_check" json:"is_check" form:"is_check"`
71 72
 }
72 73
 
73 74
 func (Warehousing) TableName() string {
@@ -142,6 +143,8 @@ type WarehousingInfo struct {
142 143
 	SupplyWarehouseDetailInfo int64       `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
143 144
 	StorehouseId              int64       `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
144 145
 	SecondWarehouseInfoId     int64       `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
146
+	IsCheck                   int64       `gorm:"column:is_check" json:"is_check" form:"is_check"`
147
+	RegisterNumber            string      `gorm:"column:register_number" json:"register_number" form:"register_number"`
145 148
 }
146 149
 
147 150
 func (WarehousingInfo) TableName() string {
@@ -189,6 +192,7 @@ type VmWarehousingInfo struct {
189 192
 	Count             int64       `gorm:json:"count"`
190 193
 	PackingPrice      float64     `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
191 194
 	StorehouseId      int64       `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
195
+	IsCheck           int64       `gorm:"column:is_check" json:"is_check" form:"is_check"`
192 196
 }
193 197
 
194 198
 type WarehouseOut struct {
@@ -213,6 +217,7 @@ type WarehouseOut struct {
213 217
 	SupplyWarehouseId       int64        `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
214 218
 	StorehouseId            int64        `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
215 219
 	SecondWarehouseId       int64        `gorm:"column:second_warehouse_id" json:"second_warehouse_id" form:"second_warehouse_id"`
220
+	IsCheck                 int64        `gorm:"column:is_check" json:"is_check" form:"is_check"`
216 221
 }
217 222
 
218 223
 func (WarehouseOut) TableName() string {
@@ -258,6 +263,8 @@ type WarehouseOutInfo struct {
258 263
 	AdminUserId             int64        `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
259 264
 	BuyPrice                float64      `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
260 265
 	StockCount              string       `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
266
+	IsCheck                 int64        `gorm:"column:is_check" json:"is_check" form:"is_check"`
267
+	RegisterNumber          string       `gorm:"column:register_number" json:"register_number" form:"register_number"`
261 268
 }
262 269
 
263 270
 func (WarehouseOutInfo) TableName() string {
@@ -358,6 +365,7 @@ type CancelStock struct {
358 365
 	Type              int64                `gorm:"column:type" json:"type"`
359 366
 	XtCancelStockInfo []*XtCancelStockInfo `gorm:"ForeignKey:CancelStockId;AssociationForeignKey:ID" json:"XtCancelStockInfo"`
360 367
 	StorehouseId      int64                `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
368
+	IsCheck           int64                `gorm:"column:is_check" json:"is_check" form:"is_check"`
361 369
 }
362 370
 
363 371
 func (CancelStock) TableName() string {
@@ -623,6 +631,7 @@ type VmStockFlow struct {
623 631
 	AdminUserId               int64   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
624 632
 	BuyPrice                  float64 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
625 633
 	StockCount                string  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
634
+	RegisterNumber            string  `gorm:"column:register_number" json:"register_number" form:"register_number"`
626 635
 }
627 636
 
628 637
 func (VmStockFlow) TableName() string {
@@ -657,6 +666,7 @@ type CancelStockInfo struct {
657 666
 	PatientId       int64              `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
658 667
 	RecordDate      int64              `gorm:"column:record_date" json:"record_date" form:"record_date"`
659 668
 	StorehouseId    int64              `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
669
+	IsCheck         int64              `gorm:"column:is_check" json:"is_check" form:"is_check"`
660 670
 }
661 671
 
662 672
 func (CancelStockInfo) TableName() string {
@@ -889,6 +899,7 @@ type BloodWarehouseInfo struct {
889 899
 	PackingUnit       string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
890 900
 	BuyPrice          float64 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
891 901
 	StorehouseId      int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
902
+	IsCheck           string  `gorm:"column:is_check" json:"is_check" form:"is_check"`
892 903
 }
893 904
 
894 905
 type XtStockAdjustPrice struct {
@@ -1391,3 +1402,40 @@ type DrugOutConfig struct {
1391 1402
 func (DrugOutConfig) TableName() string {
1392 1403
 	return "xt_drug_out_config"
1393 1404
 }
1405
+
1406
+type VmWarehousingInfoSix struct {
1407
+	ID                        int64    `gorm:"column:id" json:"id"`
1408
+	WarehousingId             int64    `gorm:"column:warehousing_id" json:"warehousing_id"`
1409
+	GoodId                    int64    `gorm:"column:good_id" json:"good_id"`
1410
+	GoodTypeId                int64    `gorm:"column:good_type_id" json:"good_type_id"`
1411
+	Number                    string   `gorm:"column:number" json:"number"`
1412
+	ProductDate               int64    `gorm:"column:product_date" json:"product_date"`
1413
+	ExpiryDate                int64    `gorm:"column:expiry_date" json:"expiry_date"`
1414
+	WarehousingCount          int64    `gorm:"column:warehousing_count" json:"warehousing_count"`
1415
+	WarehousingUnit           string   `gorm:"column:warehousing_unit" json:"warehousing_unit"`
1416
+	Price                     float64  `gorm:"column:price" json:"price"`
1417
+	TotalPrice                float64  `gorm:"column:total_price" json:"total_price"`
1418
+	Dealer                    int64    `gorm:"column:dealer" json:"dealer"`
1419
+	Manufacturer              int64    `gorm:"column:manufacturer" json:"manufacturer"`
1420
+	Remark                    string   `gorm:"column:remark" json:"remark"`
1421
+	Ctime                     int64    `gorm:"column:ctime" json:"ctime"`
1422
+	Mtime                     int64    `gorm:"column:mtime" json:"mtime"`
1423
+	Status                    int64    `gorm:"column:status" json:"status"`
1424
+	OrgId                     int64    `gorm:"column:org_id" json:"org_id"`
1425
+	IsReturn                  int64    `gorm:"column:is_return" json:"is_return"`
1426
+	StockCount                int64    `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
1427
+	WarehousingOrder          string   `gorm:"column:warehousing_order" json:"warehousing_order"`
1428
+	GoodInfo                  GoodInfo `gorm:"ForeignKey:ID;AssociationForeignKey:GoodId" `
1429
+	Type                      int64    `gorm:"column:type" json:"type"`
1430
+	LicenseNumber             string   `gorm:"column:license_number" json:"license_number" form:"license_number"`
1431
+	WarehouseInfoId           int64    `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
1432
+	PackingPrice              float64  `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
1433
+	SupplyWarehouseId         int64    `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
1434
+	SupplyWarehouseDetailInfo int64    `gorm:"column:supply_warehouse_detail_info" json:"supply_warehouse_detail_info" form:"supply_warehouse_detail_info"`
1435
+	StorehouseId              int64    `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
1436
+	SecondWarehouseInfoId     int64    `gorm:"column:second_warehouse_info_id" json:"second_warehouse_info_id" form:"second_warehouse_info_id"`
1437
+}
1438
+
1439
+func (VmWarehousingInfoSix) TableName() string {
1440
+	return "xt_warehouse_info"
1441
+}

+ 4 - 4
service/gobal_config_service.go Vedi File

@@ -278,7 +278,7 @@ func GetDrugInOrderDetail(startime int64, endtime int64, orgid int64, orderType
278 278
 	likeKey := "%" + keyword + "%"
279 279
 	offset := (page - 1) * limit
280 280
 
281
-	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
281
+	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1 and x.is_check = 1")
282 282
 	dbOne := XTReadDB().Table("xt_base_drug as t").Where("t.status =1")
283 283
 	dbTwo := XTReadDB().Table("xt_drug_warehouse as s").Where("s.status = 1")
284 284
 	dbThree := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
@@ -352,7 +352,7 @@ func GetDrugOutOrder(startime int64, endtime int64, orgid int64, orderType int64
352 352
 
353 353
 	likeKey := "%" + keyword + "%"
354 354
 	offset := (page - 1) * limit
355
-	db := XTReadDB().Table("xt_drug_warehouse_out_info as x").Where("x.status =1")
355
+	db := XTReadDB().Table("xt_drug_warehouse_out_info as x").Where("x.status =1 and x.is_check = 1")
356 356
 	dbOne := XTReadDB().Table("xt_base_drug as b").Where("b.status =1")
357 357
 	dbTwo := XTReadDB().Table("xt_drug_warehouse_out as t").Where("t.status = 1")
358 358
 	fmt.Print(dbOne, dbTwo)
@@ -654,7 +654,7 @@ func GetAllBaseDurgListCount(page int64, limit int64, keyword string, drugcatego
654 654
 		if storehouse_id > 0 {
655 655
 			db = db.Where("storehouse_id = ?", storehouse_id)
656 656
 		}
657
-		return db.Where("status = 1")
657
+		return db.Where("status = 1 and is_check = 1")
658 658
 	}).Preload("DrugCancelStockInfo", func(db *gorm.DB) *gorm.DB {
659 659
 		if startime > 0 {
660 660
 			db = db.Where("ctime>=?", startime)
@@ -744,7 +744,7 @@ func GetDrugStockOutFlow(drugid int64, startime int64, endtime int64, page int64
744 744
 
745 745
 func GetBatchOrderDetail(drugid int64, orgid int64, page int64, limit int64) (drug []*models.DrugWarehouseInfo, total int64, err error) {
746 746
 	offset := (page - 1) * limit
747
-	err = XTReadDB().Model(&drug).Where("drug_id = ? and org_id = ? and status = 1", drugid, orgid).Count(&total).Offset(offset).Limit(limit).Order("id desc").Find(&drug).Error
747
+	err = XTReadDB().Model(&drug).Where("drug_id = ? and org_id = ? and status = 1 and is_check = 1", drugid, orgid).Count(&total).Offset(offset).Limit(limit).Order("id desc").Find(&drug).Error
748 748
 	return drug, total, err
749 749
 }
750 750
 

+ 403 - 2
service/manage_center_service.go Vedi File

@@ -2,7 +2,10 @@ package service
2 2
 
3 3
 import (
4 4
 	"XT_New/models"
5
+	"fmt"
5 6
 	"github.com/jinzhu/gorm"
7
+	"strconv"
8
+	"strings"
6 9
 	"time"
7 10
 )
8 11
 
@@ -169,12 +172,12 @@ func FindAllDrugLibRecordTotal(org_id int64) (count int64) {
169 172
 }
170 173
 
171 174
 func FindBaseDrugLibRecord(org_id int64, id int64) (lib models.BaseDrugLib, err error) {
172
-	err = readDb.Model(&models.BaseDrugLib{}).Where("org_id = ? AND id = ? AND status = 1", org_id, id).First(&lib).Error
175
+	err = readDb.Model(&models.BaseDrugLib{}).Where("id = ? AND org_id = ?  AND status = 1", id, org_id).First(&lib).Error
173 176
 	return
174 177
 }
175 178
 
176 179
 func FindBaseDrugLibRecordSeven(org_id int64, id int64) (lib models.BaseDrugLibSeven, err error) {
177
-	err = readDb.Select("id,drug_name,max_unit,min_number,min_unit,sum_count").Where("org_id = ? AND id = ? AND status = 1", org_id, id).First(&lib).Error
180
+	err = readDb.Select("id,drug_name,max_unit,min_number,min_unit,sum_count,is_user").Where("org_id = ? AND id = ? AND status = 1", org_id, id).First(&lib).Error
178 181
 	return
179 182
 }
180 183
 
@@ -202,6 +205,12 @@ func GetDrugAutoWarehouseOutSeven(patient_id int64, advicedate int64, drugid int
202 205
 	return &detail, nil
203 206
 }
204 207
 
208
+func GetDrugAutoWarehouseOutEight(patient_id int64, advicedate int64, drugid int64, adviceid int64) (models.DrugWarehouseOutInfo, error) {
209
+	detail := models.DrugWarehouseOutInfo{}
210
+	err = XTReadDB().Model(&detail).Where("patient_id = ? and sys_record_time =? and drug_id = ? and status = 1 and advice_id = ?", patient_id, advicedate, drugid, adviceid).Find(&detail).Error
211
+	return detail, err
212
+}
213
+
205 214
 func UpdateDrugWarehouse(id int64, info models.DrugWarehouseInfo) error {
206 215
 	err := writeDb.Model(&models.DrugWarehouseInfo{}).Where("id = ?", id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number + ?", info.StockMinNumber)).Error
207 216
 	return err
@@ -411,3 +420,395 @@ func GetAllDrugList(orgid int64) (drug []*models.BaseDrugLib, err error) {
411 420
 	err = XTReadDB().Model(&drug).Where("org_id = ? and status = 1", orgid).Find(&drug).Error
412 421
 	return drug, err
413 422
 }
423
+
424
+//自动退库分装方法
425
+
426
+func DrugAutoAddCancelInfo(advice *models.HisDoctorAdviceInfo, creater int64) error {
427
+
428
+	//查询该病人该药品是否有库存记录
429
+	info, _ := GetDrugAutoWarehouseOutEight(advice.PatientId, advice.AdviceDate, advice.DrugId, advice.ID)
430
+	storeHouseConfig, _ := GetAllStoreHouseConfig(advice.UserOrgId)
431
+	//如果剩余数量 + 退库数量 < 总入库数量
432
+	if info.ID > 0 {
433
+		//查询该药品出库批次总入库数量
434
+		druginfo, error := GetDrugInfoSix(info.WarehouseInfoId, info.OrgId)
435
+		fmt.Println(error)
436
+		//退库
437
+		drug, _ := FindBaseDrugLibRecord(advice.UserOrgId, advice.DrugId)
438
+		var out_count int64  //该批次出库库存
439
+		var sum_count int64  //该批次总库存
440
+		var over_count int64 //剩余数量
441
+
442
+		over_count = druginfo.StockMaxNumber*drug.MinNumber + druginfo.StockMinNumber
443
+		if info.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
444
+			out_count = info.Count * drug.MinNumber
445
+
446
+		}
447
+		if info.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
448
+			out_count = info.Count
449
+		}
450
+
451
+		if info.CountUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
452
+			out_count = info.Count
453
+		}
454
+
455
+		if druginfo.MaxUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
456
+			sum_count = druginfo.WarehousingCount * drug.MinNumber
457
+		}
458
+
459
+		if druginfo.MaxUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
460
+			sum_count = druginfo.WarehousingCount
461
+		}
462
+
463
+		if druginfo.MaxUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
464
+			sum_count = druginfo.WarehousingCount
465
+		}
466
+
467
+		fmt.Println("该批次剩余库存", over_count)
468
+		fmt.Println("该批次退库数量", out_count)
469
+		fmt.Println("该批次总入库数量", sum_count)
470
+		if (over_count + out_count) <= sum_count {
471
+
472
+			if advice.PrescribingNumberUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
473
+
474
+				floatPrescrip := strconv.FormatFloat(advice.PrescribingNumber, 'f', -1, 32)
475
+				prescribingNumber, _ := strconv.ParseInt(floatPrescrip, 10, 64)
476
+
477
+				//退库
478
+				warehouseInfo := models.DrugWarehouseInfo{
479
+					StockMinNumber: prescribingNumber,
480
+				}
481
+				UpdateDrugWarehouse(info.WarehouseInfoId, warehouseInfo)
482
+
483
+				operation_time := time.Now().Unix()
484
+
485
+				ctime := time.Now().Unix()
486
+				timeStr := time.Now().Format("2006-01-02")
487
+				timeArr := strings.Split(timeStr, "-")
488
+				total, _ := FindAllDrugCancelStockTotal(advice.UserOrgId)
489
+				total = total + 1
490
+				orderNumber := "CKTKD" + strconv.FormatInt(advice.UserOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
491
+				cancelStock := models.DrugCancelStock{
492
+					OrderNumber:  orderNumber,
493
+					OperaTime:    operation_time,
494
+					OrgId:        advice.UserOrgId,
495
+					Creater:      creater,
496
+					Ctime:        ctime,
497
+					Status:       1,
498
+					ReturnTime:   advice.AdviceDate,
499
+					Dealer:       info.Dealer,
500
+					Manufacturer: info.Manufacturer,
501
+					Type:         1,
502
+					StorehouseId: storeHouseConfig.DrugStorehouseOut,
503
+					IsCheck:      1,
504
+				}
505
+				AddSigleDrugCancelStock(&cancelStock)
506
+
507
+				manufactureName, _ := GetManufactureById(info.Manufacturer)
508
+				dealer, _ := GetDealerById(info.Dealer)
509
+				cancelInfo, _ := GetLastDrugCancelStockById(advice.UserOrgId)
510
+				cancelStockInfo := models.DrugCancelStockInfo{
511
+					OrderNumber:      cancelInfo.OrderNumber,
512
+					CancelStockId:    cancelInfo.ID,
513
+					DrugId:           info.DrugId,
514
+					Count:            info.Count,
515
+					Status:           1,
516
+					Ctime:            ctime,
517
+					OrgId:            advice.UserOrgId,
518
+					Type:             1,
519
+					Manufacturer:     manufactureName.ManufacturerName,
520
+					Dealer:           dealer.DealerName,
521
+					Total:            0,
522
+					RetailPrice:      info.RetailPrice,
523
+					RetailTotalPrice: info.RetailTotalPrice,
524
+					Price:            info.Price,
525
+					RegisterAccount:  "",
526
+					Remark:           info.Remark,
527
+					BatchNumber:      info.BatchNumber,
528
+					MaxUnit:          info.CountUnit,
529
+					ProductDate:      info.ProductDate,
530
+					ExpiryDate:       info.ExpiryDate,
531
+					BatchNumberId:    info.WarehouseInfoId,
532
+					StorehouseId:     storeHouseConfig.DrugStorehouseOut,
533
+					IsCheck:          1,
534
+				}
535
+
536
+				flow := models.DrugFlow{
537
+					WarehousingId:           0,
538
+					DrugId:                  info.DrugId,
539
+					Number:                  "",
540
+					BatchNumber:             info.BatchNumber,
541
+					Count:                   info.Count,
542
+					UserOrgId:               advice.UserOrgId,
543
+					PatientId:               0,
544
+					SystemTime:              info.SysRecordTime,
545
+					ConsumableType:          7,
546
+					IsSys:                   0,
547
+					WarehousingOrder:        "",
548
+					WarehouseOutId:          0,
549
+					WarehouseOutOrderNumber: info.WarehouseOutOrderNumber,
550
+					IsEdit:                  0,
551
+					CancelStockId:           cancelStock.ID,
552
+					CancelOrderNumber:       cancelStock.OrderNumber,
553
+					Manufacturer:            info.Manufacturer,
554
+					Dealer:                  info.Dealer,
555
+					Creator:                 creater,
556
+					UpdateCreator:           0,
557
+					Status:                  1,
558
+					Ctime:                   time.Now().Unix(),
559
+					Mtime:                   0,
560
+					Price:                   info.Price,
561
+					WarehousingDetailId:     0,
562
+					WarehouseOutDetailId:    0,
563
+					CancelOutDetailId:       0,
564
+					ExpireDate:              info.ExpiryDate,
565
+					ProductDate:             info.ProductDate,
566
+					MaxUnit:                 info.CountUnit,
567
+					MinUnit:                 "",
568
+					AdviceId:                info.AdviceId,
569
+					StorehouseId:            storeHouseConfig.DrugStorehouseOut,
570
+				}
571
+				CreatedCancelStock(cancelStockInfo)
572
+				CreateDrugFlowOne(flow)
573
+
574
+				//删除出库记录
575
+				UpdateDrugFlowSeven(info.PatientId, info.SysRecordTime, info.DrugId, advice.ID, info.ID, info.WarehouseOutId)
576
+				//删除流水
577
+				UpdateDrugFlowTens(info.PatientId, info.WarehouseOutOrderNumber, info.DrugId, advice.ID, info.ID)
578
+			}
579
+			if advice.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
580
+
581
+				houseConfig, _ := GetAllStoreHouseConfig(advice.UserOrgId)
582
+				floatPrescrip := strconv.FormatFloat(advice.PrescribingNumber, 'f', -1, 32)
583
+
584
+				prescribingNumber, _ := strconv.ParseInt(floatPrescrip, 10, 64)
585
+
586
+				if advice.PrescribingNumberUnit == drug.MaxUnit {
587
+					warehouseInfo := models.DrugWarehouseInfo{
588
+						StockMaxNumber: prescribingNumber,
589
+					}
590
+					UpdateDrugWarehouseOne(info.WarehouseInfoId, warehouseInfo)
591
+
592
+				}
593
+
594
+				operation_time := time.Now().Unix()
595
+				ctime := time.Now().Unix()
596
+				timeStr := time.Now().Format("2006-01-02")
597
+				timeArr := strings.Split(timeStr, "-")
598
+				total, _ := FindAllDrugCancelStockTotal(advice.UserOrgId)
599
+				total = total + 1
600
+				orderNumber := "CKTKD" + strconv.FormatInt(advice.UserOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
601
+
602
+				cancelStock := models.DrugCancelStock{
603
+					OrderNumber:  orderNumber,
604
+					OperaTime:    operation_time,
605
+					OrgId:        advice.UserOrgId,
606
+					Creater:      creater,
607
+					Ctime:        ctime,
608
+					Status:       1,
609
+					ReturnTime:   advice.AdviceDate,
610
+					Dealer:       info.Dealer,
611
+					Manufacturer: info.Manufacturer,
612
+					Type:         1,
613
+					StorehouseId: houseConfig.DrugStorehouseOut,
614
+					IsCheck:      1,
615
+				}
616
+				AddSigleDrugCancelStock(&cancelStock)
617
+				fmt.Println("到这里了吗32222222222222222222222222222222222222222222222")
618
+
619
+				manufactureName, _ := GetManufactureById(info.Manufacturer)
620
+				dealer, _ := GetDealerById(info.Dealer)
621
+				cancelInfo, _ := GetLastDrugCancelStockById(advice.UserOrgId)
622
+				cancelStockInfo := models.DrugCancelStockInfo{
623
+					OrderNumber:      cancelInfo.OrderNumber,
624
+					CancelStockId:    cancelInfo.ID,
625
+					DrugId:           info.DrugId,
626
+					Count:            info.Count,
627
+					Status:           1,
628
+					Ctime:            ctime,
629
+					OrgId:            advice.UserOrgId,
630
+					Type:             1,
631
+					Manufacturer:     manufactureName.ManufacturerName,
632
+					Dealer:           dealer.DealerName,
633
+					Total:            0,
634
+					RetailPrice:      info.RetailPrice,
635
+					RetailTotalPrice: info.RetailTotalPrice,
636
+					Price:            info.Price,
637
+					RegisterAccount:  "",
638
+					Remark:           info.Remark,
639
+					BatchNumber:      info.BatchNumber,
640
+					MaxUnit:          info.CountUnit,
641
+					ProductDate:      info.ProductDate,
642
+					ExpiryDate:       info.ExpiryDate,
643
+					BatchNumberId:    info.WarehouseInfoId,
644
+					StorehouseId:     houseConfig.DrugStorehouseOut,
645
+					IsCheck:          1,
646
+				}
647
+
648
+				flow := models.DrugFlow{
649
+					WarehousingId:           0,
650
+					DrugId:                  info.DrugId,
651
+					Number:                  "",
652
+					BatchNumber:             info.BatchNumber,
653
+					Count:                   info.Count,
654
+					UserOrgId:               advice.UserOrgId,
655
+					PatientId:               0,
656
+					SystemTime:              info.SysRecordTime,
657
+					ConsumableType:          7,
658
+					IsSys:                   0,
659
+					WarehousingOrder:        "",
660
+					WarehouseOutId:          0,
661
+					WarehouseOutOrderNumber: info.WarehouseOutOrderNumber,
662
+					IsEdit:                  0,
663
+					CancelStockId:           cancelStock.ID,
664
+					CancelOrderNumber:       cancelStock.OrderNumber,
665
+					Manufacturer:            info.Manufacturer,
666
+					Dealer:                  info.Dealer,
667
+					Creator:                 creater,
668
+					UpdateCreator:           0,
669
+					Status:                  1,
670
+					Ctime:                   time.Now().Unix(),
671
+					Mtime:                   0,
672
+					Price:                   info.Price,
673
+					WarehousingDetailId:     0,
674
+					WarehouseOutDetailId:    0,
675
+					CancelOutDetailId:       0,
676
+					ExpireDate:              info.ExpiryDate,
677
+					ProductDate:             info.ProductDate,
678
+					MaxUnit:                 info.CountUnit,
679
+					MinUnit:                 "",
680
+					AdviceId:                info.AdviceId,
681
+					StorehouseId:            houseConfig.DrugStorehouseOut,
682
+				}
683
+				CreatedCancelStock(cancelStockInfo)
684
+				CreateDrugFlowOne(flow)
685
+				//删除出库记录
686
+				UpdateDrugFlowSeven(info.PatientId, info.SysRecordTime, info.DrugId, advice.ID, info.ID, info.WarehouseOutId)
687
+				//删除流水
688
+				UpdateDrugFlowTens(info.PatientId, info.WarehouseOutOrderNumber, info.DrugId, advice.ID, info.ID)
689
+			}
690
+
691
+			if advice.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
692
+
693
+				houseConfig, _ := GetAllStoreHouseConfig(advice.UserOrgId)
694
+				floatPrescrip := strconv.FormatFloat(advice.PrescribingNumber, 'f', -1, 32)
695
+
696
+				prescribingNumber, _ := strconv.ParseInt(floatPrescrip, 10, 64)
697
+
698
+				if advice.PrescribingNumberUnit == drug.MaxUnit {
699
+					warehouseInfo := models.DrugWarehouseInfo{
700
+						StockMaxNumber: prescribingNumber,
701
+					}
702
+					UpdateDrugWarehouseOne(info.WarehouseInfoId, warehouseInfo)
703
+
704
+				}
705
+
706
+				operation_time := time.Now().Unix()
707
+				ctime := time.Now().Unix()
708
+				timeStr := time.Now().Format("2006-01-02")
709
+				timeArr := strings.Split(timeStr, "-")
710
+				total, _ := FindAllDrugCancelStockTotal(advice.UserOrgId)
711
+				total = total + 1
712
+				orderNumber := "CKTKD" + strconv.FormatInt(advice.UserOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
713
+
714
+				cancelStock := models.DrugCancelStock{
715
+					OrderNumber:  orderNumber,
716
+					OperaTime:    operation_time,
717
+					OrgId:        advice.UserOrgId,
718
+					Creater:      creater,
719
+					Ctime:        ctime,
720
+					Status:       1,
721
+					ReturnTime:   advice.AdviceDate,
722
+					Dealer:       info.Dealer,
723
+					Manufacturer: info.Manufacturer,
724
+					Type:         1,
725
+					StorehouseId: houseConfig.DrugStorehouseOut,
726
+					IsCheck:      1,
727
+				}
728
+				AddSigleDrugCancelStock(&cancelStock)
729
+				fmt.Println("到这里了吗32222222222222222222222222222222222222222222222")
730
+
731
+				manufactureName, _ := GetManufactureById(info.Manufacturer)
732
+				dealer, _ := GetDealerById(info.Dealer)
733
+				cancelInfo, _ := GetLastDrugCancelStockById(advice.UserOrgId)
734
+				cancelStockInfo := models.DrugCancelStockInfo{
735
+					OrderNumber:      cancelInfo.OrderNumber,
736
+					CancelStockId:    cancelInfo.ID,
737
+					DrugId:           info.DrugId,
738
+					Count:            info.Count,
739
+					Status:           1,
740
+					Ctime:            ctime,
741
+					OrgId:            advice.UserOrgId,
742
+					Type:             1,
743
+					Manufacturer:     manufactureName.ManufacturerName,
744
+					Dealer:           dealer.DealerName,
745
+					Total:            0,
746
+					RetailPrice:      info.RetailPrice,
747
+					RetailTotalPrice: info.RetailTotalPrice,
748
+					Price:            info.Price,
749
+					RegisterAccount:  "",
750
+					Remark:           info.Remark,
751
+					BatchNumber:      info.BatchNumber,
752
+					MaxUnit:          info.CountUnit,
753
+					ProductDate:      info.ProductDate,
754
+					ExpiryDate:       info.ExpiryDate,
755
+					BatchNumberId:    info.WarehouseInfoId,
756
+					StorehouseId:     houseConfig.DrugStorehouseOut,
757
+					IsCheck:          1,
758
+				}
759
+
760
+				flow := models.DrugFlow{
761
+					WarehousingId:           0,
762
+					DrugId:                  info.DrugId,
763
+					Number:                  "",
764
+					BatchNumber:             info.BatchNumber,
765
+					Count:                   info.Count,
766
+					UserOrgId:               advice.UserOrgId,
767
+					PatientId:               0,
768
+					SystemTime:              info.SysRecordTime,
769
+					ConsumableType:          7,
770
+					IsSys:                   0,
771
+					WarehousingOrder:        "",
772
+					WarehouseOutId:          0,
773
+					WarehouseOutOrderNumber: info.WarehouseOutOrderNumber,
774
+					IsEdit:                  0,
775
+					CancelStockId:           cancelStock.ID,
776
+					CancelOrderNumber:       cancelStock.OrderNumber,
777
+					Manufacturer:            info.Manufacturer,
778
+					Dealer:                  info.Dealer,
779
+					Creator:                 creater,
780
+					UpdateCreator:           0,
781
+					Status:                  1,
782
+					Ctime:                   time.Now().Unix(),
783
+					Mtime:                   0,
784
+					Price:                   info.Price,
785
+					WarehousingDetailId:     0,
786
+					WarehouseOutDetailId:    0,
787
+					CancelOutDetailId:       0,
788
+					ExpireDate:              info.ExpiryDate,
789
+					ProductDate:             info.ProductDate,
790
+					MaxUnit:                 info.CountUnit,
791
+					MinUnit:                 "",
792
+					AdviceId:                info.AdviceId,
793
+					StorehouseId:            houseConfig.DrugStorehouseOut,
794
+				}
795
+				CreatedCancelStock(cancelStockInfo)
796
+				CreateDrugFlowOne(flow)
797
+				//删除出库记录
798
+				UpdateDrugFlowSeven(info.PatientId, info.SysRecordTime, info.DrugId, advice.ID, info.ID, info.WarehouseOutId)
799
+				//删除流水
800
+				UpdateDrugFlowTens(info.PatientId, info.WarehouseOutOrderNumber, info.DrugId, advice.ID, info.ID)
801
+			}
802
+		}
803
+		//更新字典里面的库存
804
+		stockInfo, _ := GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, advice.UserOrgId, advice.DrugId)
805
+		//查询改药品信息
806
+		medical, _ := GetBaseDrugMedical(advice.DrugId)
807
+		var sum_count_one int64
808
+		for _, its := range stockInfo {
809
+			sum_count_one += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
810
+		}
811
+		UpdateBaseDrugSumTwo(advice.DrugId, sum_count_one, advice.UserOrgId)
812
+	}
813
+	return err
814
+}

+ 1 - 1
service/mobile_dialysis_service.go Vedi File

@@ -795,7 +795,7 @@ func MobileGetDoctorAdvicesByGroups(orgID int64, patientID int64, recordDate int
795 795
 // 透析记录
796 796
 func MobileGetSchedualDialysisRecordTen(orgID int64, patientID int64, recordDate int64) (*models.DialysisOrder, error) {
797 797
 	var record models.DialysisOrder
798
-	err := readDb.Model(&models.DialysisOrder{}).Preload("DeviceNumber", "org_id = ? AND  status = 1", orgID).Where("user_org_id = ? AND patient_id = ? AND  dialysis_date = ?", orgID, patientID, recordDate).First(&record).Error
798
+	err := readDb.Model(&models.DialysisOrder{}).Preload("DeviceNumber", "org_id = ?", orgID).Where("user_org_id = ? AND patient_id = ? AND  dialysis_date = ?", orgID, patientID, recordDate).First(&record).Error
799 799
 	if err != nil {
800 800
 		if err == gorm.ErrRecordNotFound {
801 801
 			return nil, nil

+ 2 - 2
service/patient_service.go Vedi File

@@ -569,8 +569,8 @@ func FindPatientByIdWithDiseases(orgID int64, id int64) (patient models.Patients
569 569
 
570 570
 func FindPatientWithDeviceByNo(orgID int64, no string, time int64) (patient models.SchedualPatient2, err error) {
571 571
 	err = readDb.Preload("DialysisSchedule", func(db *gorm.DB) *gorm.DB {
572
-		return db.Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
573
-			Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
572
+		return db.Preload("DeviceNumber", "org_id = ?", orgID).
573
+			Preload("DeviceZone", "org_id = ?", orgID).
574 574
 			Where("user_org_id = ? AND schedule_date = ? ", orgID, time)
575 575
 	}).Preload("InfectiousDiseases", "status = 1").Where("user_org_id=? and dialysis_no = ? and status=1", orgID, no).First(&patient).Error
576 576
 	return

+ 2 - 2
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go Vedi File

@@ -33,8 +33,8 @@ func GetSchedules(orgID int64, schIDs []string) ([]*ScheduleVM, error) {
33 33
 		return db.Where("user_org_id = ? AND status = 1", orgID).
34 34
 			Order("operate_time asc")
35 35
 	}).
36
-		Preload("DeviceNumber", "org_id = ? AND status = 1", orgID).
37
-		Preload("DeviceZone", "org_id = ? AND status = 1", orgID).
36
+		Preload("DeviceNumber", "org_id = ?", orgID).
37
+		Preload("DeviceZone", "org_id = ?", orgID).
38 38
 		Preload("DoubleCheck", "user_org_id = ? AND status = 1", orgID).
39 39
 		Preload("Summer", "user_org_id = ? AND status = 1", orgID).
40 40
 		Preload("Advices", func(db *gorm.DB) *gorm.DB {

+ 2 - 2
service/secondary_service.go Vedi File

@@ -1086,7 +1086,7 @@ func GetStoreHouseDrugWarehouseingInfo(id int64) (models.DrugWarehouseInfo, erro
1086 1086
 
1087 1087
 func GetDrugSumCountByStorehouseId(storehouse_id int64, orgid int64, drug_id int64) (info []*models.DrugWarehouseInfo, err error) {
1088 1088
 
1089
-	err = XTReadDB().Where("storehouse_id = ? and org_id = ? and status = 1 and (stock_max_number >0 or stock_min_number>0) and drug_id =?", storehouse_id, orgid, drug_id).Find(&info).Error
1089
+	err = XTReadDB().Where("storehouse_id = ? and org_id = ? and status = 1 and (stock_max_number >0 or stock_min_number>0) and drug_id =? and is_check = 1", storehouse_id, orgid, drug_id).Find(&info).Error
1090 1090
 	return info, err
1091 1091
 }
1092 1092
 
@@ -1098,7 +1098,7 @@ func GetDrugSumCountByStorehouseIdSix(storehouse_id int64, orgid int64) (info []
1098 1098
 
1099 1099
 func GetGoodSumCountByStoreId(storehouse_id int64, goodid int64, orgid int64) (info []*models.WarehousingInfo, err error) {
1100 1100
 
1101
-	err = XTReadDB().Where("storehouse_id = ? and good_id = ? and org_id =? and status =1 and stock_count > 0", storehouse_id, goodid, orgid).Find(&info).Error
1101
+	err = XTReadDB().Where("storehouse_id = ? and good_id = ? and org_id =? and status =1 and stock_count > 0 and is_check = 1", storehouse_id, goodid, orgid).Find(&info).Error
1102 1102
 	return info, err
1103 1103
 }
1104 1104
 

+ 1 - 1
service/self_drug_service.go Vedi File

@@ -827,7 +827,7 @@ func GetLastDrugWarehouseOutInfo(drugid int64, warehouseOutId int64, orgid int64
827 827
 }
828 828
 
829 829
 func PostSearchDrugWarehouseList(keyword string, orgid int64, storehouse_id int64) (info []*models.BloodDrugWarehouseInfo, err error) {
830
-	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
830
+	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1 and x.is_check = 1")
831 831
 	table := XTReadDB().Table("xt_base_drug as t").Where("t.status")
832 832
 	fmt.Println(table)
833 833
 	likeKey := "%" + keyword + "%"

+ 641 - 61
service/stock_service.go Vedi File

@@ -534,11 +534,11 @@ func CreateDrugWarehousingInfoSix(warehousingInfo []*models.DrugWarehouseInfo) (
534 534
 	if len(warehousingInfo) > 0 {
535 535
 		utx := writeDb.Begin()
536 536
 		if len(warehousingInfo) > 0 {
537
-			thisSQL := "INSERT INTO xt_drug_warehouse_info (warehousing_id, drug_id, number, product_date,expiry_date,warehousing_count,price,total_price,dealer,manufacturer,remark,ctime,mtime,status,org_id,warehousing_order,type,retail_price,retail_total_price,stock_max_number,max_unit,min_unit,batch_number,stock_min_number,supply_warehouse_id,supply_warehouse_detail_info,storehouse_id) VALUES "
537
+			thisSQL := "INSERT INTO xt_drug_warehouse_info (warehousing_id, drug_id, number, product_date,expiry_date,warehousing_count,price,total_price,dealer,manufacturer,remark,ctime,mtime,status,org_id,warehousing_order,type,retail_price,retail_total_price,stock_max_number,max_unit,min_unit,batch_number,stock_min_number,supply_warehouse_id,supply_warehouse_detail_info,storehouse_id,is_check) VALUES "
538 538
 			insertParams := make([]string, 0)
539 539
 			insertData := make([]interface{}, 0)
540 540
 			for _, info := range warehousingInfo {
541
-				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
541
+				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
542 542
 				insertData = append(insertData, info.WarehousingId)
543 543
 				insertData = append(insertData, info.DrugId)
544 544
 				insertData = append(insertData, info.Number)
@@ -566,6 +566,7 @@ func CreateDrugWarehousingInfoSix(warehousingInfo []*models.DrugWarehouseInfo) (
566 566
 				insertData = append(insertData, info.SupplyWarehouseId)
567 567
 				insertData = append(insertData, info.SupplyWarehouseDetailInfo)
568 568
 				insertData = append(insertData, info.StorehouseId)
569
+				insertData = append(insertData, info.IsCheck)
569 570
 			}
570 571
 			thisSQL += strings.Join(insertParams, ", ")
571 572
 			err = utx.Exec(thisSQL, insertData...).Error
@@ -728,15 +729,14 @@ func CreateDrugFlowOne(flow models.DrugFlow) error {
728 729
 	return err
729 730
 }
730 731
 
731
-func UpdateDrugFlowSeven(patientid int64, recorddate int64, drugid int64, advice_id int64) (models.DrugAutomaticReduceDetail, error) {
732
-
732
+func UpdateDrugFlowSeven(patientid int64, recorddate int64, drugid int64, advice_id int64, id int64, warhouse_out_id int64) (models.DrugAutomaticReduceDetail, error) {
733 733
 	detail := models.DrugAutomaticReduceDetail{}
734
-	err := XTWriteDB().Model(&detail).Where("patient_id = ? and record_time = ? and drug_id = ? and status= 1 and advice_id =?", patientid, recorddate, drugid, advice_id).Updates(map[string]interface{}{"status": 0}).Error
735
-	err = XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("patient_id =? and sys_record_time =? and drug_id = ? and status = 1 and advice_id =?", patientid, recorddate, drugid, advice_id).Updates(map[string]interface{}{"status": 0}).Error
734
+	err := XTWriteDB().Model(&detail).Where("patient_id = ? and record_time = ? and drug_id = ? and status= 1 and advice_id =? ", patientid, recorddate, drugid, advice_id).Updates(map[string]interface{}{"status": 0}).Error
735
+	err = XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("patient_id =? and sys_record_time =? and drug_id = ? and status = 1 and advice_id =? and id = ?", patientid, recorddate, drugid, advice_id, id).Updates(map[string]interface{}{"status": 0}).Error
736 736
 	return detail, err
737 737
 }
738 738
 
739
-func UpdateDrugFlowTens(patientid int64, warehouse_out_number string, drug_id int64, advice_id int64) (models.DrugFlow, error) {
739
+func UpdateDrugFlowTens(patientid int64, warehouse_out_number string, drug_id int64, advice_id int64, id int64) (models.DrugFlow, error) {
740 740
 	flow := models.DrugFlow{}
741 741
 	err := XTWriteDB().Model(&flow).Where("patient_id =? and warehouse_out_order_number = ? and drug_id = ? and status = 1 and advice_id =?", patientid, warehouse_out_number, drug_id, advice_id).Updates(map[string]interface{}{"status": 0}).Error
742 742
 	return flow, err
@@ -802,10 +802,10 @@ func FindWarehousingInfoTen(goodId int64, storehouse_id int64) (models.Warehousi
802 802
 	info := models.WarehousingInfo{}
803 803
 	var err error
804 804
 	if storehouse_id == 0 {
805
-		err = XTReadDB().Select(" good_id,sum(stock_count) as stock_count").Where("good_id = ? and status = 1", goodId).Find(&info).Error
805
+		err = XTReadDB().Select(" good_id,sum(stock_count) as stock_count").Where("good_id = ? and status = 1 and is_check = 1", goodId).Find(&info).Error
806 806
 	}
807 807
 	if storehouse_id > 0 {
808
-		err = XTReadDB().Select(" good_id,sum(stock_count) as stock_count").Where("good_id = ? and status = 1 and storehouse_id = ?", goodId, storehouse_id).Find(&info).Error
808
+		err = XTReadDB().Select(" good_id,sum(stock_count) as stock_count").Where("good_id = ? and status = 1 and storehouse_id = ? and is_check = 1", goodId, storehouse_id).Find(&info).Error
809 809
 	}
810 810
 
811 811
 	return info, err
@@ -814,7 +814,7 @@ func FindWarehousingInfoTen(goodId int64, storehouse_id int64) (models.Warehousi
814 814
 //药品先进先出,找出最先入库的批次
815 815
 
816 816
 func FindLastDrugWarehousingInfoByID(drug_id int64, storehouse_id int64) (info models.XtDrugWarehouseInfo, err error) {
817
-	err = readDb.Model(&models.XtDrugWarehouseInfo{}).Where("drug_id = ? AND status = 1 AND (stock_max_number > 0 or stock_min_number > 0) and storehouse_id = ?", drug_id, storehouse_id).Order("ctime").First(&info).Error
817
+	err = readDb.Model(&models.XtDrugWarehouseInfo{}).Where("drug_id = ? AND status = 1 AND (stock_max_number > 0 or stock_min_number > 0) and storehouse_id = ? and is_check = 1", drug_id, storehouse_id).Order("ctime").First(&info).Error
818 818
 	return info, err
819 819
 }
820 820
 
@@ -849,7 +849,7 @@ func FindLastDrugWarehousingInfo(order string) (info models.DrugWarehouseInfo, e
849 849
 
850 850
 }
851 851
 
852
-func FindAllWarehousingList(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, ids []int64, storehouse_id int64) (list []*models.Warehousing, total int64, err error) {
852
+func FindAllWarehousingList(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, ids []int64, storehouse_id int64, check_type int64) (list []*models.Warehousing, total int64, err error) {
853 853
 	db := readDb.Model(&models.Warehousing{})
854 854
 	db = db.Where("xt_warehouse.org_id = ? AND xt_warehouse.status = 1 AND xt_warehouse.type = ?", orgId, types)
855 855
 
@@ -871,6 +871,13 @@ func FindAllWarehousingList(orgId int64, page int64, limit int64, startTime int6
871 871
 		db = db.Where("xt_warehouse.storehouse_id = ?", storehouse_id)
872 872
 	}
873 873
 
874
+	if check_type == 0 {
875
+		db = db.Where("xt_warehouse.is_check = 0 or xt_warehouse.is_check = 1 or xt_warehouse.is_check = 2")
876
+	}
877
+	if check_type > 0 {
878
+		db = db.Where("xt_warehouse.is_check = ?", check_type)
879
+	}
880
+
874 881
 	db = db.Count(&total)
875 882
 	offset := (page - 1) * limit
876 883
 	err = db.Offset(offset).Limit(limit).Order("xt_warehouse.ctime desc").Find(&list).Error
@@ -955,6 +962,7 @@ type VMDrugWarehouse struct {
955 962
 	SupplyWarehouseId int64                `gorm:"column:supply_warehouse_id" json:"supply_warehouse_id" form:"supply_warehouse_id"`
956 963
 	StorehouseId      int64                `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
957 964
 	IsSys             int64                `gorm:"column:is_sys" json:"is_sys" form:"is_sys"`
965
+	IsCheck           int64                `gorm:"column:is_check" json:"is_check" form:"is_check"`
958 966
 }
959 967
 
960 968
 func (VMDrugWarehouse) TableName() string {
@@ -1094,7 +1102,7 @@ func FindAllDrugWarehousingList(orgId int64, page int64, limit int64, startTime
1094 1102
 	return
1095 1103
 }
1096 1104
 
1097
-func FindAllDrugWarehousingListOne(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, ids []int64, storehouse_id int64) (list []*VMDrugWarehouse, total int64, err error) {
1105
+func FindAllDrugWarehousingListOne(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, ids []int64, storehouse_id int64, check_type int64) (list []*VMDrugWarehouse, total int64, err error) {
1098 1106
 	db := readDb.Model(&VMDrugWarehouse{})
1099 1107
 	db = db.Where("xt_drug_warehouse.org_id = ? AND xt_drug_warehouse.status = 1", orgId)
1100 1108
 	db = db.Preload("Manufacturers", "status = 1 AND org_id = ?", orgId)
@@ -1113,6 +1121,9 @@ func FindAllDrugWarehousingListOne(orgId int64, page int64, limit int64, startTi
1113 1121
 	if storehouse_id > 0 {
1114 1122
 		db = db.Where("xt_drug_warehouse.storehouse_id = ?", storehouse_id)
1115 1123
 	}
1124
+	if check_type > 0 {
1125
+		db = db.Where("xt_drug_warehouse.is_check = ?", check_type)
1126
+	}
1116 1127
 	db = db.Count(&total)
1117 1128
 	offset := (page - 1) * limit
1118 1129
 	err = db.Offset(offset).Limit(limit).Order("xt_drug_warehouse.ctime desc").Find(&list).Error
@@ -1352,32 +1363,33 @@ func FindCancelStockInfoById(id int64) (list []*models.CancelStockInfo, err erro
1352 1363
 }
1353 1364
 
1354 1365
 type DrugCancelStockInfo struct {
1355
-	ID               int64   `gorm:"column:id" json:"id" form:"id"`
1356
-	DrugId           int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
1357
-	CancelStockId    int64   `gorm:"column:cancel_stock_id" json:"cancel_stock_id" form:"cancel_stock_id"`
1358
-	Count            int64   `gorm:"column:count" json:"count" form:"count"`
1359
-	Price            float64 `gorm:"column:price" json:"price" form:"price"`
1360
-	Total            float64 `gorm:"column:total" json:"total" form:"total"`
1361
-	ProductDate      int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
1362
-	ExpiryDate       int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
1363
-	Ctime            int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
1364
-	Mtime            int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
1365
-	Status           int64   `gorm:"column:status" json:"status" form:"status"`
1366
-	OrgId            int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
1367
-	OrderNumber      string  `gorm:"column:order_number" json:"order_number" form:"order_number"`
1368
-	Type             int64   `gorm:"column:type" json:"type" form:"type"`
1369
-	Dealer           string  `gorm:"column:dealer" json:"dealer" form:"dealer"`
1370
-	Manufacturer     string  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
1371
-	RetailPrice      float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
1372
-	RetailTotalPrice float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
1373
-	Number           string  `gorm:"column:number" json:"number" form:"number"`
1374
-	RegisterAccount  string  `gorm:"column:register_account" json:"register_account" form:"register_account"`
1375
-	Remark           string  `gorm:"column:remark" json:"remark" form:"remark"`
1376
-	BatchNumber      string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
1377
-	MaxUnit          string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
1378
-	Drug             *Drug   `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug"`
1379
-	BatchNumberId    int64   `gorm:"column:batch_number_id" json:"batch_number_id" form:"batch_number_id"`
1380
-	StorehouseId     int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
1366
+	ID                int64                         `gorm:"column:id" json:"id" form:"id"`
1367
+	DrugId            int64                         `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
1368
+	CancelStockId     int64                         `gorm:"column:cancel_stock_id" json:"cancel_stock_id" form:"cancel_stock_id"`
1369
+	Count             int64                         `gorm:"column:count" json:"count" form:"count"`
1370
+	Price             float64                       `gorm:"column:price" json:"price" form:"price"`
1371
+	Total             float64                       `gorm:"column:total" json:"total" form:"total"`
1372
+	ProductDate       int64                         `gorm:"column:product_date" json:"product_date" form:"product_date"`
1373
+	ExpiryDate        int64                         `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
1374
+	Ctime             int64                         `gorm:"column:ctime" json:"ctime" form:"ctime"`
1375
+	Mtime             int64                         `gorm:"column:mtime" json:"mtime" form:"mtime"`
1376
+	Status            int64                         `gorm:"column:status" json:"status" form:"status"`
1377
+	OrgId             int64                         `gorm:"column:org_id" json:"org_id" form:"org_id"`
1378
+	OrderNumber       string                        `gorm:"column:order_number" json:"order_number" form:"order_number"`
1379
+	Type              int64                         `gorm:"column:type" json:"type" form:"type"`
1380
+	Dealer            string                        `gorm:"column:dealer" json:"dealer" form:"dealer"`
1381
+	Manufacturer      string                        `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
1382
+	RetailPrice       float64                       `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
1383
+	RetailTotalPrice  float64                       `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
1384
+	Number            string                        `gorm:"column:number" json:"number" form:"number"`
1385
+	RegisterAccount   string                        `gorm:"column:register_account" json:"register_account" form:"register_account"`
1386
+	Remark            string                        `gorm:"column:remark" json:"remark" form:"remark"`
1387
+	BatchNumber       string                        `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
1388
+	MaxUnit           string                        `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
1389
+	Drug              *Drug                         `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug"`
1390
+	BatchNumberId     int64                         `gorm:"column:batch_number_id" json:"batch_number_id" form:"batch_number_id"`
1391
+	StorehouseId      int64                         `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
1392
+	DrugWarehouseInfo []*models.XtDrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:DrugId" json:"drug_warehouse_info"`
1381 1393
 }
1382 1394
 
1383 1395
 func (DrugCancelStockInfo) TableName() string {
@@ -1385,7 +1397,7 @@ func (DrugCancelStockInfo) TableName() string {
1385 1397
 }
1386 1398
 
1387 1399
 func FindDrugCancelStockInfoById(id int64, org_id int64) (list []*DrugCancelStockInfo, err error) {
1388
-	err = readDb.Model(&DrugCancelStockInfo{}).Preload("Drug", "status = 1 AND org_id = ? ", org_id).Where("cancel_stock_id = ? AND status = 1", id).Find(&list).Error
1400
+	err = readDb.Model(&DrugCancelStockInfo{}).Preload("Drug", "status = 1 AND org_id = ? ", org_id).Preload("DrugWarehouseInfo", "status = 1 AND org_id = ? ", org_id).Where("cancel_stock_id = ? AND status = 1", id).Find(&list).Error
1389 1401
 	return list, err
1390 1402
 }
1391 1403
 
@@ -1552,7 +1564,7 @@ func FindAllWarehouseOutList(orgId int64, page int64, limit int64, startTime int
1552 1564
 
1553 1565
 }
1554 1566
 
1555
-func FindAllWarehouseOutListOne(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, ids []int64, storehouse_id int64, way_type int64) (list []*models.WarehouseOut, total int64, err error) {
1567
+func FindAllWarehouseOutListOne(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, ids []int64, storehouse_id int64, way_type int64, check_type int64) (list []*models.WarehouseOut, total int64, err error) {
1556 1568
 	db := readDb.Model(&models.WarehouseOut{})
1557 1569
 	db = db.Where("xt_warehouse_out.org_id = ? AND xt_warehouse_out.status = 1 AND xt_warehouse_out.type = ?", orgId, types)
1558 1570
 
@@ -1572,7 +1584,7 @@ func FindAllWarehouseOutListOne(orgId int64, page int64, limit int64, startTime
1572 1584
 		db = db.Where("xt_warehouse_out.storehouse_id = ?", storehouse_id)
1573 1585
 	}
1574 1586
 	if way_type == 0 {
1575
-		db = db.Where("xt_warehouse_out.is_sys = 0 || xt_warehouse_out.is_sys = 1 || xt_warehouse_out.is_sys = 12")
1587
+		db = db.Where("xt_warehouse_out.is_sys = 0 or xt_warehouse_out.is_sys = 1 or xt_warehouse_out.is_sys = 12")
1576 1588
 	}
1577 1589
 	if way_type == 1 {
1578 1590
 		db = db.Where("xt_warehouse_out.is_sys = 0")
@@ -1583,6 +1595,12 @@ func FindAllWarehouseOutListOne(orgId int64, page int64, limit int64, startTime
1583 1595
 	if way_type == 3 {
1584 1596
 		db = db.Where("xt_warehouse_out.is_sys = 12")
1585 1597
 	}
1598
+	if check_type > 0 {
1599
+		db = db.Where("xt_warehouse_out.is_check = ?", check_type)
1600
+	}
1601
+	if check_type == 0 {
1602
+		db = db.Where("xt_warehouse_out.is_check = 1 or xt_warehouse_out.is_check = 2")
1603
+	}
1586 1604
 	db = db.Count(&total)
1587 1605
 	offset := (page - 1) * limit
1588 1606
 	if orgId == 10191 {
@@ -1620,7 +1638,7 @@ func FindAllDrugWarehouseOutList(orgId int64, page int64, limit int64, startTime
1620 1638
 
1621 1639
 }
1622 1640
 
1623
-func FindAllDrugWarehouseOutListOne(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, ids []int64, storehouse_id int64, way_type int64) (list []*models.DrugWarehouseOut, total int64, err error) {
1641
+func FindAllDrugWarehouseOutListOne(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, ids []int64, storehouse_id int64, way_type int64, check_type int64) (list []*models.DrugWarehouseOut, total int64, err error) {
1624 1642
 	db := readDb.Model(&models.DrugWarehouseOut{})
1625 1643
 	db = db.Where("xt_drug_warehouse_out.org_id = ? AND xt_drug_warehouse_out.status = 1 ", orgId)
1626 1644
 
@@ -1640,6 +1658,9 @@ func FindAllDrugWarehouseOutListOne(orgId int64, page int64, limit int64, startT
1640 1658
 	if storehouse_id > 0 {
1641 1659
 		db = db.Where("xt_drug_warehouse_out.storehouse_id = ?", storehouse_id)
1642 1660
 	}
1661
+	if check_type > 0 {
1662
+		db = db.Where("xt_drug_warehouse_out.is_check = ?", check_type)
1663
+	}
1643 1664
 
1644 1665
 	if way_type == 0 {
1645 1666
 		db = db.Where("xt_drug_warehouse_out.is_sys = 0 || xt_drug_warehouse_out.is_sys = 1 || xt_drug_warehouse_out.is_sys = 12")
@@ -2535,7 +2556,7 @@ func UpdateDrugFlowSix(warehousoutid int64, drugid int64, warehouse_out_order_nu
2535 2556
 	return err
2536 2557
 }
2537 2558
 
2538
-func FindAllCancelList(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, storehouse_id int64) (list []*models.CancelStock, total int64, err error) {
2559
+func FindAllCancelList(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, storehouse_id int64, check_type int64) (list []*models.CancelStock, total int64, err error) {
2539 2560
 	db := readDb.Model(&models.CancelStock{})
2540 2561
 	db = db.Where("xt_cancel_stock.org_id = ? AND xt_cancel_stock.status = 1 AND xt_cancel_stock.type = ?", orgId, types)
2541 2562
 	if len(keywords) > 0 {
@@ -2554,13 +2575,16 @@ func FindAllCancelList(orgId int64, page int64, limit int64, startTime int64, en
2554 2575
 	if storehouse_id > 0 {
2555 2576
 		db = db.Where("xt_cancel_stock.storehouse_id = ?", storehouse_id)
2556 2577
 	}
2578
+	if check_type > 0 {
2579
+		db = db.Where("xt_cancel_stock.is_check = ?", check_type)
2580
+	}
2557 2581
 	db = db.Count(&total)
2558 2582
 	offset := (page - 1) * limit
2559 2583
 	err = db.Offset(offset).Limit(limit).Order("xt_cancel_stock.ctime desc").Find(&list).Error
2560 2584
 	return
2561 2585
 }
2562 2586
 
2563
-func FindAllDrugCancelList(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, storehoue_id int64) (list []*models.DrugCancelStock, total int64, err error) {
2587
+func FindAllDrugCancelList(orgId int64, page int64, limit int64, startTime int64, endTime int64, types int64, keywords string, storehoue_id int64, check_type int64) (list []*models.DrugCancelStock, total int64, err error) {
2564 2588
 	db := readDb.Model(&models.DrugCancelStock{})
2565 2589
 	db = db.Where("xt_drug_cancel_stock.org_id = ? AND xt_drug_cancel_stock.status = 1", orgId)
2566 2590
 	if len(keywords) > 0 {
@@ -2579,6 +2603,9 @@ func FindAllDrugCancelList(orgId int64, page int64, limit int64, startTime int64
2579 2603
 	if storehoue_id > 0 {
2580 2604
 		db = db.Where("xt_drug_cancel_stock.storehouse_id = ?", storehoue_id)
2581 2605
 	}
2606
+	if check_type > 0 {
2607
+		db = db.Where("xt_drug_cancel_stock.is_check = ?", check_type)
2608
+	}
2582 2609
 	db = db.Count(&total)
2583 2610
 	offset := (page - 1) * limit
2584 2611
 	err = db.Offset(offset).Limit(limit).Order("xt_drug_cancel_stock.ctime desc").Find(&list).Error
@@ -2738,7 +2765,7 @@ type StockDetailModel struct {
2738 2765
 func FindStockInDetailList(orgId int64, page int64, limit int64, startTime int64, endTime int64, keywords string, manufacturer int64, order_type int64, dealer int64, storehouse_id int64) (list []*models.WarehousingInfo, total int64, err error) {
2739 2766
 
2740 2767
 	db := readDb.Model(&models.WarehousingInfo{})
2741
-	db = db.Where("xt_warehouse_info.org_id = ? AND xt_warehouse_info.status = 1", orgId)
2768
+	db = db.Where("xt_warehouse_info.org_id = ? AND xt_warehouse_info.status = 1 AND xt_warehouse_info.is_check = 1", orgId)
2742 2769
 	if len(keywords) > 0 {
2743 2770
 		likeKey := "%" + keywords + "%"
2744 2771
 		//db = db.Joins("join xt_warehouse on xt_warehouse.id = xt_warehouse_info.warehousing_id AND ")
@@ -2814,7 +2841,7 @@ func FloatRound(f float64, n int) float64 {
2814 2841
 
2815 2842
 func FindStockOutDetailList(orgId int64, page int64, limit int64, startTime int64, endTime int64, keywords string, manufacturer int64, order_type int64, dealer int64, storehouse_id int64) (list []*models.WarehouseOutInfo, total int64, err error) {
2816 2843
 	db := readDb.Model(&models.WarehouseOutInfo{})
2817
-	db = db.Where("xt_warehouse_out_info.org_id = ? AND xt_warehouse_out_info.status = 1 AND xt_warehouse_out_info.good_id <> 0 AND xt_warehouse_out_info.count <> 0 ", orgId)
2844
+	db = db.Where("xt_warehouse_out_info.org_id = ? AND xt_warehouse_out_info.status = 1 AND xt_warehouse_out_info.is_check = 1 AND xt_warehouse_out_info.good_id <> 0 AND xt_warehouse_out_info.count <> 0 ", orgId)
2818 2845
 
2819 2846
 	if len(keywords) > 0 {
2820 2847
 		likeKey := "%" + keywords + "%"
@@ -3943,7 +3970,7 @@ func GetAllGoodInfoStockList(page int64, limit int64, startime int64, endtime in
3943 3970
 		if storehouse_id > 0 {
3944 3971
 			db = db.Where("storehouse_id = ?", storehouse_id)
3945 3972
 		}
3946
-		return db.Where("status = 1")
3973
+		return db.Where("status = 1 and is_check = 1")
3947 3974
 	}).Preload("WarehousingInfo", func(db *gorm.DB) *gorm.DB {
3948 3975
 		if startime > 0 {
3949 3976
 			db = db.Where("ctime>=?", startime)
@@ -3973,7 +4000,7 @@ func GetAllGoodInfoStockList(page int64, limit int64, startime int64, endtime in
3973 4000
 func GetStockListById(good_id int64, orgid int64, limit int64, page int64, startime int64, endtime int64) (info []*models.VmWarehousingInfo, total int64, err error) {
3974 4001
 
3975 4002
 	offset := (page - 1) * limit
3976
-	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status= 1")
4003
+	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status= 1 and x.is_check = 1")
3977 4004
 	table := XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
3978 4005
 	fmt.Println(table)
3979 4006
 	if startime > 0 {
@@ -4099,7 +4126,9 @@ func GetWarehouseOutOrder(id []string, orgid int64) (out []*models.WarehouseOut,
4099 4126
 	if orgid > 0 {
4100 4127
 		db = db.Where("x.org_id= ?", orgid)
4101 4128
 	}
4102
-	err = db.Select("x.id,x.warehouse_out_order_number,x.operation_time,x.creater,x.org_id,x.modifier,x.remark,x.warehouse_out_time,x.dealer,x.manufacturer,x.type").Find(&out).Error
4129
+	err = db.Select("x.id,x.warehouse_out_order_number,x.operation_time,x.creater,x.org_id,x.modifier,x.remark,x.warehouse_out_time,x.dealer,x.manufacturer,x.type").Preload("WarehouseOutInfo", func(db *gorm.DB) *gorm.DB {
4130
+		return XTReadDB().Where("org_id=? and status = 1", orgid).Preload("WarehousingInfo", "status = 1 and org_id = ?", orgid)
4131
+	}).Find(&out).Error
4103 4132
 	return out, err
4104 4133
 }
4105 4134
 
@@ -4107,7 +4136,8 @@ func GetOrderDetialByOrderIdOne(id []string, orgid int64) (out []*models.Warehou
4107 4136
 
4108 4137
 	db := XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status = 1")
4109 4138
 	table := XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
4110
-	fmt.Println(table)
4139
+	tableOne := XTReadDB().Table("xt_warehouse_info as n").Where("n.status = 1")
4140
+	fmt.Println(table, tableOne)
4111 4141
 	if len(id) > 0 {
4112 4142
 		db = db.Where("x.warehouse_out_id in (?)", id)
4113 4143
 	}
@@ -4115,7 +4145,7 @@ func GetOrderDetialByOrderIdOne(id []string, orgid int64) (out []*models.Warehou
4115 4145
 		db = db.Where("x.org_id = ?", orgid)
4116 4146
 	}
4117 4147
 
4118
-	err = db.Select("x.id,x.warehouse_out_id,x.good_id,sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,t.social_security_directory_code,x.is_sys,x.sys_record_time,x.number,x.remark,x.license_number,x.storehouse_id,x.admin_user_id,x.buy_price,x.stock_count,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.packing_unit,t.min_unit,t.packing_price").Joins("left join xt_good_information as t on t.id=x.good_id").Group("x.warehouse_out_id,x.good_id").Order("x.ctime desc").Scan(&out).Error
4148
+	err = db.Select("x.id,x.warehouse_out_id,x.good_id,sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,t.social_security_directory_code,x.is_sys,x.sys_record_time,n.number,x.remark,x.license_number,x.storehouse_id,x.admin_user_id,x.buy_price,x.stock_count,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.packing_unit,t.min_unit,t.packing_price").Joins("left join xt_warehouse_info as n on n.id=x.warehouse_info_id").Joins("left join xt_good_information as t on t.id=x.good_id").Group("x.warehouse_out_id,x.good_id").Order("x.ctime desc").Scan(&out).Error
4119 4149
 	return out, err
4120 4150
 }
4121 4151
 
@@ -4690,10 +4720,9 @@ func GetDrugWarehouseOut(warehouse_out_id []string) (out []*models.StDrugWarehou
4690 4720
 
4691 4721
 func GetDrugWarehouseOutTenty(warehouse_out_id []string, orgid int64) (out []*models.DrugWarehouseOutTwenty, err error) {
4692 4722
 
4693
-	err = XTReadDB().Where("id in(?)", warehouse_out_id).
4694
-		Preload("DrugWarehouseOutInfoTenty", func(db *gorm.DB) *gorm.DB {
4695
-			return XTReadDB().Where("org_id=? and status = 1", orgid).Preload("BaseDrugLib", "status = 1 and org_id = ?", orgid)
4696
-		}).Find(&out).Error
4723
+	err = XTReadDB().Where("id in(?)", warehouse_out_id).Preload("DrugWarehouseOutInfoTenty", func(db *gorm.DB) *gorm.DB {
4724
+		return XTReadDB().Where("org_id=? and status = 1", orgid).Preload("BaseDrugLib", "status = 1 and org_id = ?", orgid).Preload("DrugWarehouseInfo", "status = 1 and org_id = ?", orgid)
4725
+	}).Find(&out).Error
4697 4726
 
4698 4727
 	return out, err
4699 4728
 }
@@ -5107,9 +5136,9 @@ func GetDrugWarehouseInfoPrescription(drugid int64, orgid int64) (info []*models
5107 5136
 	return info, err
5108 5137
 }
5109 5138
 
5110
-func GetDrugWarehouseInfoPrescriptionSeven(drugid int64, orgid int64) (info []*models.DrugWarehouseInfoSeven, err error) {
5139
+func GetDrugWarehouseInfoPrescriptionSeven(drugid int64, orgid int64, storehouse_id int64) (info []*models.DrugWarehouseInfoSeven, err error) {
5111 5140
 
5112
-	err = XTReadDB().Select("id,stock_max_number,stock_min_number").Where("drug_id = ? and org_id =? and status = 1", drugid, orgid).Find(&info).Error
5141
+	err = XTReadDB().Select("id,stock_max_number,stock_min_number").Where("drug_id = ? and org_id =? and status = 1 and storehouse_id = ? and is_check = 1", drugid, orgid, storehouse_id).Find(&info).Error
5113 5142
 	return info, err
5114 5143
 }
5115 5144
 
@@ -5120,6 +5149,12 @@ func GetHisAdviceListByDrugId(drugid int64, patient_id int64, advice_date int64)
5120 5149
 	return info, err
5121 5150
 }
5122 5151
 
5152
+func GetHisAdviceListByDrugIdTwo(patient_id int64, advice_date int64, orgid int64) (info []*models.HisDoctorAdviceInfo, err error) {
5153
+
5154
+	err = XTReadDB().Where("patient_id = ? and advice_date = ? and status = 1 and user_org_id = ?", patient_id, advice_date, orgid).Find(&info).Error
5155
+	return info, err
5156
+}
5157
+
5123 5158
 func GetHisAdviceListByDrugIdEight(drugid int64, patient_id int64, advice_date int64, advice_id int64) (models.HisDoctorAdviceInfo, error) {
5124 5159
 
5125 5160
 	info := models.HisDoctorAdviceInfo{}
@@ -5133,6 +5168,12 @@ func GetLastDrugWarehouseOutByDrugId(drugid int64, patient_id int64, advice_date
5133 5168
 	return detail, err
5134 5169
 }
5135 5170
 
5171
+func GetLastDrugWarehouseOutByDrugIdTwenty(drugid int64, patient_id int64, advice_date int64, advice_id int64) (out []*models.DrugWarehouseOutInfo, err error) {
5172
+
5173
+	err = XTReadDB().Where("advice_id = ?  and drug_id = ? and patient_id = ? and sys_record_time = ? and status = 1 and is_check = 1", advice_id, drugid, patient_id, advice_date).Find(&out).Error
5174
+	return out, err
5175
+}
5176
+
5136 5177
 func ModefyDrugByWarehouseInfo(id int64, stock_max_number int64) error {
5137 5178
 
5138 5179
 	err := XTWriteDB().Model(models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", stock_max_number)).Error
@@ -5393,7 +5434,7 @@ func GetTemplatePlan(orgid int64) (config []*models.Dataconfig, err error) {
5393 5434
 
5394 5435
 func GetSearchGoodWarehouseList(keyword string, orgid int64, storehouse_id int64) (info []*models.BloodWarehouseInfo, err error) {
5395 5436
 
5396
-	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
5437
+	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1 and x.is_check = 1")
5397 5438
 	table := XTReadDB().Table("xt_goood_information as t").Where("t.status")
5398 5439
 	fmt.Println(table)
5399 5440
 	likeKey := "%" + keyword + "%"
@@ -5911,7 +5952,7 @@ func UpdateWarehouseInfoByGoodId(info models.WarehousingInfo, id int64) error {
5911 5952
 	return err
5912 5953
 }
5913 5954
 
5914
-func UpdateWarehouseInfoByGoodIdOne(info models.WarehousingInfo, id int64) error {
5955
+func UpdateWarehouseInfoByGoodIdOne(info *models.WarehousingInfo, id int64) error {
5915 5956
 
5916 5957
 	err := XTWriteDB().Model(&info).Where("id =? and status = 1", id).Updates(map[string]interface{}{"warehousing_count": info.WarehousingCount, "stock_count": info.StockCount, "price": info.Price, "number": info.Number, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "license_number": info.LicenseNumber, "manufacturer": info.Manufacturer, "dealer": info.Dealer, "remark": info.Remark, "packing_price": info.PackingPrice, "storehouse_id": info.StorehouseId}).Error
5917 5958
 	return err
@@ -6178,8 +6219,6 @@ func ModifyGoodReduceInformationTwo(good_id int64, sum_count int64, orgid int64)
6178 6219
 func ModifyGoodReduceInformationSix(good_id int64, sum_count int64, orgid int64, retail_price float64) (models.GoodInfo, error) {
6179 6220
 
6180 6221
 	info := models.GoodInfo{}
6181
-
6182
-	err = XTWriteDB().Model(&info).Where("id = ? and org_id = ? and status = 1", good_id, orgid).UpdateColumn("sum_count", gorm.Expr("sum_count - ?", sum_count)).Error
6183 6222
 	err = XTWriteDB().Model(&info).Where("id = ? and org_id = ? and status = 1", good_id, orgid).Update(map[string]interface{}{"batch_retai_price": retail_price}).Error
6184 6223
 	return info, err
6185 6224
 }
@@ -6812,6 +6851,14 @@ func GetDrugOpenConfig(orgid int64) (*models.DrugOutConfig, error) {
6812 6851
 	return &config, nil
6813 6852
 }
6814 6853
 
6854
+func GetDrugOpenConfigOne(orgid int64) (models.DrugOutConfig, error) {
6855
+
6856
+	config := models.DrugOutConfig{}
6857
+	err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&config).Error
6858
+
6859
+	return config, err
6860
+}
6861
+
6815 6862
 func CreateDrugOutConfig(config models.DrugOutConfig) error {
6816 6863
 
6817 6864
 	err := XTWriteDB().Create(&config).Error
@@ -6830,3 +6877,536 @@ func FindDrugOutConfigById(orgid int64) (models.DrugOutConfig, error) {
6830 6877
 	err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&config).Error
6831 6878
 	return config, err
6832 6879
 }
6880
+
6881
+func UpdatedWarehouseOut(id int64) error {
6882
+
6883
+	err := XTWriteDB().Model(&models.WarehouseOut{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
6884
+	err = XTWriteDB().Model(&models.WarehouseOutInfo{}).Where("warehouse_out_id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
6885
+	return err
6886
+}
6887
+
6888
+func UpdatedSigleWarehouseOutInfo(id int64, info *models.WarehouseOutInfo) error {
6889
+
6890
+	err := XTWriteDB().Model(&models.WarehouseOutInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"warehouse_info_id": info.WarehouseInfotId}).Error
6891
+
6892
+	return err
6893
+
6894
+}
6895
+
6896
+func GetLastGoodWarehouseOutInfo(orgid int64, id int64) (info []*models.WarehouseOutInfo, err error) {
6897
+
6898
+	err = XTReadDB().Where("org_id = ? and status = 1 and warehouse_out_id = ?", orgid, id).Preload("GoodInfo", func(db *gorm.DB) *gorm.DB {
6899
+		return XTReadDB().Where("org_id=? and status = 1", orgid).Preload("GoodsType", "status = 1")
6900
+	}).Find(&info).Error
6901
+	return info, err
6902
+}
6903
+
6904
+func GetLastGoodWarehouseOutInfoById(orgid int64) (models.WarehouseOutInfo, error) {
6905
+	info := models.WarehouseOutInfo{}
6906
+	err := XTReadDB().Where("org_id = ? and status = 1", orgid).Last(&info).Error
6907
+	return info, err
6908
+}
6909
+
6910
+func ModifyWarehouseOutInfo(id int64, info *models.WarehouseOutInfo) error {
6911
+
6912
+	err := XTWriteDB().Model(&models.WarehouseOutInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"good_id": info.GoodId, "good_type_id": info.GoodTypeId, "count": info.Count, "price": info.Price, "total_price": info.TotalPrice, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "remark": info.Remark, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "number": info.Number, "license_number": info.LicenseNumber, "storehouse_id": info.StorehouseId, "admin_user_id": info.AdminUserId, "buy_price": info.BuyPrice, "stock_count": info.StockCount}).Error
6913
+	return err
6914
+}
6915
+
6916
+func UpdateWarehouseOutFlow(info models.VmStockFlow, id int64) error {
6917
+
6918
+	err := XTWriteDB().Model(&models.VmStockFlow{}).Where("warehouse_out_detail_id = ? and status = 1", id).Update(map[string]interface{}{"good_id": info.GoodId, "number": info.Number, "license_number": info.LicenseNumber, "count": info.Count, "manufacturer": info.Manufacturer, "dealer": info.Dealer, "price": info.Price, "expire_date": info.ExpireDate, "product_date": info.ProductDate, "storehouse_id": info.StorehouseId, "admin_user_id": info.AdminUserId, "buy_price": info.BuyPrice, "stock_count": info.StockCount}).Error
6919
+	return err
6920
+}
6921
+
6922
+func GetLastGoodWarehouseOutTwenty(orgid int64) (models.WarehouseOut, error) {
6923
+	out := models.WarehouseOut{}
6924
+	err := XTReadDB().Where("org_id = ? and status = 1", orgid).Last(&out).Error
6925
+	return out, err
6926
+}
6927
+
6928
+func UpdateaGoodWarehouseInfo(count int64, good_id int64, orgid int64, warehouse_info_id int64) error {
6929
+
6930
+	err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("good_id = ?  and org_id = ? and status = 1 and id = ?", good_id, orgid, warehouse_info_id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
6931
+
6932
+	return err
6933
+}
6934
+
6935
+func ModifyGoodWarehouseOut(id int64) error {
6936
+
6937
+	err := XTWriteDB().Model(&models.WarehouseOut{}).Where("id = ? and status =1", id).Update(map[string]interface{}{"is_check": 2}).Error
6938
+	err = XTWriteDB().Model(&models.WarehouseOutInfo{}).Where("warehouse_out_id in(?) and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
6939
+	err = XTWriteDB().Model(&models.VmStockFlow{}).Where("warehouse_out_id in(?) and status = 1", id).Update(map[string]interface{}{"status": 0}).Error
6940
+
6941
+	return err
6942
+}
6943
+
6944
+func GetGoodWarehouseInfoById(waresing_id int64, orgid int64) (info []*models.VmWarehousingInfoSix, err error) {
6945
+
6946
+	err = XTReadDB().Where("org_id = ? and status = 1 and warehousing_id = ?", orgid, waresing_id).Preload("GoodInfo", func(db *gorm.DB) *gorm.DB {
6947
+		return XTReadDB().Where("org_id=? and status = 1", orgid).Preload("GoodsType", "status = 1")
6948
+	}).Find(&info).Error
6949
+	return info, err
6950
+}
6951
+
6952
+func FindLastWarehousing(order string) (info models.Warehousing, err error) {
6953
+	err = readDb.Model(&models.Warehousing{}).Where("warehousing_order = ? AND status = 1", order).Last(&info).Error
6954
+
6955
+	return info, err
6956
+
6957
+}
6958
+
6959
+func UpdateWarehouseDetail(info *models.WarehousingInfo, id int64) error {
6960
+
6961
+	err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"good_id": info.GoodId, "good_type_id": info.GoodTypeId, "number": info.Number, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "warehousing_count": info.WarehousingCount, "warehousing_unit": info.WarehousingUnit, "price": info.Price, "total_price": info.TotalPrice, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "remark": info.Remark, "license_number": info.LicenseNumber, "packing_price": info.PackingPrice}).Error
6962
+	return err
6963
+}
6964
+
6965
+func UpdateCheckWarehouseInfo(id int64) error {
6966
+
6967
+	err := XTWriteDB().Model(&models.Warehousing{}).Where("id =? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
6968
+	return err
6969
+}
6970
+
6971
+func GetWarehouseInfoList(id int64, orgid int64) (info []*models.WarehousingInfo, err error) {
6972
+
6973
+	err = XTReadDB().Where("warehousing_id = ? and org_id = ? and status = 1", id, orgid).Find(&info).Error
6974
+	return info, err
6975
+}
6976
+
6977
+func UpdateWarehouseInfoByIdList(count int64, id int64) error {
6978
+
6979
+	err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
6980
+	err = XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
6981
+	return err
6982
+}
6983
+
6984
+func ReturnCheckWarehouseInfo(id int64) error {
6985
+
6986
+	err := XTWriteDB().Model(&models.Warehousing{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
6987
+	err = XTWriteDB().Model(&models.WarehousingInfo{}).Where("warehousing_id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
6988
+	return err
6989
+}
6990
+
6991
+func UpdateWarehouseInfoByIdListTwo(count int64, id int64) error {
6992
+
6993
+	err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_count", gorm.Expr("stock_count - ?", count)).Error
6994
+	err = XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
6995
+	return err
6996
+}
6997
+
6998
+func UpdateWarehouseInfoFlow(id int64) error {
6999
+
7000
+	err := XTWriteDB().Model(models.VmStockFlow{}).Where("warehousing_detail_id =  ?", id).Update(map[string]interface{}{"status": 0}).Error
7001
+	return err
7002
+}
7003
+
7004
+func FindLastWarehousingSix(org_id int64) (info models.Warehousing, err error) {
7005
+	err = readDb.Model(&models.Warehousing{}).Where("org_id = ? AND status = 1", org_id).Last(&info).Error
7006
+
7007
+	return info, err
7008
+
7009
+}
7010
+
7011
+func FindLastWarehousingSeven(org_id int64) (info models.DrugWarehouse, err error) {
7012
+	err = readDb.Model(&models.DrugWarehouse{}).Where("org_id = ? AND status = 1", org_id).Last(&info).Error
7013
+
7014
+	return info, err
7015
+
7016
+}
7017
+
7018
+func FindLastDrugWarehousingInfoTwenty(org_id int64) (info models.DrugWarehouseInfo, err error) {
7019
+	err = readDb.Model(&models.DrugWarehouseInfo{}).Where("org_id = ? AND status = 1", org_id).Last(&info).Error
7020
+
7021
+	return info, err
7022
+
7023
+}
7024
+
7025
+func FindDrugWarehouseInfoListById(id int64, orgid int64) (info []*models.DrugWarehouseInfoTwenty, err error) {
7026
+
7027
+	err = XTReadDB().Where("warehousing_id = ? and org_id = ? and status = 1", id, orgid).Preload("BaseDrugLib", "status = 1 and org_id =?", orgid).Find(&info).Error
7028
+	return info, err
7029
+}
7030
+
7031
+func CreatedWarehouseing(info *models.DrugWarehouseInfo) error {
7032
+
7033
+	err := XTWriteDB().Create(&info).Error
7034
+	return err
7035
+}
7036
+
7037
+func UpdateWarehouseing(info *models.DrugWarehouseInfo) error {
7038
+
7039
+	err := XTWriteDB().Save(&info).Error
7040
+	return err
7041
+}
7042
+
7043
+func CheckWarehousingInfo(id int64, orgid int64) error {
7044
+
7045
+	err := XTWriteDB().Model(&models.DrugWarehouse{}).Where("id = ? and org_id = ? and status = 1", id, orgid).Update(map[string]interface{}{"is_check": 1}).Error
7046
+	return err
7047
+}
7048
+
7049
+func GetWarehousingInfoByList(id int64, orgid int64) (info []*models.DrugWarehouseInfo, err error) {
7050
+
7051
+	err = XTReadDB().Where("warehousing_id = ? and org_id = ? and status = 1", id, orgid).Find(&info).Error
7052
+	return info, err
7053
+}
7054
+
7055
+func AddDrugWarehouseStockMaxNumber(count int64, id int64) error {
7056
+
7057
+	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", count)).Error
7058
+	err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
7059
+	return err
7060
+}
7061
+
7062
+func UpdateWarehousingInfoFlow(id int64, orgid int64) error {
7063
+
7064
+	err := XTWriteDB().Model(&models.DrugFlow{}).Where("warehousing_detail_id = ? and user_org_id = ? and status = 1", id, orgid).Update(map[string]interface{}{"status": 0}).Error
7065
+	return err
7066
+}
7067
+
7068
+func AddDrugWarehouseStockMinNumber(count int64, id int64) error {
7069
+
7070
+	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number + ?", count)).Error
7071
+	err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
7072
+	return err
7073
+}
7074
+
7075
+func ReturnCheckWarehouseingInfo(id int64, orgid int64) error {
7076
+
7077
+	err := XTWriteDB().Model(&models.DrugWarehouse{}).Where("id = ? and status = 1 and org_id = ?", id, orgid).Update(map[string]interface{}{"is_check": 2}).Error
7078
+	err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("warehousing_id = ? and status = 1 and org_id = ?", id, orgid).Update(map[string]interface{}{"is_check": 2}).Error
7079
+	return err
7080
+}
7081
+
7082
+func AddDrugReturnWarehouseStockMaxNumber(count int64, id int64) error {
7083
+	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number - ?", count)).Error
7084
+	err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7085
+	return err
7086
+}
7087
+
7088
+func AddDrugReturnWarehouseStockMinNumber(count int64, id int64) error {
7089
+	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number - ?", count)).Error
7090
+	err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 2}).Error
7091
+	return err
7092
+}
7093
+
7094
+func UpdateDrugWarehouseInfoTwenty(id int64, info *models.DrugWarehouseInfo) error {
7095
+
7096
+	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"drug_id": info.DrugId, "number": info.Number, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "warehousing_count": info.WarehousingCount, "price": info.Price, "total_price": info.TotalPrice, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "remark": info.Remark, "retail_price": info.RetailPrice, "max_unit": info.MaxUnit, "min_unit": info.MinUnit}).Error
7097
+	return err
7098
+}
7099
+
7100
+func UpdatedDrugWarehouseInfo(info *models.DrugWarehouseOutInfo, id int64) error {
7101
+
7102
+	err := XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"drug_id": info.DrugId, "count": info.Count, "count_unit": info.CountUnit, "price": info.Price, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "remark": info.Remark, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "retail_price": info.RetailPrice, "retail_total_price": info.RetailTotalPrice, "number": info.Number, "batch_number": info.BatchNumber, "admin_user_id": info.AdminUserId, "last_price": info.LastPrice, "stock_count": info.StockCount}).Error
7103
+	return err
7104
+}
7105
+
7106
+func GetDrugLastWarehouseOut(orgid int64) (models.DrugWarehouseOut, error) {
7107
+	out := models.DrugWarehouseOut{}
7108
+	err := XTReadDB().Where("org_id = ? and status = 1", orgid).Find(&out).Error
7109
+	return out, err
7110
+}
7111
+
7112
+func GetDrugWarehouseOutListById(warehouse_out_id int64, orgId int64) (info []*models.DrugWarehouseOutInfo, err error) {
7113
+
7114
+	err = XTReadDB().Where("warehouse_out_id = ? and org_id  =? and status = 1", warehouse_out_id, orgId).Preload("BaseDrugLib", "status=1").Find(&info).Error
7115
+	return info, err
7116
+}
7117
+
7118
+func UpdateCheckDrugOut(out models.DrugWarehouseOut, id int64) error {
7119
+
7120
+	err := XTWriteDB().Model(&models.DrugWarehouseOut{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": out.IsCheck}).Error
7121
+	err = XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("warehouse_out_id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
7122
+	return err
7123
+}
7124
+
7125
+func UpdateCheckDrugOutInfoList(info models.DrugWarehouseOutInfo, warehouse_out_id int64) error {
7126
+
7127
+	err := XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("warehouse_out_id = ?  and status = 1", warehouse_out_id).Update(map[string]interface{}{"is_check": info.IsCheck}).Error
7128
+	return err
7129
+}
7130
+
7131
+func UpdateCheckDrugOutInfo(info models.DrugWarehouseOutInfo, warehouse_out_id int64) error {
7132
+
7133
+	err := XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("warehouse_out_id = ?", warehouse_out_id).Update(map[string]interface{}{"is_check": info.IsCheck}).Error
7134
+	return err
7135
+}
7136
+
7137
+func GetDrugWarehouseOutByLastId(id int64) (models.DrugWarehouseOut, error) {
7138
+	out := models.DrugWarehouseOut{}
7139
+	err := XTReadDB().Where("id = ? and status = 1", id).Find(&out).Error
7140
+	return out, err
7141
+}
7142
+
7143
+func UpdateDrugMaxNumber(count int64, id int64) error {
7144
+	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", count)).Error
7145
+	return err
7146
+}
7147
+
7148
+func UpdateDrugMinNumber(count int64, id int64) error {
7149
+	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number + ?", count)).Error
7150
+	return err
7151
+}
7152
+
7153
+func DeleteDrugOutFlow(id int64, orgid int64) error {
7154
+
7155
+	err := XTWriteDB().Model(models.DrugFlow{}).Where("warehouse_out_detail_id = ? and user_org_id = ? and status = 1", id, orgid).Update(map[string]interface{}{"status": 0}).Error
7156
+	return err
7157
+}
7158
+
7159
+func GetWarehouseOutByWarehouseInfoId(warehouse_info_id int64, good_id int64, orgid int64) (outInfo []*models.WarehouseOutInfo, err error) {
7160
+
7161
+	err = XTReadDB().Where("warehouse_info_id = ? and good_id = ? and org_id = ? and is_check = 1 and status = 1", warehouse_info_id, good_id, orgid).Find(&outInfo).Error
7162
+	return outInfo, err
7163
+}
7164
+
7165
+func GetDrugWarehouseOutByWarehouseInfoId(warehouse_info_id int64, drug_id int64, orgid int64) (outInfo []*models.DrugWarehouseOutInfo, err error) {
7166
+
7167
+	err = XTReadDB().Where("warehouse_info_id = ? and drug_id = ? and org_id = ? and is_check = 1 and status = 1", warehouse_info_id, drug_id, orgid).Find(&outInfo).Error
7168
+	return outInfo, err
7169
+}
7170
+
7171
+func GetAllStockInList(id int64, orgid int64) (info []*models.VmWarehousingInfoSix, err error) {
7172
+
7173
+	err = XTReadDB().Where("warehousing_id = ? and org_id  = ? and status = 1", id, orgid).Preload("GoodInfo", "status = 1 and org_id =?", orgid).Find(&info).Error
7174
+	return info, err
7175
+}
7176
+
7177
+func GetDrugWarehouseInfoList(id int64, orgid int64) (info []*models.DrugWarehouseInfoTwenty, err error) {
7178
+
7179
+	err = XTReadDB().Where("warehousing_id = ? and org_id = ? and status = 1", id, orgid).Preload("BaseDrugLib", "org_id = ? and status = 1", orgid).Find(&info).Error
7180
+
7181
+	return info, err
7182
+}
7183
+
7184
+func GetStockCountByGoodId(goodid int64, storehouse_id int64, orgId int64) (info []*models.WarehousingInfo, err error) {
7185
+
7186
+	err = XTReadDB().Where("good_id = ? and storehouse_id = ? and org_id = ? and status = 1 and is_check = 1", goodid, storehouse_id, orgId).Find(&info).Error
7187
+	return info, err
7188
+}
7189
+
7190
+func UpdateGoodInfoSumCount(goodid int64, sum_count int64, orgid int64) error {
7191
+
7192
+	err = XTWriteDB().Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).UpdateColumn("sum_count", gorm.Expr("sum_count + ?", sum_count)).Error
7193
+	err := XTWriteDB().Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).UpdateColumn("sum_in_count", gorm.Expr("sum_in_count + ?", sum_count)).Error
7194
+	return err
7195
+}
7196
+
7197
+func UpdateGoodInfoReduceSumCount(goodid int64, sum_count int64, orgid int64) error {
7198
+
7199
+	err = XTWriteDB().Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
7200
+	return err
7201
+}
7202
+
7203
+func GetCancelStockInfo(id int64, orgid int64) (stock []*models.CancelStockInfo, err error) {
7204
+
7205
+	err = XTReadDB().Where("cancel_stock_id  = ? and org_id = ? and status  = 1", id, orgid).Preload("GoodInfo", "status = 1 and org_id = ?", orgid).Preload("WarehousingInfo", "status = 1 and org_id = ?", orgid).Find(&stock).Error
7206
+	return stock, err
7207
+}
7208
+
7209
+func ModifyCancelStockInfo(id int64, info *models.CancelStockInfo) error {
7210
+
7211
+	err := XTWriteDB().Model(&models.CancelStockInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"good_id": info.GoodId, "good_type_id": info.GoodTypeId, "count": info.Count, "price": info.Price, "total": info.Total, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "number": info.Number, "register_account": info.RegisterAccount, "remark": info.Remark}).Error
7212
+	return err
7213
+}
7214
+
7215
+func GetCancelStockInfoListById(cancel_stock_id int64, orgid int64) (info []*models.CancelStockInfo, err error) {
7216
+
7217
+	err = XTReadDB().Where("cancel_stock_id = ? and org_id = ? and status = 1", cancel_stock_id, orgid).Find(&info).Error
7218
+	return info, err
7219
+}
7220
+
7221
+func GetWarehouseOutList(orgId int64, goodId int64, warehouseInfoId int64) (info []*models.WarehouseOutInfo, err error) {
7222
+
7223
+	err = XTReadDB().Where("org_id = ? and good_id = ? and warehouse_info_id = ? and status = 1", orgId, goodId, warehouseInfoId).Find(&info).Error
7224
+	return info, err
7225
+}
7226
+
7227
+func GetCancelWarehouseList(orgId int64, goodId int64, warehouseInfoId int64) (info []*models.CancelStockInfo, err error) {
7228
+
7229
+	err = XTReadDB().Where("org_id = ? and good_id = ? and warehouse_info_id = ? and status = 1", orgId, goodId, warehouseInfoId).Find(&info).Error
7230
+	return info, err
7231
+}
7232
+
7233
+func CheckCancelStock(stock models.CancelStock, cancel_stock_id int64, orgid int64) error {
7234
+
7235
+	err := XTWriteDB().Model(&models.CancelStock{}).Where("id = ? and status = 1 and org_id = ?", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 1}).Error
7236
+	err = XTWriteDB().Model(&models.CancelStockInfo{}).Where("cancel_stock_id = ? and status = 1 and org_id = ?", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 1}).Error
7237
+	return err
7238
+}
7239
+
7240
+func GetCancelStockInfoById(cancel_stock_id int64, orgid int64) (info []*models.CancelStockInfo, err error) {
7241
+
7242
+	err = XTReadDB().Where("cancel_stock_id = ? and org_id = ? and status = 1 and is_check = 1", cancel_stock_id, orgid).Find(&info).Error
7243
+	return info, err
7244
+}
7245
+
7246
+func UpdateCancelStockNumber(stock_count int64, warehouse_info_id int64, orgid int64) error {
7247
+
7248
+	err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and org_id = ? and status = 1", warehouse_info_id, orgid).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", stock_count)).Error
7249
+	return err
7250
+}
7251
+
7252
+func UpdateGoodSumCount(sum_count int64, good_id int64, orgid int64) error {
7253
+
7254
+	err := XTWriteDB().Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", good_id, orgid).UpdateColumn("sum_count", gorm.Expr("sum_count + ?", sum_count)).Error
7255
+	return err
7256
+}
7257
+
7258
+func UpdateStockWarehouseInfo(cancel_stock_id int64, orgid int64, stock models.CancelStock) error {
7259
+
7260
+	err := XTWriteDB().Model(&models.CancelStock{}).Where("id = ? and org_id = ? and status = 1", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 2}).Error
7261
+	err = XTWriteDB().Model(&models.CancelStockInfo{}).Where("cancel_stock_id = ? and org_id = ? and status = 1", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 2}).Error
7262
+	return err
7263
+}
7264
+
7265
+func UpdateStockWarehouseInfoStockFlow(id int64, orgid int64, goodid int64) error {
7266
+	err = XTWriteDB().Model(&models.VmStockFlow{}).Where("cancel_out_detail_id = ? and user_org_id = ? and status = 1 and good_id =?", id, orgid, goodid).Update(map[string]interface{}{"status": 0}).Error
7267
+	return err
7268
+}
7269
+
7270
+func UpdateStockNumberWarehouseInfo(warehouse_info_id int64, good_id int64, org_id int64, stock_count int64) error {
7271
+
7272
+	err := XTWriteDB().Model(&models.WarehousingInfo{}).Where("id = ? and good_id = ? and org_id = ? and status = 1", warehouse_info_id, good_id, org_id).UpdateColumn("stock_count", gorm.Expr("stock_count - ?", stock_count)).Error
7273
+	err = XTWriteDB().Model(&models.GoodInfo{}).Where("id = ? and status = 1 and org_id = ?", good_id, org_id).UpdateColumn("sum_count", gorm.Expr("sum_count - ?", stock_count)).Error
7274
+	return err
7275
+}
7276
+
7277
+func UpdateDrugSumCount(drugid int64, sum_count int64, sum_in_count int64, orgid int64) error {
7278
+
7279
+	err := XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and org_id = ?", drugid, orgid).UpdateColumn("sum_count", gorm.Expr("sum_count + ?", sum_count)).Error
7280
+	err = XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and org_id = ?", drugid, orgid).UpdateColumn("sum_in_count", gorm.Expr("sum_in_count + ?", sum_in_count)).Error
7281
+	return err
7282
+}
7283
+
7284
+func GetDrugStockWarehouseInfo(id int64, orgid int64) (info []*models.DrugWarehouseInfo, err error) {
7285
+
7286
+	err = XTReadDB().Where("id = ? and org_id = ? and status = 1 and is_check = 1", id, orgid).Find(&info).Error
7287
+	return info, err
7288
+}
7289
+
7290
+func UpdateBaseDrugSum(drugid int64, orgid int64, sum_count int64, sum_in_count int64) error {
7291
+
7292
+	err := XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and org_id = ? and status = 1", drugid, orgid).UpdateColumn("sum_count", gorm.Expr("sum_count + ?", sum_count)).Error
7293
+	err = XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and org_id = ? and status = 1", drugid, orgid).UpdateColumn("sum_in_count", gorm.Expr("sum_in_count + ?", sum_in_count)).Error
7294
+	return err
7295
+}
7296
+
7297
+func GetDrugAllStockInfo(storehouse_id int64, orgid int64, drugid int64) (info []*models.DrugWarehouseInfo, err error) {
7298
+
7299
+	err = XTReadDB().Where("storehouse_id  = ? and org_id = ? and status = 1 and drug_id = ? and is_check = 1", storehouse_id, orgid, drugid).Find(&info).Error
7300
+	return info, err
7301
+}
7302
+
7303
+func UpdateBaseDrugSumInfo(sum_count int64, drugid int64, orgid int64, sum_in_count int64) error {
7304
+
7305
+	err := XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and status = 1 and org_id = ?", drugid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
7306
+	err = XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and status = 1 and org_id = ?", drugid, orgid).Update(map[string]interface{}{"sum_in_count": sum_in_count}).Error
7307
+	return err
7308
+}
7309
+
7310
+func UpdateBaseDrugSumTwo(drugid int64, sum_count int64, orgid int64) error {
7311
+
7312
+	err = XTWriteDB().Model(&models.BaseDrugLib{}).Where("id = ? and org_id = ? and status = 1", drugid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
7313
+	return err
7314
+}
7315
+
7316
+func GetLastCancelStockByList(id int64, orgid int64) (info []*models.DrugCancelStockInfo, err error) {
7317
+
7318
+	err = XTReadDB().Where("cancel_stock_id = ? and org_id = ? and status = 1", id, orgid).Preload("DrugWarehouseInfo", "status = 1 and org_id = ?", orgid).Preload("BaseDrugLib", "status = 1 and org_id = ?", orgid).Find(&info).Error
7319
+	return info, err
7320
+}
7321
+
7322
+func GetCancelDrugStockList(cancel_stock_id int64, orgid int64) (info []*models.DrugCancelStockInfo, err error) {
7323
+
7324
+	err = XTReadDB().Where("cancel_stock_id = ? and org_id = ? and status = 1", cancel_stock_id, orgid).Find(&info).Error
7325
+	return info, err
7326
+}
7327
+
7328
+func ModifyCancelStock(cancel_stock_id int64, stock models.DrugCancelStock, orgid int64) error {
7329
+
7330
+	err := XTWriteDB().Model(&models.DrugCancelStock{}).Where("id = ? and org_id = ? and status = 1", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 1}).Error
7331
+	err = XTWriteDB().Model(&models.DrugCancelStockInfo{}).Where("cancel_stock_id = ? and org_id = ? and status = 1", cancel_stock_id, orgid).Update(map[string]interface{}{"is_check": 1}).Error
7332
+	return err
7333
+}
7334
+
7335
+func GetCancelDrugStock(cancel_stock_id int64, orgid int64) (models.DrugCancelStock, error) {
7336
+	stock := models.DrugCancelStock{}
7337
+	err := XTReadDB().Where("id = ? and org_id = ? and status = 1", cancel_stock_id, orgid).Find(&stock).Error
7338
+	return stock, err
7339
+}
7340
+
7341
+func GetDrugCancelCheckById(cancel_stock_id int64, orgid int64) (stock []*models.DrugCancelStockInfo, err error) {
7342
+
7343
+	err = XTReadDB().Where("cancel_stock_id = ? and org_id = ? and status = 1 and is_check = 1", cancel_stock_id, orgid).Find(&stock).Error
7344
+	return stock, err
7345
+}
7346
+
7347
+func GetDrugCancelCheckByIdTwenty(cancel_stock_id int64, orgid int64) (stock []*models.DrugCancelStockInfo, err error) {
7348
+
7349
+	err = XTReadDB().Where("cancel_stock_id = ? and org_id = ? and status = 1 ", cancel_stock_id, orgid).Find(&stock).Error
7350
+	return stock, err
7351
+}
7352
+
7353
+func GetDrugWarehouseOutList(batch_number_id int64, drugId int64, orgid int64) (info []*models.DrugWarehouseOutInfo, err error) {
7354
+
7355
+	err = XTReadDB().Where("warehouse_info_id = ? and drug_id  = ? and org_id = ? and status = 1", batch_number_id, drugId, orgid).Find(&info).Error
7356
+	return info, err
7357
+}
7358
+
7359
+func ModifyDrugWarehouseInfoStockMaxNumber(count int64, drugid int64, orgid int64, id int64) error {
7360
+
7361
+	err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and org_id = ? and drug_id = ? and status = 1", id, orgid, drugid).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", count)).Error
7362
+	return err
7363
+}
7364
+
7365
+func ModifyDrugWarehouseInfoStockMinNumber(count int64, drugid int64, orgid int64, id int64) error {
7366
+
7367
+	err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and org_id = ? and drug_id = ? and status = 1", id, orgid, drugid).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number + ?", count)).Error
7368
+	return err
7369
+}
7370
+
7371
+func ModifyDrugCancelStockInfo(id int64, info *models.DrugCancelStockInfo) error {
7372
+
7373
+	err := XTWriteDB().Model(&models.DrugCancelStockInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"drug_id": info.DrugId, "count": info.Count, "price": info.Price, "total": info.Total, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "retail_price": info.RetailPrice, "retail_total_price": info.RetailTotalPrice, "number": info.Number, "register_account": info.RegisterAccount, "remark": info.Remark, "batch_number": info.BatchNumber, "max_unit": info.MaxUnit, "batch_number_id": info.BatchNumberId, "storehouse_id": info.StorehouseId}).Error
7374
+	return err
7375
+}
7376
+
7377
+func ReturnDrugCancelStock(cancelstock_id int64, stock models.DrugCancelStock) error {
7378
+
7379
+	err := XTWriteDB().Model(&models.DrugCancelStock{}).Where("id = ? and status = 1", cancelstock_id).Update(map[string]interface{}{"is_check": 2}).Error
7380
+	err = XTWriteDB().Model(&models.DrugCancelStockInfo{}).Where("cancel_stock_id = ? and status = 1", cancelstock_id).Update(map[string]interface{}{"is_check": 2}).Error
7381
+	return err
7382
+}
7383
+
7384
+func GetDrugCancelStockInfo(cancelstock_id int64, orgid int64) (info []*models.DrugCancelStockInfo, err error) {
7385
+
7386
+	err = XTReadDB().Where("cancel_stock_id = ? and org_id = ? and status = 1", cancelstock_id, orgid).Find(&info).Error
7387
+	return info, err
7388
+}
7389
+
7390
+func ModifyDrugFlowByCancelId(cancelstock_id int64, drugId int64, orgid int64) error {
7391
+	err := XTWriteDB().Model(&models.DrugFlow{}).Where("cancel_out_detail_id = ? and drug_id = ? and user_org_id = ? and status = 1", cancelstock_id, drugId, orgid).Update(map[string]interface{}{"status": 0}).Error
7392
+	return err
7393
+}
7394
+
7395
+func ModifyDrugMaxNumberWarehouseInfo(id int64, count int64, orgid int64) error {
7396
+
7397
+	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and org_id = ? and status = 1", id, orgid).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number - ?", count)).Error
7398
+	return err
7399
+}
7400
+
7401
+func ModifyDrugMinNumberWarehouseInfo(id int64, count int64, orgid int64) error {
7402
+
7403
+	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and org_id = ? and status = 1", id, orgid).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number - ?", count)).Error
7404
+	return err
7405
+}
7406
+
7407
+func GetDrugInfoSix(id int64, orgid int64) (models.DrugWarehouseInfo, error) {
7408
+
7409
+	info := models.DrugWarehouseInfo{}
7410
+	err := XTReadDB().Where("id = ? and org_id = ? and status = 1 and is_check = 1", id, orgid).Find(&info).Error
7411
+	return info, err
7412
+}

+ 2 - 2
service/supply_service.go Vedi File

@@ -768,7 +768,7 @@ func GetSupplySupplyWarehouseId(id int64, orgid int64) (models.WarehousingInfo,
768 768
 
769 769
 func GetSupplySupplyWarehouseIdSeven(id int64, orgid int64) (info []*models.WarehousingInfo, err error) {
770 770
 
771
-	err = XTReadDB().Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Find(&info).Error
771
+	err = XTReadDB().Where("supply_warehouse_id = ? and org_id = ? and status = 1 and is_check = 1", id, orgid).Find(&info).Error
772 772
 	return info, err
773 773
 }
774 774
 
@@ -780,7 +780,7 @@ func GetDrugSupplyWarehouseId(id int64, orgid int64) (models.DrugWarehouseInfo,
780 780
 
781 781
 func GetDrugSupplyWarehouseIdSeven(id int64, orgid int64) (info []*models.DrugWarehouseInfo, err error) {
782 782
 
783
-	err = XTReadDB().Where("supply_warehouse_id = ? and org_id = ? and status = 1", id, orgid).Find(&info).Error
783
+	err = XTReadDB().Where("supply_warehouse_id = ? and org_id = ? and status = 1 and is_check = 1", id, orgid).Find(&info).Error
784 784
 	return info, err
785 785
 }
786 786
 

File diff suppressed because it is too large
+ 642 - 66
service/warhouse_service.go