zoie il y a 1 an
Parent
commit
c631ece6f9

+ 2 - 1
.gitignore

@@ -26,4 +26,5 @@ _testmain.go
 
 bin
 ./Medical_ERP
-./ofile
+ofile
+files

+ 1 - 1
Makefile

@@ -3,7 +3,7 @@ PREFIX=$(shell pwd)
 CMD_PACKAGE=${PACKAGE}
 OUTPUT_DIR=${PREFIX}/bin
 OUTPUT_FILE=${OUTPUT_DIR}/Medical_ERP
-OUTPUT_FILE_LINUX=${OUTPUT_DIR}/linux/Medical_ERP
+OUTPUT_FILE_LINUX=${OUTPUT_DIR}/linux/Medical_ERP6410
 COMMIT_ID=$(shell git rev-parse --short HEAD)
 VERSION=$(shell git describe --tags || echo "v0.0.1")
 VERSION_IMPORT_PATH=github.com/lneoe/go-help-libs/version

+ 5 - 0
common/global/constant.go

@@ -20,6 +20,8 @@ const (
 	BadRequest = 400
 	// Unauthorized 未认证
 	Unauthorized = 401
+	// NoAccessErr 无权访问
+	NoAccessErr = 402
 	// PageNotFoundErr 	页面未找到
 	PageNotFoundErr = 404
 
@@ -36,6 +38,9 @@ const (
 	UnmarshalErr         = 505
 	// ParseFormErr 解析表单数据异常
 	ParseFormErr = 506
+
+	// EnterDeptErr 未进入公司
+	EnterDeptErr = 600
 )
 
 var (

+ 2 - 1
common/initialize/db.go

@@ -92,7 +92,8 @@ func init() {
 	)
 
 	DB, Err = gorm.Open(mysql.Open(dataSource), &gorm.Config{
-		Logger: newLogger,
+		Logger:               newLogger,
+		DisableAutomaticPing: true,
 	})
 
 	if Err != nil {

+ 19 - 9
conf/app.conf

@@ -6,16 +6,23 @@ copyrequestbody = true
 EnableDocs = true
 
 # 数据库配置(Mysql)
-mysqlUrlPort = "192.168.11.77:3306"
-mysqlDB = "medical_erp"
-mysqlUser = "medical_erp"
-mysqlPass= "XMzTDthD4By3ArjG"
+# mysqlUrlPort = "192.168.11.77:3306"
+# mysqlDB = "medical_erp"
+# mysqlUser = "medical_erp"
+# mysqlPass= "XMzTDthD4By3ArjG"
+# mysqlMaxConns = 100
+# MysqlMaxOpen = 200
+# 数据库配置(Mysql)
+mysqlUrlPort = "127.0.0.1:40306"
+mysqlDB = "godown"
+mysqlUser = "godown"
+mysqlPass= "wCHDXHL35kZGSD8r"
 mysqlMaxConns = 100
 MysqlMaxOpen = 200
 
 # 日志配置
 # 0-控制台输出 1-文件输出 2-文件和控制台输出
-adapter_type = 0
+adapter_type = 2
 # 文件最多保存多少天
 maxdays = 7
 # 日志级别 (0-紧急 1-报警 2-严重错误 3-错误 4-警告 5-注意 6-信息 7-调试)
@@ -28,18 +35,21 @@ slow_threshold = 200
 maxlines = 10000
 
 #redis
-Redis_address = "192.168.11.77:6379"
+# Redis_address = "192.168.11.77:6379"
+Redis_address = "127.0.0.1:43379"
 Redis_password = ""
-Redis_dbNum = "4"
+Redis_dbNum = "3"
 
 #不验证登录URL
 FilterExcludeURL = ""
 #只验证登录URL
 FilterOnlyLoginCheckURL = "/api/role-api"
+# 不进入公司的url
+FilterNotEnterDeptURL = "/api/medicine-template/init"
 
 # 统一身份认证
-OAuth_baseUrl = "http://192.168.11.77:8100"
-# OAuth_baseUrl = "http://127.0.0.1:8000"
+# OAuth_baseUrl = "http://192.168.11.77:8100"
+OAuth_baseUrl = "http://127.0.0.1:8000"
 # 服务发现服务信息
 Service_number = "q9YeglML"
 Service_authCode = "3EDJRaagFTVVo2Ilo80nHJfLVN1O1234"

+ 1 - 1
controllers/dosage_form.go

@@ -142,8 +142,8 @@ func (c DosageFormController) Delete() {
 		return
 	}
 
-	// TODO 判断出入库数据
 	reqData.SetUpdateBy(beegouser.GetUserId(c.Ctx))
+	reqData.SetDeptId(beegouser.GetDeptId(c.Ctx))
 	err := s.Remove(&reqData)
 	if err != nil {
 		c.Error(500, err, err.Error())

+ 2 - 3
controllers/enterprise.go

@@ -40,8 +40,7 @@ func (c EnterpriseController) List() {
 		return
 	}
 
-	//c.PageOK(list, int(count), reqData.GetPageIndex(), reqData.GetPageSize(), "查询成功")
-	c.PageOK(list, beegouser.GetDeptId(c.Ctx), reqData.GetPageIndex(), reqData.GetPageSize(), "查询成功")
+	c.PageOK(list, int(count), reqData.GetPageIndex(), reqData.GetPageSize(), "查询成功")
 }
 
 // Detail 通过id获取生产企业
@@ -142,9 +141,9 @@ func (c EnterpriseController) Delete() {
 		c.Error(global.ParseFormErr, err, err.Error())
 		return
 	}
-	// TODO 判断出入库数据
 
 	reqData.SetUpdateBy(beegouser.GetUserId(c.Ctx))
+	reqData.SetDeptId(beegouser.GetDeptId(c.Ctx))
 	err := s.Remove(&reqData)
 	if err != nil {
 		c.Error(500, err, err.Error())

+ 1 - 2
controllers/medicine.go

@@ -16,7 +16,7 @@ type MedicineController struct {
 // @Summary 批号列表
 // @Description 批号列表
 // @Tags 药品
-// @Param data body dto.MedicineDeleteReq true "body"
+// @Param data body dto.MedicineBatchNumberReq true "body"
 // @Success 200 {object} response.Page "{"code": 200, "data": [...]}"
 // @Router /medicine/batch-number [post]
 // @Security Bearer
@@ -42,7 +42,6 @@ func (c MedicineController) BatchNumber() {
 // @Summary 基本数据统计
 // @Description 基本数据统计
 // @Tags 药品
-// @Param data body dto.MedicineDeleteReq true "body"
 // @Success 200 {object} response.Page "{"code": 200, "data": [...]}"
 // @Router /medicine/basic-data-stat [post]
 // @Security Bearer

+ 2 - 1
controllers/product.go

@@ -141,9 +141,10 @@ func (c ProductController) Delete() {
 		c.Error(global.ParseFormErr, err, err.Error())
 		return
 	}
-	// TODO 判断出入库数据
 
 	reqData.SetUpdateBy(beegouser.GetUserId(c.Ctx))
+	reqData.SetDeptId(beegouser.GetDeptId(c.Ctx))
+
 	err := s.Remove(&reqData)
 	if err != nil {
 		c.Error(500, err, err.Error())

+ 19 - 15
controllers/sales.go

@@ -2,6 +2,7 @@ package controllers
 
 import (
 	"Medical_ERP/common/global"
+	_ "Medical_ERP/common/response"
 	"Medical_ERP/dto"
 	"Medical_ERP/models"
 	"Medical_ERP/services"
@@ -305,14 +306,6 @@ func (c SalesController) SalesOrderList() {
 	c.PageOK(list, int(count), reqData.GetPageIndex(), reqData.GetPageSize(), "查询成功")
 }
 
-// SalesStockOutExcel 出库单
-// @Summary 出库单
-// @Description 出库单
-// @Tags 销售管理
-// @Param body body dto.SalesStockOutExcelReq true "body"
-// @Success 200 {object} response.Page "{"code": 200, "data": [...]}"
-// @Router /sales/order_list [post]
-// @Security Bearer
 func (c SalesController) SalesStockOutExcel(reqData dto.SalesStockOutExcelReq) {
 	s := services.Sales{}
 	deptId := beegouser.GetDeptId(c.Ctx)
@@ -348,7 +341,7 @@ func (c SalesController) SalesStockOutExcel(reqData dto.SalesStockOutExcelReq) {
 	f.SetCellValue("Sheet1", "B3", "剂型")
 	f.SetCellValue("Sheet1", "C3", "规格")
 	f.SetCellValue("Sheet1", "D3", "生产企业")
-	f.SetCellValue("Sheet1", "E3", "疫苗批号")
+	f.SetCellValue("Sheet1", "E3", "批号")
 	f.SetCellValue("Sheet1", "F3", "效期")
 	f.SetCellValue("Sheet1", "G3", "批准文号")
 	f.SetCellValue("Sheet1", "H3", "数量")
@@ -369,7 +362,7 @@ func (c SalesController) SalesStockOutExcel(reqData dto.SalesStockOutExcelReq) {
 	// 循环写入数据
 	for _, v := range list {
 		line++
-		f.SetRowHeight("Sheet1", line, 25)
+		//f.SetRowHeight("Sheet1", line, 25)
 		f.SetCellValue("Sheet1", fmt.Sprintf("A%d", line), v[models.FieldProductName])
 		f.SetCellValue("Sheet1", fmt.Sprintf("B%d", line), v[models.FieldDosageFormName])
 		f.SetCellValue("Sheet1", fmt.Sprintf("C%d", line), v[models.FieldSpecName])
@@ -457,9 +450,9 @@ func (c SalesController) SalesStockOutPdf(reqData dto.SalesStockOutExcelReq) {
 		c.Error(500, err, err.Error())
 		return
 	}
-	cols := []float64{22, 10, 22, 18, 20, 20, 20, 10, 10, 18, 18}
+	cols := []float64{22, 12, 22, 18, 20, 20, 20, 10, 10, 18, 18}
 
-	header := []string{"品种", "剂型", "规格", "生产企业", "疫苗批号", "效期", "批准文号", "数量", "单位", "销售单价", "销售金额"}
+	header := []string{"品种", "剂型", "规格", "生产企业", "批号", "效期", "批准文号", "数量", "单位", "销售单价", "销售金额"}
 	rows := [][]string{}
 	money := 0.0
 	for _, row := range list {
@@ -525,7 +518,7 @@ func (c SalesController) SalesStockOutPdf(reqData dto.SalesStockOutExcelReq) {
 
 		for i, txt := range row {
 			lines := pdf.SplitLines([]byte(txt), cols[i])
-			h := float64(len(lines))*lineHt + marginCell*float64(len(lines))
+			h = float64(len(lines))*lineHt + marginCell*float64(len(lines))
 			if h > height {
 				height = h
 			}
@@ -538,7 +531,8 @@ func (c SalesController) SalesStockOutPdf(reqData dto.SalesStockOutExcelReq) {
 		for i, txt := range row {
 			width := cols[i]
 			pdf.Rect(x, y, width, height, "")
-			pdf.MultiCell(width, lineHt+marginCell, txt, "", "CM", false)
+
+			pdf.MultiCell(width, lineHt+marginCell, txt, "", "C", false)
 			x += width
 			pdf.SetXY(x, y)
 		}
@@ -546,6 +540,7 @@ func (c SalesController) SalesStockOutPdf(reqData dto.SalesStockOutExcelReq) {
 	}
 
 	curx, y = pdf.GetXY()
+	h = 10.0
 	width := cols[0] + cols[1] + cols[2] + cols[3]
 	pdf.CellFormat(width, h, fmt.Sprintf("整单合计金额(小写):¥%.2f元", money), "1", 0, "CM", false, 0, "")
 	width = cols[4] + cols[5] + cols[6] + cols[7] + cols[8] + cols[9] + cols[10]
@@ -567,7 +562,7 @@ func (c SalesController) SalesStockOutPdf(reqData dto.SalesStockOutExcelReq) {
 
 	filename := "二类出库单" + time.Now().Format("20060102150405") + ".pdf"
 	// 保存文件
-	if err := pdf.OutputFileAndClose("ofile/" + filename); err != nil {
+	if err = pdf.OutputFileAndClose("ofile/" + filename); err != nil {
 		fmt.Println(err)
 	}
 	defer func() {
@@ -578,6 +573,15 @@ func (c SalesController) SalesStockOutPdf(reqData dto.SalesStockOutExcelReq) {
 	c.Ctx.Output.Download("ofile/" + filename)
 
 }
+
+// SalesStockOutExport 二类出库单
+// @Summary 二类出库单
+// @Description 二类出库单
+// @Tags 销售管理
+// @Param body body dto.SalesStockOutExcelReq true "body"
+// @Success 200 {object} response.Page "{"code": 200, "data": [...]}"
+// @Router /sales/order_list [post]
+// @Security Bearer
 func (c SalesController) SalesStockOutExport() {
 	reqData := dto.SalesStockOutExcelReq{}
 	if err := c.ParseAndValidate(&c.Ctx.Input.RequestBody, &reqData); err != nil {

+ 1 - 1
controllers/spec.go

@@ -143,8 +143,8 @@ func (c SpecController) Delete() {
 		return
 	}
 
-	// TODO 判断出入库数据
 	reqData.SetUpdateBy(beegouser.GetUserId(c.Ctx))
+	reqData.SetDeptId(beegouser.GetDeptId(c.Ctx))
 	err := s.Remove(&reqData)
 	if err != nil {
 		c.Error(500, err, err.Error())

+ 16 - 15
controllers/stock_template.go

@@ -288,7 +288,7 @@ func (c StockTemplateController) StockTemplateOutList() {
 // @Tags 库存
 // @Param body body dto.StockTemplateInventoryPageReq true "body"
 // @Success 200 {object} response.Page "{"code": 200, "data": [...]}"
-// @Router /stock-template/inventory/list [post]
+// @Router /stock/inventory/list [post]
 // @Security Bearer
 func (c StockTemplateController) StockTemplateInventoryList() {
 	s := services.StockTemplate{}
@@ -726,14 +726,6 @@ func (c StockTemplateController) StockTemplateInventoryExport() {
 	}
 }
 
-// TransportRecordWord 运输记录表word
-// @Summary 收发登记表word
-// @Description 收发登记表word
-// @Tags 库存
-// @Param body body dto.TransportRecordWordReq true "body"
-// @Success 200 {object} response.Page "{"code": 200, "data": [...]}"
-// @Router /stock-template/inventory/list [post]
-// @Security Bearer
 func (c StockTemplateController) TransportRecordWord(reqData dto.TransportRecordWordReq) {
 	s := services.StockTemplate{}
 	deptId := beegouser.GetDeptId(c.Ctx)
@@ -929,7 +921,7 @@ func (c StockTemplateController) TransportRecordWord(reqData dto.TransportRecord
 	run = para.AddRun()
 	run.Properties().SetFontFamily("宋体")
 	run.Properties().SetSize(9)
-	run.AddText("疫苗批号")
+	run.AddText("批号")
 
 	cell = row.AddCell()
 	cell.Properties().SetWidthPercent(10)
@@ -939,7 +931,7 @@ func (c StockTemplateController) TransportRecordWord(reqData dto.TransportRecord
 	run = para.AddRun()
 	run.Properties().SetFontFamily("宋体")
 	run.Properties().SetSize(9)
-	run.AddText("疫苗效期")
+	run.AddText("效期")
 
 	cell = row.AddCell()
 	cell.Properties().SetWidthPercent(6)
@@ -1172,7 +1164,7 @@ func (c StockTemplateController) TransportRecordWord(reqData dto.TransportRecord
 	run = para.AddRun()
 	run.Properties().SetFontFamily("宋体")
 	run.Properties().SetSize(8)
-	run.AddText("疫苗储存温度")
+	run.AddText("储存温度")
 
 	cell = row.AddCell()
 	cell.Properties().SetWidthPercent(17)
@@ -1925,6 +1917,15 @@ func (c StockTemplateController) TransportRecordPdf(reqData dto.TransportRecordW
 	c.Ctx.Output.Download("ofile/" + filename)
 
 }
+
+// TransportRecordExport 运输记录表
+// @Summary 收发登记表word
+// @Description 收发登记表word
+// @Tags 库存
+// @Param body body dto.TransportRecordWordReq true "body"
+// @Success 200 {object} response.Page "{"code": 200, "data": [...]}"
+// @Router /stock-template/inventory/list [post]
+// @Security Bearer
 func (c StockTemplateController) TransportRecordExport() {
 	reqData := dto.TransportRecordWordReq{}
 	if err := c.ParseAndValidate(&c.Ctx.Input.RequestBody, &reqData); err != nil {
@@ -1995,13 +1996,13 @@ func (c StockTemplateController) StockOperatorList() {
 	c.PageOK(list, 0, 0, 0, "查询成功")
 }
 
-// StockStatList 库存查询
+// StockInquiryList 库存查询
 // @Summary 库存查询-每个商品、生产企业、规格、批号数量
 // @Description 库存查询
 // @Tags 库存
 // @Param body body dto.StockStatListReq true "body"
 // @Success 200 {object} response.Page "{"code": 200, "data": [...]}"
-// @Router /stock/stat [post]
+// @Router /stock/inquiry/list [post]
 // @Security Bearer
 func (c StockTemplateController) StockInquiryList() {
 	s := services.StockTemplate{}
@@ -2051,7 +2052,7 @@ func (c StockTemplateController) StockInquiryExcel() {
 	f.MergeCell("Sheet1", "A1", "L1")
 	f.SetRowStyle("Sheet1", 1, 1, StyleTitle)
 	f.SetRowHeight("Sheet1", 1, 50)
-	f.SetCellValue("Sheet1", "A1", fmt.Sprintf("疫苗库存信息表(%s)", time.Now().Format("2006-01-02 15:04:05")))
+	f.SetCellValue("Sheet1", "A1", fmt.Sprintf("库存信息表(%s)", time.Now().Format("2006-01-02 15:04:05")))
 	// 这里设置表头
 	f.SetCellValue("Sheet1", "A2", "品名")
 	f.SetCellValue("Sheet1", "B2", "生产企业")

Fichier diff supprimé car celui-ci est trop grand
+ 713 - 77
docs/docs.go


Fichier diff supprimé car celui-ci est trop grand
+ 715 - 79
docs/swagger.json


+ 505 - 26
docs/swagger.yaml

@@ -1,5 +1,32 @@
 basePath: /api
 definitions:
+  dto.BatchStockTemplateInInsertReq:
+    properties:
+      stockInList:
+        items:
+          properties:
+            date:
+              description: 入库日期
+              type: string
+            forwardingUnit:
+              description: 发货单位
+              type: string
+            medicineInfo:
+              additionalProperties: true
+              description: 药品信息
+              type: object
+            operator:
+              description: 经办人
+              type: string
+            quantity:
+              description: 数量
+              type: integer
+            unitPrice:
+              description: 购入单价
+              type: number
+          type: object
+        type: array
+    type: object
   dto.DosageFormDeleteReq:
     properties:
       id:
@@ -84,6 +111,18 @@ definitions:
         example: 生产企业
         type: string
     type: object
+  dto.MedicineBatchNumberReq:
+    properties:
+      batchNumber:
+        description: 批号
+        type: string
+      enterpriseId:
+        description: 生产企业id
+        type: integer
+      productId:
+        description: 药品名称id
+        type: integer
+    type: object
   dto.MedicineTemplateDeleteReq:
     properties:
       id:
@@ -190,6 +229,84 @@ definitions:
         example: test
         type: string
     type: object
+  dto.SalesOrderPageReq:
+    properties:
+      batchNumber:
+        description: 批号
+        type: string
+      date:
+        description: 下单日期
+        type: string
+      enterpriseId:
+        description: 生产企业id
+        type: integer
+      page:
+        description: 页数
+        example: 1
+        type: integer
+      pageSize:
+        description: 每页条数
+        example: 10
+        type: integer
+      productId:
+        description: 药品名称id
+        type: integer
+      receivingUnit:
+        description: 收货单位
+        type: string
+    type: object
+  dto.SalesPageReq:
+    properties:
+      batchNumber:
+        description: 批号
+        type: string
+      endDate:
+        description: 出库结束时间
+        type: string
+      enterpriseId:
+        description: 生产企业id
+        type: integer
+      page:
+        description: 页数
+        example: 1
+        type: integer
+      pageSize:
+        description: 每页条数
+        example: 10
+        type: integer
+      productId:
+        description: 药品名称id
+        type: integer
+      receivingUnit:
+        description: 收货单位
+        type: string
+      startDate:
+        description: 出库开始时间
+        type: string
+    type: object
+  dto.SalesStockOutExcelReq:
+    properties:
+      consignee:
+        description: 收货人
+        type: string
+      consigner:
+        description: 发货人
+        type: string
+      date:
+        description: 下单日期
+        type: string
+      drawer:
+        description: 开票员
+        type: string
+      finance:
+        description: 财务
+        type: string
+      receivingUnit:
+        description: 收货单位
+        type: string
+      type:
+        type: string
+    type: object
   dto.SpecDeleteReq:
     properties:
       id:
@@ -232,6 +349,68 @@ definitions:
         example: 规格
         type: string
     type: object
+  dto.StockOperatorListReq:
+    properties:
+      name:
+        type: string
+    type: object
+  dto.StockStatListReq:
+    properties:
+      batchNumber:
+        description: 批号
+        type: string
+      endDate:
+        description: 效期结束时间
+        type: string
+      enterpriseId:
+        description: 生产企业id
+        type: integer
+      page:
+        description: 页数
+        example: 1
+        type: integer
+      pageSize:
+        description: 每页条数
+        example: 10
+        type: integer
+      productId:
+        description: 药品名称id
+        type: integer
+      startDate:
+        description: 效期开始时间
+        type: string
+    type: object
+  dto.StockTemplateInDeleteReq:
+    properties:
+      id:
+        description: 入库id
+        type: integer
+    type: object
+  dto.StockTemplateInEditReq:
+    properties:
+      date:
+        description: 入库日期
+        type: string
+      forwarding_unit:
+        description: 发货单位
+        type: string
+      id:
+        description: 入库id
+        type: integer
+      medicineInfo:
+        additionalProperties: true
+        description: 药品信息
+        type: object
+      operator:
+        description: 经办人
+        type: string
+      quantity:
+        description: 数量
+        type: integer
+      unit_Price:
+        description: 购入单价
+        type: number
+    type: object
   dto.StockTemplateInInsertReq:
     properties:
       date:
@@ -252,22 +431,75 @@ definitions:
         type: integer
       unitPrice:
         description: 购入单价
-        type: integer
+        type: number
     type: object
   dto.StockTemplateInPageReq:
     properties:
       batchNumber:
-        description: 疫苗批号
+        description: 批号
+        type: string
+      endDate:
+        description: 入库结束时间
         type: string
       enterpriseId:
         description: 生产企业id
         type: integer
-      expiryEndDate:
-        description: 疫苗效期结束时间
+      forwardingUnit:
+        description: 发货单位
         type: string
-      expiryStartDate:
-        description: 疫苗效期开始时间
+      page:
+        description: 页数
+        example: 1
+        type: integer
+      pageSize:
+        description: 每页条数
+        example: 10
+        type: integer
+      productId:
+        description: 药品名称id
+        type: integer
+      startDate:
+        description: 入库开始时间
         type: string
+    type: object
+  dto.StockTemplateInventoryExcelReq:
+    properties:
+      batchNumber:
+        description: 批号
+        type: string
+      endDate:
+        description: 出/入库结束时间
+        type: string
+      enterpriseId:
+        description: 生产企业id
+        type: integer
+      productId:
+        description: 药品名称id
+        type: integer
+      specId:
+        description: 规格id
+        type: integer
+      startDate:
+        description: 出/入库开始时间
+        type: string
+      type:
+        description: 类型 excel pdf
+        type: string
+    type: object
+  dto.StockTemplateInventoryPageReq:
+    properties:
+      SendReceiveUnit:
+        description: 收发单位
+        type: string
+      batchNumber:
+        description: 批号
+        type: string
+      endDate:
+        description: 出/入库结束时间
+        type: string
+      enterpriseId:
+        description: 生产企业id
+        type: integer
       page:
         description: 页数
         example: 1
@@ -279,11 +511,43 @@ definitions:
       productId:
         description: 药品名称id
         type: integer
+      startDate:
+        description: 出/入库开始时间
+        type: string
+    type: object
+  dto.StockTemplateOutDeleteReq:
+    properties:
+      id:
+        type: integer
+    type: object
+  dto.StockTemplateOutEditReq:
+    properties:
+      date:
+        description: 出库日期
+        type: string
+      id:
+        type: integer
+      medicineInfo:
+        additionalProperties: true
+        description: 药品信息
+        type: object
+      operator:
+        description: 经办人
+        type: string
+      quantity:
+        description: 数量
+        type: integer
+      receiving_unit:
+        description: 收货单位
+        type: string
+      unit_price:
+        description: 购入单价
+        type: number
     type: object
   dto.StockTemplateOutInsertReq:
     properties:
       date:
-        description: 入库日期
+        description: 库日期
         type: string
       medicineInfo:
         additionalProperties: true
@@ -300,22 +564,19 @@ definitions:
         type: string
       unitPrice:
         description: 购入单价
-        type: integer
+        type: number
     type: object
   dto.StockTemplateOutPageReq:
     properties:
       batchNumber:
-        description: 疫苗批号
+        description: 批号
+        type: string
+      endDate:
+        description: 出库结束时间
         type: string
       enterpriseId:
         description: 生产企业id
         type: integer
-      expiryEndDate:
-        description: 疫苗效期结束时间
-        type: string
-      expiryStartDate:
-        description: 疫苗效期开始时间
-        type: string
       page:
         description: 页数
         example: 1
@@ -327,6 +588,35 @@ definitions:
       productId:
         description: 药品名称id
         type: integer
+      receivingUnit:
+        description: 收货单位
+        type: string
+      startDate:
+        description: 出库开始时间
+        type: string
+    type: object
+  dto.StockUnitListReq:
+    properties:
+      name:
+        type: string
+      type:
+        description: 1-入库 2-出库 3-库存
+        type: integer
+    type: object
+  dto.TransportRecordWordReq:
+    properties:
+      date:
+        description: 出库时间
+        type: string
+      productId:
+        description: 药品名称id
+        type: integer
+      receivingUnit:
+        description: 收货单位
+        type: string
+      type:
+        description: 类型
+        type: string
     type: object
   dto.UnitDeleteReq:
     properties:
@@ -595,8 +885,8 @@ definitions:
 host: 192.168.11.77:8110
 info:
   contact: {}
-  description: 疫苗进销存管理系统
-  title: 疫苗进销存管理系统
+  description: 药品进销存管理系统
+  title: 药品进销存管理系统
   version: "1.0"
 paths:
   /api/role-api:
@@ -859,8 +1149,6 @@ paths:
       - 生产企业
   /medicine-template/add:
     post:
-      consumes:
-      - application/json
       description: 添加模版字段
       parameters:
       - description: data
@@ -923,8 +1211,6 @@ paths:
       - 药品信息模板
   /medicine-template/edit:
     post:
-      consumes:
-      - application/json
       description: 修改模版字段
       parameters:
       - description: body
@@ -963,6 +1249,59 @@ paths:
       summary: 获取品名列表
       tags:
       - 药品信息模板
+  /medicine-template/list-for-stock:
+    post:
+      description: 获取入库列表
+      responses:
+        "200":
+          description: '{"code": 200, "data": [...]}'
+          schema:
+            allOf:
+            - $ref: '#/definitions/response.Page'
+            - properties:
+                list:
+                  items:
+                    $ref: '#/definitions/models.MedicineTemplate'
+                  type: array
+              type: object
+      security:
+      - Bearer: []
+      summary: 获取入库列表
+      tags:
+      - 药品信息模板
+  /medicine/basic-data-stat:
+    post:
+      description: 基本数据统计
+      responses:
+        "200":
+          description: '{"code": 200, "data": [...]}'
+          schema:
+            $ref: '#/definitions/response.Page'
+      security:
+      - Bearer: []
+      summary: 基本数据统计
+      tags:
+      - 药品
+  /medicine/batch-number:
+    post:
+      description: 批号列表
+      parameters:
+      - description: body
+        in: body
+        name: data
+        required: true
+        schema:
+          $ref: '#/definitions/dto.MedicineBatchNumberReq'
+      responses:
+        "200":
+          description: '{"code": 200, "data": [...]}'
+          schema:
+            $ref: '#/definitions/response.Page'
+      security:
+      - Bearer: []
+      summary: 批号列表
+      tags:
+      - 药品
   /product/add:
     post:
       consumes:
@@ -1081,6 +1420,66 @@ paths:
       summary: 获取品名列表
       tags:
       - 品名
+  /sales/excel:
+    post:
+      description: 销售报表
+      parameters:
+      - description: body
+        in: body
+        name: body
+        required: true
+        schema:
+          $ref: '#/definitions/dto.SalesPageReq'
+      responses:
+        "200":
+          description: '{"code": 200, "data": [...]}'
+          schema:
+            $ref: '#/definitions/response.Page'
+      security:
+      - Bearer: []
+      summary: 销售报表
+      tags:
+      - 销售管理
+  /sales/list:
+    post:
+      description: 销售管理
+      parameters:
+      - description: body
+        in: body
+        name: body
+        required: true
+        schema:
+          $ref: '#/definitions/dto.SalesPageReq'
+      responses:
+        "200":
+          description: '{"code": 200, "data": [...]}'
+          schema:
+            $ref: '#/definitions/response.Page'
+      security:
+      - Bearer: []
+      summary: 销售管理
+      tags:
+      - 销售管理
+  /sales/order_list:
+    post:
+      description: 出库单
+      parameters:
+      - description: body
+        in: body
+        name: body
+        required: true
+        schema:
+          $ref: '#/definitions/dto.SalesStockOutExcelReq'
+      responses:
+        "200":
+          description: '{"code": 200, "data": [...]}'
+          schema:
+            $ref: '#/definitions/response.Page'
+      security:
+      - Bearer: []
+      summary: 出库单
+      tags:
+      - 销售管理
   /spec/add:
     post:
       consumes:
@@ -1201,14 +1600,14 @@ paths:
       - 规格
   /stock-template/in:
     post:
-      description: 入库
+      description: 删除入库
       parameters:
       - description: body
         in: body
         name: body
         required: true
         schema:
-          $ref: '#/definitions/dto.StockTemplateInInsertReq'
+          $ref: '#/definitions/dto.StockTemplateOutDeleteReq'
       responses:
         "200":
           description: '{"code": 200, "data": [...]}'
@@ -1216,7 +1615,7 @@ paths:
             $ref: '#/definitions/response.Response'
       security:
       - Bearer: []
-      summary: 入库
+      summary: 删除入库
       tags:
       - 库存
   /stock-template/in/list:
@@ -1239,9 +1638,29 @@ paths:
       summary: 入库列表
       tags:
       - 库存
+  /stock-template/inventory/list:
+    post:
+      description: 收发登记表word
+      parameters:
+      - description: body
+        in: body
+        name: body
+        required: true
+        schema:
+          $ref: '#/definitions/dto.TransportRecordWordReq'
+      responses:
+        "200":
+          description: '{"code": 200, "data": [...]}'
+          schema:
+            $ref: '#/definitions/response.Page'
+      security:
+      - Bearer: []
+      summary: 收发登记表word
+      tags:
+      - 库存
   /stock-template/out:
     post:
-      description: 出库
+      description: 批量出库
       parameters:
       - description: body
         in: body
@@ -1256,7 +1675,7 @@ paths:
             $ref: '#/definitions/response.Response'
       security:
       - Bearer: []
-      summary: 出库
+      summary: 批量出库
       tags:
       - 库存
   /stock-template/out/list:
@@ -1279,6 +1698,66 @@ paths:
       summary: 出库列表
       tags:
       - 库存
+  /stock/stat:
+    post:
+      description: 首页出入库信息统计
+      parameters:
+      - description: body
+        in: body
+        name: body
+        required: true
+        schema:
+          $ref: '#/definitions/dto.StockStatListReq'
+      responses:
+        "200":
+          description: '{"code": 200, "data": [...]}'
+          schema:
+            $ref: '#/definitions/response.Page'
+      security:
+      - Bearer: []
+      summary: 首页出入库信息统计
+      tags:
+      - 库存
+  /stock/stat/excel:
+    post:
+      description: 库存信息表
+      parameters:
+      - description: body
+        in: body
+        name: body
+        required: true
+        schema:
+          $ref: '#/definitions/dto.StockStatListReq'
+      responses:
+        "200":
+          description: '{"code": 200, "data": [...]}'
+          schema:
+            $ref: '#/definitions/response.Page'
+      security:
+      - Bearer: []
+      summary: 库存信息表-每个商品、生产企业、规格、批号数量
+      tags:
+      - 库存
+  /stock/unit/list:
+    post:
+      description: 获取收货单位,发货单位,收发单位
+      parameters:
+      - description: body
+        in: body
+        name: body
+        required: true
+        schema:
+          $ref: '#/definitions/dto.StockOperatorListReq'
+      responses:
+        "200":
+          description: '{"code": 200, "data": [...]}'
+          schema:
+            $ref: '#/definitions/response.Page'
+      security:
+      - Bearer: []
+      summary: 获取收货单位,发货单位,收发单位
+      tags:
+      - 库存
   /unit/add:
     post:
       consumes:

+ 2 - 2
dto/sales.go

@@ -9,7 +9,7 @@ type SalesPageReq struct {
 	EnterpriseID   int    `json:"enterpriseId"`  // 生产企业id
 	StartDate      string `json:"startDate"`     // 出库开始时间
 	EndDate        string `json:"endDate"`       // 出库结束时间
-	BatchNumber    string `json:"batchNumber"`   // 疫苗批号
+	BatchNumber    string `json:"batchNumber"`   // 批号
 	ReceivingUnit  string `json:"receivingUnit"` // 收货单位
 }
 
@@ -19,7 +19,7 @@ type SalesOrderPageReq struct {
 	ProductID      int    `json:"productId"`     // 药品名称id
 	EnterpriseID   int    `json:"enterpriseId"`  // 生产企业id
 	Date           string `json:"date"`          // 下单日期
-	BatchNumber    string `json:"batchNumber"`   // 疫苗批号
+	BatchNumber    string `json:"batchNumber"`   // 批号
 	ReceivingUnit  string `json:"receivingUnit"` // 收货单位
 }
 

+ 6 - 6
dto/stock.go

@@ -27,8 +27,8 @@ type StockInInsertReq struct {
 	ApprovalNumber      string `json:"approvalNumber"`      // 批准文号
 	QualificationNumber string `json:"qualificationNumber"` // 批签发合格编号
 	ProductionDate      string `json:"productionDate"`      // 生产日期
-	ExpiryDate          string `json:"expiryDate"`          // 疫苗效期
-	BatchNumber         string `json:"batchNumber"`         // 疫苗批号
+	ExpiryDate          string `json:"expiryDate"`          // 效期
+	BatchNumber         string `json:"batchNumber"`         // 批号
 
 	Quantity       int     `json:"quantity"`       // 数量
 	UnitPrice      float32 `json:"unitPrice"`      // 购入单价
@@ -56,8 +56,8 @@ type StockOutInsertReq struct {
 	ApprovalNumber      string `json:"approvalNumber"`      // 批准文号
 	QualificationNumber string `json:"qualificationNumber"` // 批签发合格编号
 	ProductionDate      string `json:"productionDate"`      // 生产日期
-	ExpiryDate          string `json:"expiryDate"`          // 疫苗效期
-	BatchNumber         string `json:"batchNumber"`         // 疫苗批号
+	ExpiryDate          string `json:"expiryDate"`          // 效期
+	BatchNumber         string `json:"batchNumber"`         // 批号
 
 	Quantity      int     `json:"quantity"`      // 数量
 	UnitPrice     float32 `json:"unitPrice"`     // 购入单价
@@ -78,8 +78,8 @@ type StockInPageReq struct {
 	dto.Pagination `search:"-"`
 	ProductID      int    `json:"productId"`    // 药品名称id
 	EnterpriseID   int    `json:"enterpriseId"` // 生产企业id
-	ExpiryDate     string `json:"expiryDate"`   // 疫苗效期
-	BatchNumber    string `json:"batchNumber"`  // 疫苗批号
+	ExpiryDate     string `json:"expiryDate"`   // 效期
+	BatchNumber    string `json:"batchNumber"`  // 批号
 }
 
 func (m *StockInPageReq) GetNeedSearch() interface{} {

+ 5 - 5
dto/stock_template.go

@@ -79,7 +79,7 @@ type BatchStockTemplateOutInsertReq struct {
 		Operator      string                 `json:"operator"`      // 经办人
 		ReceivingUnit string                 `json:"receivingUnit"` // 收货单位
 		Date          string                 `json:"date"`          // 出库日期
-	} `json:"StockOutList"`
+	} `json:"stockOutList"`
 	common.ControlBy `swaggerignore:"true"`
 }
 
@@ -141,7 +141,7 @@ type StockTemplateInPageReq struct {
 	EnterpriseID   int    `json:"enterpriseId"`   // 生产企业id
 	StartDate      string `json:"startDate"`      // 入库开始时间
 	EndDate        string `json:"endDate"`        // 入库结束时间
-	BatchNumber    string `json:"batchNumber"`    // 疫苗批号
+	BatchNumber    string `json:"batchNumber"`    // 批号
 	ForwardingUnit string `json:"forwardingUnit"` // 发货单位
 }
 
@@ -152,7 +152,7 @@ type StockTemplateOutPageReq struct {
 	EnterpriseID   int    `json:"enterpriseId"`  // 生产企业id
 	StartDate      string `json:"startDate"`     // 出库开始时间
 	EndDate        string `json:"endDate"`       // 出库结束时间
-	BatchNumber    string `json:"batchNumber"`   // 疫苗批号
+	BatchNumber    string `json:"batchNumber"`   // 批号
 	ReceivingUnit  string `json:"receivingUnit"` // 收货单位
 }
 
@@ -163,7 +163,7 @@ type StockTemplateInventoryPageReq struct {
 	EnterpriseID    int    `json:"enterpriseId"`    // 生产企业id
 	StartDate       string `json:"startDate"`       // 出/入库开始时间
 	EndDate         string `json:"endDate"`         // 出/入库结束时间
-	BatchNumber     string `json:"batchNumber"`     // 疫苗批号
+	BatchNumber     string `json:"batchNumber"`     // 批号
 	SendReceiveUnit string `json:"SendReceiveUnit"` // 收发单位
 }
 
@@ -198,7 +198,7 @@ type StockStatListReq struct {
 	EnterpriseID   int    `json:"enterpriseId"` // 生产企业id
 	StartDate      string `json:"startDate"`    // 效期开始时间
 	EndDate        string `json:"endDate"`      // 效期结束时间
-	BatchNumber    string `json:"batchNumber"`  // 疫苗批号
+	BatchNumber    string `json:"batchNumber"`  // 批号
 }
 
 // StockStatReq 列表或者搜索使用结构体

+ 3 - 2
go.mod

@@ -13,8 +13,7 @@ require (
 	github.com/go-sql-driver/mysql v1.7.0
 	github.com/gobwas/glob v0.2.3
 	github.com/google/uuid v1.3.0
-	github.com/jung-kurt/gofpdf v1.16.2
-	github.com/opentracing/opentracing-go v1.2.0
+	github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5
 	github.com/signintech/gopdf v0.20.0
 	github.com/smartystreets/goconvey v1.8.1
 	github.com/swaggo/swag v1.16.2
@@ -111,3 +110,5 @@ require (
 )
 
 replace gogs.baozhida.cn/zoie/OAuth-core => /Users/zoie/work/bzd_project/OAuth-core
+
+replace github.com/jung-kurt/gofpdf => /Users/zoie/work/bzd_project/github.com/jung-kurt/gofpdf

+ 0 - 5
go.sum

@@ -375,10 +375,6 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7
 github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
 github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
 github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
-github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
-github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
-github.com/jung-kurt/gofpdf v1.16.2 h1:jgbatWHfRlPYiK85qgevsZTHviWXKwB1TTiKdz5PtRc=
-github.com/jung-kurt/gofpdf v1.16.2/go.mod h1:1hl7y57EsiPAkLbOwzpzqgx1A30nQCk/YmFV8S2vmK0=
 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
 github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
@@ -480,7 +476,6 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
 github.com/onsi/gomega v1.13.0 h1:7lLHu94wT9Ij0o6EWWclhu0aOh32VxhkwEJvzuWPeak=
 github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY=
 github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
-github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
 github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
 github.com/openzipkin/zipkin-go v0.2.5/go.mod h1:KpXfKdgRDnnhsxw4pNIH9Md5lyFqKUa4YDFlwRYAMyE=
 github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=

+ 2 - 2
main.go

@@ -18,9 +18,9 @@ import (
 )
 
 //go:generate swag init --parseDependency --parseDepth=6
-// @title 疫苗进销存管理系统
+// @title 药品进销存管理系统
 // @version 1.0
-// @description 疫苗进销存管理系统
+// @description 药品进销存管理系统
 // @Host 192.168.11.77:8110
 // @BasePath /api
 // @Schemes http

+ 23 - 15
middleware/auth_middle.go

@@ -7,10 +7,10 @@ import (
 	"Medical_ERP/services"
 	"encoding/json"
 	"errors"
+	"github.com/beego/beego/v2/core/logs"
 	beego "github.com/beego/beego/v2/server/web"
 	"github.com/go-resty/resty/v2"
 	"github.com/gobwas/glob"
-	"github.com/opentracing/opentracing-go/log"
 	coreModel "gogs.baozhida.cn/zoie/OAuth-core/model"
 	jwt "gogs.baozhida.cn/zoie/OAuth-core/pkg/jwtauth"
 	"net/http"
@@ -28,23 +28,30 @@ func AuthMiddle() {
 	// 不 需要验证的url
 	FilterExcludeURL, _ := beego.AppConfig.String("FilterExcludeURL")
 	FilterOnlyLoginCheckURL, _ := beego.AppConfig.String("FilterOnlyLoginCheckURL")
+	FilterNotEnterDeptURL, _ := beego.AppConfig.String("FilterNotEnterDeptURL")
 	var filterLogin = func(ctx *context.Context) {
 		url := ctx.Input.URL()
 		method := ctx.Input.Method()
 		if !strings.Contains(FilterExcludeURL, url) && !strings.Contains(url, "/swagger") && !strings.Contains(url, "/static") {
 			// 验证登录
-			usr, err := ValidateToken(ctx)
+			usr, code, err := ValidateToken(ctx)
 			if err != nil {
-				ctx.Output.JSON(response.Error(global.Unauthorized, err, err.Error()),
+				ctx.Output.JSON(response.Error(code, err, err.Error()),
 					true, true)
 				return
 			}
+			if usr.DeptId == 0 && !strings.Contains(FilterNotEnterDeptURL, url) {
+				ctx.Output.JSON(response.Error(global.EnterDeptErr, EnterDeptErr, EnterDeptErr.Error()),
+					true, true)
+				return
+			}
+
 			// 过滤掉不需要验证权限的路由
 			if !strings.Contains(FilterOnlyLoginCheckURL, url) {
 				if usr.RoleKey != "admin" {
 					//校验权限
 					if !checkPermission(usr.RoleKey, url, method) {
-						ctx.Output.JSON(response.Error(global.Unauthorized, nil, "无权访问"), true, true)
+						ctx.Output.JSON(response.Error(global.NoAccessErr, nil, "无权访问"), true, true)
 						return
 					}
 				}
@@ -56,7 +63,9 @@ func AuthMiddle() {
 	adapter.InsertFilter("/api/*", adapter.BeforeRouter, filterLogin)
 }
 
-func ValidateToken(c *context.Context) (coreModel.UserInfo, error) {
+var EnterDeptErr = errors.New("请先进入公司")
+
+func ValidateToken(c *context.Context) (coreModel.UserInfo, int, error) {
 
 	reqPath := "/api/service/userinfo"
 	url := conf.OAuthBaseUrl + reqPath
@@ -68,8 +77,8 @@ func ValidateToken(c *context.Context) (coreModel.UserInfo, error) {
 		},
 	).Get(url)
 	if reqError != nil {
-		log.Error(reqError)
-		return coreModel.UserInfo{}, reqError
+		logs.Error(reqError)
+		return coreModel.UserInfo{}, global.BadRequest, reqError
 
 	}
 	type Res struct {
@@ -80,20 +89,18 @@ func ValidateToken(c *context.Context) (coreModel.UserInfo, error) {
 	var res Res // 替换为你期望的结构体类型
 	err := json.Unmarshal(r.Body(), &res)
 	if err != nil {
-		log.Error(err)
-		return coreModel.UserInfo{}, err
+		logs.Error(err)
+		return coreModel.UserInfo{}, global.BadRequest, err
 	}
 
 	if res.Code != http.StatusOK {
-		log.Error(errors.New(res.Msg.Msg))
-	}
-	if res.Data.DeptId == 0 {
-		return coreModel.UserInfo{}, errors.New("请先进入公司")
+		logs.Error(errors.New(res.Msg.Msg))
+		return coreModel.UserInfo{}, int(res.Code), errors.New(res.Msg.Msg)
 	}
 	c.Input.SetData(jwt.JwtPayloadKey, jwt.MapClaims{
 		"uuid":      res.Data.Uuid,
 		"identity":  float64(res.Data.UserId),
-		"userName":  res.Data.UserName,
+		"username":  res.Data.UserName,
 		"roleName":  res.Data.RoleName,
 		"deptName":  res.Data.DeptName,
 		"roleKey":   res.Data.RoleKey,
@@ -102,7 +109,8 @@ func ValidateToken(c *context.Context) (coreModel.UserInfo, error) {
 		"dataScope": float64(res.Data.DataScope),
 		"deptId":    float64(res.Data.DeptId),
 	})
-	return res.Data, nil
+
+	return res.Data, global.MsgOk, nil
 
 }
 

+ 3 - 4
middleware/log_middle.go

@@ -6,12 +6,14 @@ import (
 	"encoding/json"
 	"fmt"
 	"github.com/go-basic/uuid"
+	"gogs.baozhida.cn/zoie/OAuth-core/pkg/jwtauth/beegouser"
 	"strconv"
 	"strings"
 	"time"
 
 	adapter "github.com/beego/beego/v2/adapter"
 	"github.com/beego/beego/v2/adapter/context"
+	context2 "github.com/beego/beego/v2/server/web/context"
 )
 
 type OperationLogDetailed struct {
@@ -31,10 +33,7 @@ var filterLog = func(ctx *context.Context) {
 		var name, username string
 		//非登录接口从token中获取用户name
 		if len(ctx.Request.Header["Authorization"]) != 0 {
-			user, err := ValidateToken(ctx)
-			if err == nil {
-				username = user.UserName
-			}
+			username = beegouser.GetUserName((*context2.Context)(ctx))
 		}
 		//获取url类型
 		urlKey := strings.Replace(ctx.Input.URL(), "/", "_", -1)

+ 2 - 2
models/medicine_Info.go

@@ -12,8 +12,8 @@ type MedicineInfo struct {
 	ApprovalNumber      string `json:"approvalNumber" gorm:"size:128;"`      // 批准文号
 	QualificationNumber string `json:"qualificationNumber" gorm:"size:128;"` // 批签发合格编号
 	ProductionDate      string `json:"productionDate" gorm:"size:128;"`      // 生产日期
-	ExpiryDate          string `json:"expiryDate" gorm:"size:128;"`          // 疫苗效期
-	BatchNumber         string `json:"batchNumber" gorm:"size:128;"`         // 疫苗批号
+	ExpiryDate          string `json:"expiryDate" gorm:"size:128;"`          // 效期
+	BatchNumber         string `json:"batchNumber" gorm:"size:128;"`         // 批号
 	model2.ControlBy
 	model2.ModelTime
 }

+ 3 - 3
models/medicine_template.go

@@ -48,7 +48,7 @@ func (e *MedicineTemplate) TableName() string {
 
 func GetInitMedicineTemplateInfo(deptId, CreateBy int) []MedicineTemplate {
 	return []MedicineTemplate{
-		{Type: 1, Name: "品", FieldName: FieldProductID, Show: 1, State: 1, Sort: -9, ControlBy: model2.ControlBy{CreateBy: CreateBy, DeptId: deptId}},
+		{Type: 1, Name: "品", FieldName: FieldProductID, Show: 1, State: 1, Sort: -9, ControlBy: model2.ControlBy{CreateBy: CreateBy, DeptId: deptId}},
 		{Type: 2, Name: "生产企业", FieldName: FieldEnterpriseID, Show: 1, State: 1, Sort: -8, ControlBy: model2.ControlBy{CreateBy: CreateBy, DeptId: deptId}},
 		{Type: 3, Name: "规格", FieldName: FieldSpecID, Show: 1, State: 1, Sort: -7, ControlBy: model2.ControlBy{CreateBy: CreateBy, DeptId: deptId}},
 		{Type: 6, Name: "批号", FieldName: FieldBatchNumber, Show: 1, State: 1, Sort: -6, ControlBy: model2.ControlBy{CreateBy: CreateBy, DeptId: deptId}},
@@ -64,7 +64,7 @@ func GetInitMedicineTemplateSql(deptId int) string {
 	sqlStmt := `
     CREATE TABLE IF NOT EXISTS ` + GetMedicineInfoTableName(deptId) + ` (
         id int primary key auto_increment comment '自增ID',
-        product_id INT comment '品ID',
+        product_id INT comment '品ID',
         enterprise_id INT comment '生产企业ID',
         spec_id INT comment '规格ID',
 		unit_id INT comment '单位ID',
@@ -126,7 +126,7 @@ func GetDeleteMedicineTemplateSql(deptId int, columnName string) string {
 }
 
 //	type	说明			英文名称
-//	1		疫苗名称		ProductID
+//	1		产品名称		ProductID
 //	2		生产企业		EnterpriseID
 //	3		规格			SpecID
 //	4		剂型			DosageFormID

+ 1 - 1
services/sales.go

@@ -18,7 +18,7 @@ type Sales struct {
 func (e *Sales) SalesList(c *dto.SalesPageReq, deptId int) (list []map[string]interface{}, count int64, err error) {
 
 	mtable := models.GetMedicineInfoTableName(deptId)
-	whereSql := "stock_out.dept_id = " + strconv.Itoa(deptId) + " AND unit_price > 0 "
+	whereSql := "stock_out.dept_id = " + strconv.Itoa(deptId) + " AND unit_price > 0 AND stock_out.deleted_at is null"
 	if c.ProductID > 0 {
 		whereSql += " AND " + mtable + ".product_id = " + strconv.Itoa(c.ProductID)
 	}

+ 73 - 34
services/stock_template.go

@@ -284,18 +284,27 @@ func (e *StockTemplate) StockTemplateInEdit(c *dto.StockTemplateInEditReq) error
 	}
 
 	// 修改入库信息
-	stockInRecord := models.StockIn{
-		MedicineID:     medicineInfoId,
-		Quantity:       c.Quantity,
-		UnitPrice:      c.UnitPrice,
-		Operator:       c.Operator,
-		ForwardingUnit: c.ForwardingUnit,
-		Date:           c.Date,
-		ControlBy: model2.ControlBy{
-			UpdateBy: c.UpdateBy,
-		},
-	}
-	err = tx.Where("id = ?", c.Id).Updates(&stockInRecord).Error
+	//stockInRecord := models.StockIn{
+	//	MedicineID:     medicineInfoId,
+	//	Quantity:       c.Quantity,
+	//	UnitPrice:      c.UnitPrice,
+	//	Operator:       c.Operator,
+	//	ForwardingUnit: c.ForwardingUnit,
+	//	Date:           c.Date,
+	//	ControlBy: model2.ControlBy{
+	//		UpdateBy: c.UpdateBy,
+	//	},
+	//}
+	stockInRecordMap := map[string]interface{}{
+		"medicine_id":     medicineInfoId,
+		"quantity":        c.Quantity,
+		"unit_price":      c.UnitPrice,
+		"operator":        c.Operator,
+		"forwarding_unit": c.ForwardingUnit,
+		"date":            c.Date,
+		"update_by":       c.UpdateBy,
+	}
+	err = tx.Model(models.StockIn{}).Where("id = ?", c.Id).Updates(stockInRecordMap).Error
 	if err != nil {
 		tx.Rollback()
 		logs.Error("db error: %s", err)
@@ -606,18 +615,30 @@ func (e *StockTemplate) StockTemplateOutEdit(c *dto.StockTemplateOutEditReq) err
 	}
 
 	// 修改入库信息
-	stockOutRecord := models.StockOut{
-		MedicineID:    medicineInfoId,
-		Quantity:      c.Quantity,
-		UnitPrice:     c.UnitPrice,
-		Operator:      c.Operator,
-		ReceivingUnit: c.ReceivingUnit,
-		Date:          c.Date,
-		ControlBy: model2.ControlBy{
-			UpdateBy: c.UpdateBy,
-		},
+	//stockOutRecord := models.StockOut{
+	//	MedicineID:    medicineInfoId,
+	//	Quantity:      c.Quantity,
+	//	UnitPrice:     c.UnitPrice,
+	//	Operator:      c.Operator,
+	//	ReceivingUnit: c.ReceivingUnit,
+	//	Date:          c.Date,
+	//	ControlBy: model2.ControlBy{
+	//		UpdateBy: c.UpdateBy,
+	//	},
+	//}
+	//err = tx.Where("id = ?", c.Id).Updates(&stockOutRecord).Error
+
+	stockOutRecordMap := map[string]interface{}{
+		"medicine_id":    medicineInfoId,
+		"quantity":       c.Quantity,
+		"unit_price":     c.UnitPrice,
+		"operator":       c.Operator,
+		"receiving_unit": c.ReceivingUnit,
+		"date":           c.Date,
+		"update_by":      c.UpdateBy,
 	}
-	err = tx.Where("id = ?", c.Id).Updates(&stockOutRecord).Error
+	err = tx.Model(models.StockOut{}).Where("id = ?", c.Id).Updates(stockOutRecordMap).Error
+
 	if err != nil {
 		tx.Rollback()
 		logs.Error("db error: %s", err)
@@ -832,6 +853,7 @@ func (e *StockTemplate) BatchStockTemplateOut(req *dto.BatchStockTemplateOutInse
 			return global.CreateFailedErr
 		}
 		if mi.Balance < c.Quantity {
+			tx.Rollback()
 			return errors.New(fmt.Sprintf("库存量【%d】小于出库库存量【%d】,出库失败", mi.Balance, c.Quantity))
 		}
 
@@ -946,10 +968,18 @@ func (e *StockTemplate) StockTemplateInList(c *dto.StockTemplateInPageReq, deptI
 			list[i][models.FieldSpecName] = models.Read_Spec_Get(utils.ToInt(id))
 		}
 		if id, ok := list[i][models.FieldUnitID]; ok {
-			list[i][models.FieldUnitName] = models.Read_Unit_Get(utils.ToInt(id))
+			if utils.ToInt(id) == 0 {
+				list[i][models.FieldUnitID] = nil
+			} else {
+				list[i][models.FieldUnitName] = models.Read_Unit_Get(utils.ToInt(id))
+			}
 		}
 		if id, ok := list[i][models.FieldDosageFormID]; ok {
-			list[i][models.FieldDosageFormName] = models.Read_DosageForm_Get(utils.ToInt(id))
+			if utils.ToInt(id) == 0 {
+				list[i][models.FieldDosageFormID] = nil
+			} else {
+				list[i][models.FieldDosageFormName] = models.Read_DosageForm_Get(utils.ToInt(id))
+			}
 		}
 		if date, ok := list[i][models.FieldExpiryDate]; ok && date != nil {
 			list[i][models.FieldExpiryDate] = date.(time.Time).Format("2006-01-02")
@@ -1006,11 +1036,20 @@ func (e *StockTemplate) StockTemplateOutList(c *dto.StockTemplateOutPageReq, dep
 			list[i][models.FieldSpecName] = models.Read_Spec_Get(utils.ToInt(id))
 		}
 		if id, ok := list[i][models.FieldUnitID]; ok {
-			list[i][models.FieldUnitName] = models.Read_Unit_Get(utils.ToInt(id))
+			if utils.ToInt(id) == 0 {
+				list[i][models.FieldUnitID] = nil
+			} else {
+				list[i][models.FieldUnitName] = models.Read_Unit_Get(utils.ToInt(id))
+			}
 		}
 		if id, ok := list[i][models.FieldDosageFormID]; ok {
-			list[i][models.FieldDosageFormName] = models.Read_DosageForm_Get(utils.ToInt(id))
+			if utils.ToInt(id) == 0 {
+				list[i][models.FieldDosageFormID] = nil
+			} else {
+				list[i][models.FieldDosageFormName] = models.Read_DosageForm_Get(utils.ToInt(id))
+			}
 		}
+
 		if date, ok := list[i][models.FieldExpiryDate]; ok && date != nil {
 			list[i][models.FieldExpiryDate] = date.(time.Time).Format("2006-01-02")
 		}
@@ -1136,7 +1175,7 @@ func (e *StockTemplate) StockUnitList(c *dto.StockUnitListReq, deptId int) (list
 		if len(c.Name) > 0 {
 			whereSql += " AND forwarding_unit like '%" + c.Name + "%'"
 		}
-		whereSql += " AND forwarding_unit is not null"
+		whereSql += " AND forwarding_unit is not null AND forwarding_unit != ''"
 		err = db.DB.Table("stock_in").
 			Distinct("forwarding_unit").
 			Where(whereSql).
@@ -1150,7 +1189,7 @@ func (e *StockTemplate) StockUnitList(c *dto.StockUnitListReq, deptId int) (list
 		if len(c.Name) > 0 {
 			whereSql += " AND receiving_unit like '%" + c.Name + "%'"
 		}
-		whereSql += " AND receiving_unit is not null"
+		whereSql += " AND receiving_unit is not null AND receiving_unit != ''"
 
 		err = db.DB.Table("stock_out").
 			Distinct("receiving_unit").
@@ -1169,7 +1208,7 @@ func (e *StockTemplate) StockUnitList(c *dto.StockUnitListReq, deptId int) (list
 		forwarding_unit, receiving_unit := []string{}, []string{}
 		err = db.DB.Table("medicine_inventory").
 			Distinct("forwarding_unit").
-			Where(whereSql + " AND forwarding_unit is not null").
+			Where(whereSql + " AND forwarding_unit is not null AND forwarding_unit != ''").
 			Scan(&forwarding_unit).Error
 		if err != nil {
 			logs.Error("db error: %s ", err)
@@ -1177,7 +1216,7 @@ func (e *StockTemplate) StockUnitList(c *dto.StockUnitListReq, deptId int) (list
 		}
 		err = db.DB.Table("medicine_inventory").
 			Distinct("receiving_unit").
-			Where(whereSql + " AND receiving_unit is not null").
+			Where(whereSql + " AND receiving_unit is not null AND receiving_unit != ''").
 			Scan(&receiving_unit).Error
 		if err != nil {
 			logs.Error("db error: %s ", err)
@@ -1211,7 +1250,7 @@ func (e *StockTemplate) StockOperatorList(c *dto.StockOperatorListReq, deptId in
 func (e *StockTemplate) StockInquiryList(c *dto.StockStatListReq, deptId int) (list []map[string]interface{}, count int64, err error) {
 
 	mtable := models.GetMedicineInfoTableName(deptId)
-	whereSql := " WHERE mi.dept_id = " + strconv.Itoa(deptId) + " AND deleted_at is null"
+	whereSql := " WHERE mi.dept_id = " + strconv.Itoa(deptId)
 	if c.ProductID > 0 {
 		whereSql += " AND m_info.product_id = " + strconv.Itoa(c.ProductID)
 	}
@@ -1232,11 +1271,11 @@ func (e *StockTemplate) StockInquiryList(c *dto.StockStatListReq, deptId int) (l
 	//sql := "SELECT * FROM (SELECT a.* FROM (SELECT * FROM medicine_inventory ORDER BY id DESC LIMIT 100) a GROUP BY a.medicine_id) b " +
 	//	"LEFT JOIN " + mtable + " ON b.medicine_id=" + mtable + ".id WHERE " + whereSql
 
-	sql := "SELECT mi.*,m_info.* FROM (SELECT medicine_id,MAX(id) AS latest_id FROM medicine_inventory GROUP BY medicine_id) AS mi_latest " +
+	sql := "SELECT mi.*,m_info.* FROM (SELECT medicine_id,MAX(id) AS latest_id FROM medicine_inventory WHERE deleted_at is null GROUP BY medicine_id) AS mi_latest " +
 		"JOIN medicine_inventory AS mi ON mi.medicine_id=mi_latest.medicine_id AND mi.id=mi_latest.latest_id " +
 		"LEFT JOIN " + mtable + " AS m_info ON mi.medicine_id=m_info.id" + whereSql + " order by m_info.expiry_date limit ? offset ?;"
 
-	sqlWhereCount := "SELECT COUNT(1) FROM (SELECT medicine_id,MAX(id) AS latest_id FROM medicine_inventory GROUP BY medicine_id) AS mi_latest " +
+	sqlWhereCount := "SELECT COUNT(1) FROM (SELECT medicine_id,MAX(id) AS latest_id FROM medicine_inventory WHERE deleted_at is null GROUP BY medicine_id) AS mi_latest " +
 		"JOIN medicine_inventory AS mi ON mi.medicine_id=mi_latest.medicine_id AND mi.id=mi_latest.latest_id " +
 		"LEFT JOIN " + mtable + " AS m_info ON mi.medicine_id=m_info.id" + whereSql
 

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff