XMLWAN před 4 roky
rodič
revize
8eecfee880

+ 27 - 3
controllers/stock_in_api_controller.go Zobrazit soubor

@@ -1376,7 +1376,7 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1376 1376
 					sys_record_time := int64(items["sys_record_time"].(float64))
1377 1377
 
1378 1378
 					warehouseOutInfo := &models.WarehouseOutInfo{
1379
-						ID: id,
1379
+						ID:                      id,
1380 1380
 						WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1381 1381
 						WarehouseOutId:          warehouseOut.ID,
1382 1382
 						GoodId:                  good_id,
@@ -1774,9 +1774,33 @@ func (c *StockManagerApiController) GetQueryInfo() {
1774 1774
 	page, _ := c.GetInt64("page", -1)
1775 1775
 	limit, _ := c.GetInt64("limit", -1)
1776 1776
 	keyword := c.GetString("keyword")
1777
-
1777
+	start_time := c.GetString("start_time")
1778
+	end_time := c.GetString("end_time")
1779
+	type_name, _ := c.GetInt64("type_name")
1780
+	timeLayout := "2006-01-02"
1781
+	loc, _ := time.LoadLocation("Local")
1782
+	var startTime int64
1783
+	if len(start_time) > 0 {
1784
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1785
+		if err != nil {
1786
+			fmt.Println(err)
1787
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1788
+			return
1789
+		}
1790
+		startTime = theTime.Unix()
1791
+	}
1792
+	var endTime int64
1793
+	if len(end_time) > 0 {
1794
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
1795
+		if err != nil {
1796
+			utils.ErrorLog(err.Error())
1797
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1798
+			return
1799
+		}
1800
+		endTime = theTime.Unix()
1801
+	}
1778 1802
 	adminUserInfo := c.GetAdminUserInfo()
1779
-	list, total, err := service.FindAllStockInfo(adminUserInfo.CurrentOrgId, page, limit, keyword)
1803
+	list, total, err := service.FindAllStockInfo(adminUserInfo.CurrentOrgId, page, limit, keyword, startTime, endTime, type_name)
1780 1804
 	if err == nil {
1781 1805
 		c.ServeSuccessJSON(map[string]interface{}{
1782 1806
 			"list":  list,

+ 1 - 1
service/his_project_service.go Zobrazit soubor

@@ -389,7 +389,7 @@ func GetHistPatient(orgid int64, keyword string) (hisPatient []*models.HisPatien
389 389
 
390 390
 func GetDoctorAdvicePrint(his_patient_id int64, recorddate int64, schIDs []string, orgid int64) (prescription []*models.HisPrescription, err error) {
391 391
 
392
-	err = XTReadDB().Model(&prescription).Where("patient_id = ? and record_date = ? and id in(?) and  status = 1 ", his_patient_id, recorddate, schIDs).Preload("Patients", "status = 1 and user_org_id = ?", orgid).Preload("HisDoctorAdviceInfo", "status = 1 and user_org_id = ?", orgid).Preload("HisPrescriptionProject", "status = 1 and user_org_id = ?", orgid).Preload("XtHisAdditionalCharge", "status = 1", orgid).Find(&prescription).Error
392
+	err = XTReadDB().Model(&prescription).Where("patient_id = ? and record_date = ? and id in(?) and  status = 1 ", his_patient_id, recorddate, schIDs).Preload("Patients", "status = 1 and user_org_id = ?", orgid).Preload("HisDoctorAdviceInfo", "status = 1 and user_org_id = ?", orgid).Preload("HisPrescriptionProject", "status = 1 and user_org_id = ?", orgid).Preload("XtHisAdditionalCharge", "status = 1 and user_org_id = ?", orgid).Find(&prescription).Error
393 393
 
394 394
 	return prescription, err
395 395
 }

+ 19 - 4
service/stock_service.go Zobrazit soubor

@@ -1144,18 +1144,28 @@ func FindAllStockOutList(orgId int64, page int64, limit int64, startTime int64,
1144 1144
 	return
1145 1145
 }
1146 1146
 
1147
-func FindAllStockInfo(orgId int64, page int64, limit int64, keyword string) (list []*models.StockInfo, total int64, err error) {
1147
+func FindAllStockInfo(orgId int64, page int64, limit int64, keyword string, startime int64, endtime int64, type_name int64) (list []*models.StockInfo, total int64, err error) {
1148 1148
 
1149 1149
 	db := readDb.Model(&models.StockInfo{})
1150
+	if startime > 0 {
1151
+		db = db.Where("ctime >=?", startime)
1152
+	}
1153
+	if endtime > 0 {
1154
+		db = db.Where("ctime<=?", endtime)
1155
+	}
1150 1156
 	db = db.Where("xt_good_information.org_id = ? AND xt_good_information.status = 1", orgId)
1151 1157
 	db = db.Group("xt_good_information.id")
1152 1158
 	db = db.Preload("QueryWarehousingInfo", func(db *gorm.DB) *gorm.DB {
1153 1159
 		return db.Where("org_id = ? AND status = 1", orgId)
1154 1160
 	})
1155 1161
 	db = db.Preload("QuerySalesReturnInfo", "org_id = ? AND status = 1", orgId)
1156
-	db = db.Preload("QueryWarehouseOutInfo", func(db *gorm.DB) *gorm.DB {
1157
-		return db.Where("org_id = ? AND status = 1", orgId)
1158
-	})
1162
+
1163
+	if startime == 0 || endtime == 0 {
1164
+		db = db.Preload("QueryWarehouseOutInfo", func(db *gorm.DB) *gorm.DB {
1165
+			return db.Where("org_id = ? AND status = 1", orgId)
1166
+		})
1167
+	}
1168
+
1159 1169
 	db = db.Preload("QueryCancelStockInfo", "org_id = ? AND status = 1", orgId)
1160 1170
 	db = db.Preload("GoodsType", "org_id = ? AND status = 1", orgId)
1161 1171
 
@@ -1165,6 +1175,11 @@ func FindAllStockInfo(orgId int64, page int64, limit int64, keyword string) (lis
1165 1175
 		db = db.Where("xt_good_information.good_code LIKE ? OR xt_good_information.specification_name LIKE ? OR xt_goods_type.type_name LIKE ?", likeKey, likeKey, likeKey).Group("xt_good_information.id")
1166 1176
 	}
1167 1177
 
1178
+	if type_name > 0 {
1179
+
1180
+		db = db.Joins("join xt_goods_type on xt_goods_type.id = xt_good_information.good_type_id  AND xt_goods_type.org_id = ? AND xt_goods_type.status = 1 and xt_goods_type.id = ?", orgId, type_name)
1181
+	}
1182
+
1168 1183
 	db = db.Count(&total)
1169 1184
 	offset := (page - 1) * limit
1170 1185
 	err = db.Offset(offset).Limit(limit).Order("ctime desc").Find(&list).Error