Browse Source

11月8日库存管理

XMLWAN 3 years ago
parent
commit
956f37f6cf

+ 4 - 1
controllers/gobal_config_api_controller.go View File

@@ -1904,7 +1904,7 @@ func (c *GobalConfigApiController) GetDrugStockFllow() {
1904 1904
 	}
1905 1905
 	orgId := c.GetAdminUserInfo().CurrentOrgId
1906 1906
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
1907
-
1907
+	medical, _ := service.GetBaseDrugMedical(drug_id)
1908 1908
 	//查询入库数据
1909 1909
 	if stock_type == 3 || stock_type == 0 {
1910 1910
 		list, total, err := service.GetDrugStockFlow(drug_id, startTime, endTime, page, limit, orgId)
@@ -1916,6 +1916,7 @@ func (c *GobalConfigApiController) GetDrugStockFllow() {
1916 1916
 			"list":             list,
1917 1917
 			"total":            total,
1918 1918
 			"manufacturerList": manufacturerList,
1919
+			"drug":             medical,
1919 1920
 		})
1920 1921
 	}
1921 1922
 
@@ -2192,11 +2193,13 @@ func (c *GobalConfigApiController) GetDrugFlow() {
2192 2193
 	list, total, _ := service.GetDrugFlow(drug_id, orgId, limit, page, startTime, endTime, stock_type)
2193 2194
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2194 2195
 	dealerList, _ := service.GetAllDealerList(orgId)
2196
+	medical, _ := service.GetBaseDrugMedical(drug_id)
2195 2197
 	c.ServeSuccessJSON(map[string]interface{}{
2196 2198
 		"list":             list,
2197 2199
 		"total":            total,
2198 2200
 		"manufacturerList": manufacturerList,
2199 2201
 		"dealerList":       dealerList,
2202
+		"drug":             medical,
2200 2203
 	})
2201 2204
 }
2202 2205
 

+ 0 - 1
controllers/manager_center_api_controller.go View File

@@ -303,7 +303,6 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
303 303
 	hosp_appr_flag, _ := c.GetInt64("hosp_appr_flag")
304 304
 	lmt_used_flag, _ := c.GetInt64("lmt_used_flag")
305 305
 	prescribing_number_unit := c.GetString("prescribing_number_unit")
306
-
307 306
 	adminInfo := c.GetAdminUserInfo()
308 307
 	drug, _ := service.FindBaseDrugLibRecord(adminInfo.CurrentOrgId, id)
309 308
 	drugLib := &models.BaseDrugLib{

+ 4 - 3
controllers/stock_in_api_controller.go View File

@@ -1258,7 +1258,7 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
1258 1258
 
1259 1259
 				var productDate int64
1260 1260
 				if len(product_date) > 0 {
1261
-					theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", expiry_date+" 00:00:00", loc)
1261
+					theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", product_date+" 00:00:00", loc)
1262 1262
 					if err != nil {
1263 1263
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1264 1264
 						return
@@ -1346,6 +1346,7 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
1346 1346
 			"good_name":          "",
1347 1347
 			"specification_name": "",
1348 1348
 		})
1349
+		return
1349 1350
 	}
1350 1351
 }
