|
@@ -439,7 +439,15 @@ func (e *StockTemplate) StockTemplateInScanCode(req *dto.BatchStockTemplateInIns
|
|
|
if medicineInfo == nil {
|
|
|
sql := "INSERT INTO " + models.GetMedicineInfoTableName(req.DeptId) + " SET "
|
|
|
for k, v := range c.MedicineInfo {
|
|
|
+ // 不是系统初始化字段
|
|
|
+ if !models.GetMedicineInfoFieldIsSysInit(k) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if v == nil {
|
|
|
+ continue
|
|
|
+ }
|
|
|
sql += fmt.Sprintf("`%s`='%v',", k, v)
|
|
|
+
|
|
|
}
|
|
|
sql += fmt.Sprintf("`%s`='%v',", "unit_price", c.UnitPrice)
|
|
|
sql += fmt.Sprintf("`%s`='%v',", "qrcode", c.Qrcode)
|
|
@@ -1494,6 +1502,7 @@ func (e *StockTemplate) StockTemplateInList(c *dto.StockTemplateInPageReq, deptI
|
|
|
).
|
|
|
Joins("left join " + mtable + " on stock_in.medicine_id = " + mtable + ".id").
|
|
|
Where(whereSql).
|
|
|
+ Order("stock_in.date desc,stock_in.id desc").
|
|
|
Scan(&list).Limit(-1).Offset(-1).
|
|
|
Count(&count).Error
|
|
|
if err != nil {
|
|
@@ -1561,6 +1570,7 @@ func (e *StockTemplate) StockTemplateOutList(c *dto.StockTemplateOutPageReq, dep
|
|
|
).
|
|
|
Joins("left join " + mtable + " on stock_out.medicine_id = " + mtable + ".id").
|
|
|
Where(whereSql).
|
|
|
+ Order("stock_out.date desc,stock_out.id desc").
|
|
|
Scan(&list).Limit(-1).Offset(-1).
|
|
|
Count(&count).Error
|
|
|
if err != nil {
|
|
@@ -2097,3 +2107,43 @@ func (e *StockTemplate) StockTemplateTransportRecordWord(c *models.TransportReco
|
|
|
return list, nil
|
|
|
|
|
|
}
|
|
|
+func (e *StockTemplate) StockTemplateTransportRecordWord2(c *models.TransportRecord, deptId int) (list []map[string]interface{}, err error) {
|
|
|
+
|
|
|
+ mtable := models.GetMedicineInfoTableName(deptId)
|
|
|
+ whereSql := "stock_out.dept_id = " + strconv.Itoa(deptId) + " AND stock_out.deleted_at is null"
|
|
|
+ if c.ProductID > 0 {
|
|
|
+ whereSql += " AND " + mtable + ".product_id = " + strconv.Itoa(c.ProductID)
|
|
|
+ }
|
|
|
+ if len(c.Date) > 0 {
|
|
|
+ whereSql += " AND stock_out.date = '" + c.Date + "'"
|
|
|
+ }
|
|
|
+ if len(c.ReceivingUnit) > 0 {
|
|
|
+ whereSql += " AND stock_out.receiving_unit like '%" + c.ReceivingUnit + "%'"
|
|
|
+ }
|
|
|
+ err = db.DB.Table("stock_out").
|
|
|
+ Select(mtable + ".*,stock_out.quantity as quantity").
|
|
|
+ Joins("left join " + mtable + " on stock_out.medicine_id = " + mtable + ".id").
|
|
|
+ Where(whereSql).
|
|
|
+ Scan(&list).Error
|
|
|
+ if err != nil {
|
|
|
+ logs.Error("db error: %s ", err)
|
|
|
+ return list, global.GetFailedErr
|
|
|
+ }
|
|
|
+ models.InitBasicData(deptId)
|
|
|
+ for i := 0; i < len(list); i++ {
|
|
|
+ if id, ok := list[i][models.FieldProductID]; ok {
|
|
|
+ list[i][models.FieldProductName] = models.Read_Product_Get(utils.ToInt(id))
|
|
|
+ }
|
|
|
+ if id, ok := list[i][models.FieldEnterpriseID]; ok {
|
|
|
+ list[i][models.FieldEnterpriseName] = models.Read_Enterprise_Get(utils.ToInt(id))
|
|
|
+ }
|
|
|
+ if id, ok := list[i][models.FieldSpecID]; ok {
|
|
|
+ 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))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list, nil
|
|
|
+
|
|
|
+}
|