Browse Source

耗材参数

XMLWAN 3 years ago
parent
commit
66ba19ca86

+ 10 - 3
controllers/print_data_api_controller.go View File

@@ -92,13 +92,20 @@ func (this *PrintDataAPIController) StockRecordPrintData() {
92 92
 
93 93
 	list, err := service.FindPrintStockGoodInfoByType(types, startTime, endTime, adminUserInfo.CurrentOrgId)
94 94
 	stockTotal, err := service.GetOutStockTotalCountTwo(startTime, endTime, adminUserInfo.CurrentOrgId)
95
+
96
+	info, err := service.GetCoutWareseOutInfo(startTime, endTime, adminUserInfo.CurrentOrgId)
97
+
98
+	infomationList, err := service.GetGoodInfomationList(adminUserInfo.CurrentOrgId)
95 99
 	if err != nil {
96 100
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
97 101
 	} else {
98 102
 		this.ServeSuccessJSON(map[string]interface{}{
99
-			"list":       list,
100
-			"type":       types,
101
-			"stockTotal": stockTotal,
103
+			"list":           list,
104
+			"type":           types,
105
+			"stockTotal":     stockTotal,
106
+			"info":           info,
107
+			"orgid":          adminUserInfo.CurrentOrgId,
108
+			"infomationList": infomationList,
102 109
 		})
103 110
 	}
104 111
 }

+ 70 - 3
controllers/stock_in_api_controller.go View File

@@ -67,6 +67,8 @@ func StockManagerApiRegistRouters() {
67 67
 	beego.Router("/api/warehouseout/postsearchstock", &StockManagerApiController{}, "Get:PostSearchStock")
68 68
 
69 69
 	beego.Router("/api/warehouseout/getoutstocktotalcount", &StockManagerApiController{}, "Get:GetOutStockTotalCount")
70
+
71
+	beego.Router("/api/good/postgoodinformation", &StockManagerApiController{}, "Post:AddGoodInformation")
70 72
 }
71 73
 