1351 1352
 func (c *StockManagerApiController) GetWarehouseOutList() {
@@ -1573,7 +1574,7 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1573 1574
 
1574 1575
 				var productDate int64
1575 1576
 				if len(product_date) > 0 {
1576
-					theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", expiry_date+" 00:00:00", loc)
1577
+					theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", product_date+" 00:00:00", loc)
1577 1578
 					if err != nil {
1578 1579
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1579 1580
 						return
@@ -1696,7 +1697,7 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1696 1697
 
1697 1698
 	if len(upDateWarehouseOutInfos) > 0 {
1698 1699
 		for _, item := range upDateWarehouseOutInfos {
1699
-
1700
+			fmt.Println("item2332323232323", item.ProductDate, item.ExpiryDate)
1700 1701
 			//1.查询该耗材该批次的最后一次出库记录
1701 1702
 			lastGood, _ := service.GetLastGoodInformationByGoodId(item.GoodId, item.WarehouseInfotId)
1702 1703
 

+ 38 - 15
service/manage_service.go View File

@@ -799,25 +799,48 @@ func GetAllEquitName(orgid int64) (equiment []*models.DeviceEquimentname, err er
799 799
 
800 800
 func GetUserForm(id int64, orgId int64, limit int64, page int64) (infor []*models.DeviceInformations, total int64, err error) {
801 801
 
802
-	db := UserReadDB().Table("xt_device_information as x").Where("x.status = 1")
803
-	table := XTReadDB().Table("xt_patients as p")
804
-	fmt.Println("table", table)
805
-	dbs := UserReadDB().Table("sgj_user_admin_role as r")
806
-	fmt.Println("dbs", dbs)
807
-	offset := (page - 1) * limit
802
+	if orgId == 10060 {
803
+		db := UserReadDB().Table("xt_device_information as x").Where("x.status = 1")
804
+		table := XTReadDB().Table("xt_patients as p")
805
+		fmt.Println("table", table)
806
+		dbs := UserReadDB().Table("sgj_user_admin_role as r")
807
+		fmt.Println("dbs", dbs)
808
+		offset := (page - 1) * limit
809
+
810
+		if id > 0 {
811
+			db = db.Where("x.equiment_id = ?", id)
812
+		}
808 813
 
809
-	if id > 0 {
810
-		db = db.Where("x.equiment_id = ?", id)
811
-	}
814
+		if orgId > 0 {
815
+			db = db.Where("x.user_org_id = ?", orgId)
816
+		}
817
+		err = db.Group("x.id").Select("x.id,x.date,x.class,x.zone,x.bed_number,x.patient_id,x.contagion,x.dialysis_mode,x.start_time,x.end_time,x.dialysis_hour,x.hyperfiltratio,x.weight_loss,x.warning_value,x.user_total,x.move,x.failure_stage,x.fault_description,x.code_information,x.disinfect_type,x.disinfectant_type,x.disinfection,x.machine_run,x.fluid_path,x.disinfectant,x.disinfection_status,x.disinfection_residue,x.long_time,x.disinfec_startime,x.disinfec_endtime,x.dialysis_checked,x.dialysis_name,x.norms,x.dialysis_concentration,x.germ_checked,x.germ_name,x.germ_number,x.clean,x.sign_name,x.equiment_id,x.bed,p.name,r.user_name").Count(&total).Joins("Left Join sgj_xt.xt_patients as p on p.id = x.patient_id").Joins("Left Join sgj_user_admin_role as r on r.admin_user_id = x.sign_name").Offset(offset).Limit(limit).Order("x.date asc").Scan(&infor).Error
818
+		if err != nil {
819
+			return
820
+		}
821
+		return
822
+	} else {
823
+		db := UserReadDB().Table("xt_device_information as x").Where("x.status = 1")
824
+		table := XTReadDB().Table("xt_patients as p")
825
+		fmt.Println("table", table)
826
+		dbs := UserReadDB().Table("sgj_user_admin_role as r")
827
+		fmt.Println("dbs", dbs)
828
+		offset := (page - 1) * limit
829
+
830
+		if id > 0 {
831
+			db = db.Where("x.equiment_id = ?", id)
832
+		}
812 833
 
813
-	if orgId > 0 {
814
-		db = db.Where("x.user_org_id = ?", orgId)
815
-	}
816
-	err = db.Group("x.id").Select("x.id,x.date,x.class,x.zone,x.bed_number,x.patient_id,x.contagion,x.dialysis_mode,x.start_time,x.end_time,x.dialysis_hour,x.hyperfiltratio,x.weight_loss,x.warning_value,x.user_total,x.move,x.failure_stage,x.fault_description,x.code_information,x.disinfect_type,x.disinfectant_type,x.disinfection,x.machine_run,x.fluid_path,x.disinfectant,x.disinfection_status,x.disinfection_residue,x.long_time,x.disinfec_startime,x.disinfec_endtime,x.dialysis_checked,x.dialysis_name,x.norms,x.dialysis_concentration,x.germ_checked,x.germ_name,x.germ_number,x.clean,x.sign_name,x.equiment_id,x.bed,p.name,r.user_name").Count(&total).Joins("Left Join sgj_xt.xt_patients as p on p.id = x.patient_id").Joins("Left Join sgj_user_admin_role as r on r.admin_user_id = x.sign_name").Offset(offset).Limit(limit).Order("x.date desc").Scan(&infor).Error
817
-	if err != nil {
834
+		if orgId > 0 {
835
+			db = db.Where("x.user_org_id = ?", orgId)
836
+		}
837
+		err = db.Group("x.id").Select("x.id,x.date,x.class,x.zone,x.bed_number,x.patient_id,x.contagion,x.dialysis_mode,x.start_time,x.end_time,x.dialysis_hour,x.hyperfiltratio,x.weight_loss,x.warning_value,x.user_total,x.move,x.failure_stage,x.fault_description,x.code_information,x.disinfect_type,x.disinfectant_type,x.disinfection,x.machine_run,x.fluid_path,x.disinfectant,x.disinfection_status,x.disinfection_residue,x.long_time,x.disinfec_startime,x.disinfec_endtime,x.dialysis_checked,x.dialysis_name,x.norms,x.dialysis_concentration,x.germ_checked,x.germ_name,x.germ_number,x.clean,x.sign_name,x.equiment_id,x.bed,p.name,r.user_name").Count(&total).Joins("Left Join sgj_xt.xt_patients as p on p.id = x.patient_id").Joins("Left Join sgj_user_admin_role as r on r.admin_user_id = x.sign_name").Offset(offset).Limit(limit).Order("x.date desc").Scan(&infor).Error
838
+		if err != nil {
839
+			return
840
+		}
818 841
 		return
819 842
 	}
820
-	return
843
+
821 844
 }
822 845
 
823 846
 func GetBedNumber(id int64, orgid int64) (models.DeviceAddmacher, error) {

+ 1 - 1
service/patient_service.go View File

@@ -1183,7 +1183,7 @@ func UpdateDoctorAdviceAndSubAdvice(m *models.DoctorAdvice) (err error) {
1183 1183
 		ut.Rollback()
1184 1184
 		return
1185 1185
 	}
1186
-	err = ut.Model(&models.DoctorAdvice{}).Where("status = 1   AND parent_id IN (?)", m.ID).Updates(map[string]interface{}{"start_time": m.StartTime, "groupno": m.GroupNo, "mtime": time.Now().Unix()}).Error
1186
+	err = ut.Model(&models.DoctorAdvice{}).Where("status = 1   AND parent_id IN (?)", m.ID).Updates(map[string]interface{}{"start_time": m.StartTime, "groupno": m.GroupNo, "updated_time": time.Now().Unix()}).Error
1187 1187
 	if err != nil {
1188 1188
 		ut.Rollback()
1189 1189
 		return

+ 7 - 8
service/warhouse_service.go View File

@@ -1696,6 +1696,8 @@ func ConsumablesDeliveryOne(orgID int64, record_time int64, goods *models.Wareho
1696 1696
 
1697 1697
 		maxNumber = goods.Count
1698 1698
 
1699
+		fmt.Println("数据1111111111111", warehouse.StockCount)
1700
+		fmt.Println("s数据233232323232323232233232", maxNumber)
1699 1701
 		if warehouse.StockCount < maxNumber {
1700 1702
 			return errors.New("库存数量不足")
1701 1703
 		}
@@ -1703,14 +1705,11 @@ func ConsumablesDeliveryOne(orgID int64, record_time int64, goods *models.Wareho
1703 1705
 		warehouse.StockCount = warehouse.StockCount - maxNumber
1704 1706
 		warehouse.Mtime = time.Now().Unix()
1705 1707
 
1706
-		if warehouse.StockCount <= 0 {
1707
-			return errors.New("库存数量不足")
1708
-		} else {
1709
-			//扣减库存
1710
-			errThree := UpDateWarehouseInfoByStock(&warehouse)
1711
-			if errThree != nil {
1712
-				return errThree
1713
-			}
1708
+		//扣减库存
1709
+		errThree := UpDateWarehouseInfoByStock(&warehouse)
1710
+		fmt.Println("几年里2323323232323232323232")
1711
+		if errThree != nil {
1712
+			return errThree
1714 1713
 		}
1715 1714
 
1716 1715
 	} else {