72 74
 func (c *StockManagerApiController) CreateWarehouse() {
@@ -1379,7 +1381,7 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1379 1381
 					sys_record_time := int64(items["sys_record_time"].(float64))
1380 1382
 
1381 1383
 					warehouseOutInfo := &models.WarehouseOutInfo{
1382
-						ID: id,
1384
+						ID:                      id,
1383 1385
 						WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1384 1386
 						WarehouseOutId:          warehouseOut.ID,
1385 1387
 						GoodId:                  good_id,
@@ -1804,10 +1806,16 @@ func (c *StockManagerApiController) GetQueryInfo() {
1804 1806
 	}
1805 1807
 	adminUserInfo := c.GetAdminUserInfo()
1806 1808
 	list, total, err := service.FindAllStockInfo(adminUserInfo.CurrentOrgId, page, limit, keyword, startTime, endTime, type_name)
1809
+	info, err := service.GetCoutWareseOutInfo(startTime, endTime, adminUserInfo.CurrentOrgId)
1810
+
1811
+	infomationList, err := service.GetGoodInfomationList(adminUserInfo.CurrentOrgId)
1807 1812
 	if err == nil {
1808 1813
 		c.ServeSuccessJSON(map[string]interface{}{
1809
-			"list":  list,
1810
-			"total": total,
1814
+			"list":           list,
1815
+			"total":          total,
1816
+			"info":           info,
1817
+			"infomationList": infomationList,
1818
+			"orgid":          adminUserInfo.CurrentOrgId,
1811 1819
 		})
1812 1820
 	} else {
1813 1821
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
@@ -1993,3 +2001,62 @@ func (this *StockManagerApiController) GetOutStockTotalCount() {
1993 2001
 		"stockCount": stockCount,
1994 2002
 	})
1995 2003
 }
2004
+
2005
+func (this *StockManagerApiController) AddGoodInformation() {
2006
+	dataBody := make(map[string]interface{}, 0)
2007
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
2008
+	if err != nil {
2009
+		utils.ErrorLog(err.Error())
2010
+		return
2011
+	}
2012
+	utils.ErrorLog("%v", dataBody)
2013
+
2014
+	tempGoods := dataBody["goods"].([]interface{})
2015
+	fmt.Println("3333333333", tempGoods)
2016
+	var goods []*models.GoodInfo
2017
+	for index, goodMap := range tempGoods {
2018
+		goodNameM := goodMap.(map[string]interface{})
2019
+		fmt.Println("00000", goodNameM)
2020
+		var good models.GoodInfo
2021
+		if goodNameM["good_name"] == nil || reflect.TypeOf(goodNameM["good_name"]).String() != "string" {
2022
+			utils.ErrorLog("good_name")
2023
+			return
2024
+		}
2025
+
2026
+		good_name, _ := goodNameM["good_name"].(string)
2027
+		if len(good_name) == 0 { //名字为空则生成一条导入错误日志
2028
+			err_log := models.ExportErrLog{
2029
+				LogType:    5,
2030
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2031
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的耗材名称不能为空",
2032
+				Status:     1,
2033
+				CreateTime: time.Now().Unix(),
2034
+				UpdateTime: time.Now().Unix(),
2035
+				ExportTime: time.Now().Unix(),
2036
+			}
2037
+			service.CreateExportErrLog(&err_log)
2038
+			continue
2039
+		}
2040
+		fmt.Println("33333333", good_name)
2041
+		good.GoodName = good_name
2042
+		if goodNameM["medical_insurance_level"] == nil || reflect.TypeOf(goodNameM["medical_insurance_level"]).String() != "string" {
2043
+			utils.ErrorLog("medical_insurance_level")
2044
+			return
2045
+		}
2046
+		medical_insurance_level := goodNameM["medical_insurance_level"].(string)
2047
+		medical_insurance_levels, _ := strconv.ParseInt(medical_insurance_level, 10, 64)
2048
+		good.MedicalInsuranceLevel = medical_insurance_levels
2049
+
2050
+		goods = append(goods, &good)
2051
+	}
2052
+	adminUser := this.GetAdminUserInfo()
2053
+	orgId := adminUser.CurrentOrgId
2054
+	if len(goods) > 0 {
2055
+		for _, item := range goods {
2056
+			service.CreateGoodsInfomation(item, orgId)
2057
+			this.ServeSuccessJSON(map[string]interface{}{
2058
+				"msg": "导入成功",
2059
+			})
2060
+		}
2061
+	}
2062
+}

+ 8 - 0
models/stock_models.go View File

@@ -308,3 +308,11 @@ type AutomaticReduceDetail struct {
308 308
 func (AutomaticReduceDetail) TableName() string {
309 309
 	return "xt_automatic_reduce_detail"
310 310
 }
311
+
312
+type VmWarehouseOutInfo struct {
313
+	GoodId int64   `gorm:"column:good_id" json:"good_id"`
314
+	Count  int64   `gorm:"column:count" json:"count"`
315
+	Remark string  `gorm:"column:remark" json:"remark"`
316
+	Price  float64 `gorm:"column:price" json:"price"`
317
+	OrgId  int64   `gorm:"column:org_id" json:"org_id"`
318
+}

+ 13 - 0
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go View File

@@ -198,3 +198,16 @@ func GetOutStockTotalCountTwo(startime int64, endtime int64, orgid int64) (autoM
198 198
 
199 199
 	return autoMatic, err
200 200
 }
201
+
202
+func GetCoutWareseOutInfo(startime int64, endtime int64, orgid int64) (houseOutInfo []*models.VmWarehouseOutInfo, err error) {
203
+
204
+	db := p_service.XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status  =1")
205
+	err = db.Select("x.good_id,Sum(x.count) as count,x.remark,x.price,x.org_id").Where("x.ctime >=? and x.ctime<=? and x.org_id = ?", startime, endtime, orgid).Group("x.good_id").Scan(&houseOutInfo).Error
206
+	return houseOutInfo, err
207
+}
208
+
209
+func GetGoodInfomationList(orgid int64) (goodInfo []*models.GoodInfo, err error) {
210
+
211
+	err = p_service.XTReadDB().Where("org_id = ? and status = 1", orgid).Find(&goodInfo).Error
212
+	return goodInfo, err
213
+}

+ 26 - 0
service/stock_service.go View File

@@ -2226,3 +2226,29 @@ func GetManufacturerName(orgid int64, name string) (*models.Manufacturer, error)
2226 2226
 	}
2227 2227
 	return &manufacturer, nil
2228 2228
 }
2229
+
2230
+func CreateGoodsInfomation(info *models.GoodInfo, orgid int64) error {
2231
+
2232
+	goodInfo := models.GoodInfo{
2233
+		GoodName:              info.GoodName,
2234
+		MedicalInsuranceLevel: info.MedicalInsuranceLevel,
2235
+		OrgId:                 orgid,
2236
+		Status:                1,
2237
+		Ctime:                 time.Now().Unix(),
2238
+	}
2239
+	err := XTWriteDB().Create(&goodInfo).Error
2240
+	return err
2241
+}
2242
+
2243
+func GetCoutWareseOutInfo(startime int64, endtime int64, orgid int64) (houseOutInfo []*models.VmWarehouseOutInfo, err error) {
2244
+
2245
+	db := XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status  =1")
2246
+	err = db.Select("x.good_id,Sum(x.count) as count,x.remark,x.price,x.org_id").Where("x.ctime >=? and x.ctime<=? and x.org_id = ?", startime, endtime, orgid).Group("x.good_id").Scan(&houseOutInfo).Error
2247
+	return houseOutInfo, err
2248
+}
2249
+
2250
+func GetGoodInfomationList(orgid int64) (goodInfo []*models.GoodInfo, err error) {
2251
+
2252
+	err = XTReadDB().Where("org_id = ? and status = 1", orgid).Find(&goodInfo).Error
2253
+	return goodInfo, err
2254
+}