|
@@ -6,8 +6,8 @@ import (
|
|
|
_ "Medical_ERP/common/response"
|
|
|
"Medical_ERP/conf"
|
|
|
"Medical_ERP/dto"
|
|
|
+ "Medical_ERP/models"
|
|
|
"Medical_ERP/services"
|
|
|
- "Medical_ERP/utils"
|
|
|
"encoding/json"
|
|
|
"errors"
|
|
|
"fmt"
|
|
@@ -40,6 +40,10 @@ func (c MedicineController) BatchNumber() {
|
|
|
}
|
|
|
|
|
|
list := make([]string, 0)
|
|
|
+ if reqData.SpecID == 0 || reqData.EnterpriseID == 0 || reqData.ProductID == 0 {
|
|
|
+ c.OK(list, "查询成功")
|
|
|
+ return
|
|
|
+ }
|
|
|
err := s.GetBatchNumber(&reqData, &list, beegouser.GetDeptId(c.Ctx))
|
|
|
if err != nil {
|
|
|
c.Error(global.BadRequest, err, err.Error())
|
|
@@ -115,51 +119,16 @@ func (c MedicineController) MSFXQuery() {
|
|
|
}
|
|
|
|
|
|
MSFX_baseUrl, _ := beego.AppConfig.String("MSFX_baseUrl")
|
|
|
- MSFX_user, _ := beego.AppConfig.String("MSFX_user")
|
|
|
- MSFX_mock := beego.AppConfig.DefaultBool("MSFX_mock", true)
|
|
|
-
|
|
|
- info := make([]map[string]interface{}, 0)
|
|
|
- if MSFX_mock {
|
|
|
- mock := map[string]interface{}{
|
|
|
- "名称": "替硝唑片" + strings.ToUpper(utils.GenerateAppKey(2)),
|
|
|
- "批号": strings.ToUpper(utils.GenerateAppKey(4)),
|
|
|
- "有效期至": "20250619",
|
|
|
- "包装数量": "1",
|
|
|
- "生产日期": "2023-06-20",
|
|
|
- "批准文号": "国药准字H20033090",
|
|
|
- "效期": "24月",
|
|
|
- "药品类别": "普通药品",
|
|
|
- "规格": "8片/盒",
|
|
|
- "规格摘要": "0.5g",
|
|
|
- "类型": "片剂",
|
|
|
- "厂家": "山东鲁抗医药集团赛特有限责任公司",
|
|
|
- }
|
|
|
- mock_ := make(map[string]interface{})
|
|
|
- mock_["product_name"] = mock["名称"]
|
|
|
- mock_["enterprise_name"] = mock["厂家"]
|
|
|
- mock_["quantity"] = mock["包装数量"]
|
|
|
- mock_["spec_name"] = fmt.Sprintf("%s×%s", mock["规格摘要"], mock["规格"])
|
|
|
- mock_["dosage_form_name"] = mock["类型"]
|
|
|
- mock_["batch_number"] = mock["批号"]
|
|
|
- date := mock["有效期至"].(string)
|
|
|
- mock_["expiry_date"] = fmt.Sprintf("%s-%s-%s", date[0:4], date[4:6], date[6:8])
|
|
|
- mock_["produced_date"] = mock["生产日期"]
|
|
|
- mock_["approval_number"] = mock["批准文号"]
|
|
|
-
|
|
|
- info = append(info, mock_)
|
|
|
- c.OK(info, "查询成功")
|
|
|
- return
|
|
|
- }
|
|
|
|
|
|
- err := redis.GetJson(global.RedisMSFXMedicineInfo+code, &info)
|
|
|
+ var res models.MSFXResponse
|
|
|
+ err := redis.GetJson(global.RedisMSFXMedicineInfo+code, &res)
|
|
|
if err == nil {
|
|
|
- c.OK(info, "查询成功")
|
|
|
+ c.OK(res, "查询成功")
|
|
|
return
|
|
|
}
|
|
|
client := resty.New()
|
|
|
resp, err := client.R().
|
|
|
SetQueryParams(map[string]string{
|
|
|
- "user": MSFX_user,
|
|
|
"code": code,
|
|
|
}).
|
|
|
Get(MSFX_baseUrl)
|
|
@@ -168,28 +137,43 @@ func (c MedicineController) MSFXQuery() {
|
|
|
c.Error(400, err, "获取药品扫码信息失败")
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- if err = json.Unmarshal(resp.Body(), &info); err != nil {
|
|
|
+ if err = json.Unmarshal(resp.Body(), &res); err != nil {
|
|
|
c.Error(400, err, "获取药品扫码信息失败")
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ // Unmarshal the inner "data" field which is a string containing JSON
|
|
|
+
|
|
|
+ var result struct {
|
|
|
+ Result models.MSFXResult `json:"result"`
|
|
|
+ }
|
|
|
+
|
|
|
+ err = json.Unmarshal([]byte(res.Data), &result)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error unmarshalling inner data:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ info := result.Result.Models
|
|
|
info_ := make([]map[string]interface{}, len(info))
|
|
|
for i := 0; i < len(info); i++ {
|
|
|
info_[i] = make(map[string]interface{})
|
|
|
- if len(info[i]["名称"].(string)) == 0 {
|
|
|
- c.Error(400, err, "药品信息不存在")
|
|
|
+ //if len(info[i]["名称"].(string)) == 0 {
|
|
|
+ // c.Error(400, err, "药品信息不存在")
|
|
|
+ //}
|
|
|
+ info_[i]["product_name"] = info[i].DrugEntBaseDTO.PhysicName
|
|
|
+ info_[i]["enterprise_name"] = info[i].PUserEntDTO.EntName
|
|
|
+ info_[i]["spec_name"] = fmt.Sprintf("%s×%s", info[i].DrugEntBaseDTO.PrepnSpec, info[i].DrugEntBaseDTO.PkgSpecCrit)
|
|
|
+ info_[i]["dosage_form_name"] = info[i].DrugEntBaseDTO.PrepnTypeDesc
|
|
|
+ info_[i]["approval_number"] = info[i].DrugEntBaseDTO.ApprovalLicenceNo
|
|
|
+
|
|
|
+ if len(info[i].CodeProduceInfoDTO.ProduceInfoList) > 0 {
|
|
|
+ info_[i]["quantity"] = info[i].CodeProduceInfoDTO.ProduceInfoList[0].PkgAmount
|
|
|
+ info_[i]["batch_number"] = info[i].CodeProduceInfoDTO.ProduceInfoList[0].BatchNo
|
|
|
+ date := info[i].CodeProduceInfoDTO.ProduceInfoList[0].ExpireDate
|
|
|
+ info_[i]["expiry_date"] = fmt.Sprintf("%s-%s-%s", date[0:4], date[4:6], date[6:8])
|
|
|
+ info_[i]["produced_date"] = info[i].CodeProduceInfoDTO.ProduceInfoList[0].ProduceDateStr
|
|
|
}
|
|
|
- info_[i]["product_name"] = info[i]["名称"]
|
|
|
- info_[i]["enterprise_name"] = info[i]["厂家"]
|
|
|
- info_[i]["quantity"] = info[i]["包装数量"]
|
|
|
- info_[i]["spec_name"] = fmt.Sprintf("%s×%s", info[i]["规格摘要"], info[i]["规格"])
|
|
|
- info_[i]["dosage_form_name"] = info[i]["类型"]
|
|
|
- info_[i]["batch_number"] = info[i]["批号"]
|
|
|
- date := info[i]["有效期至"].(string)
|
|
|
- info_[i]["expiry_date"] = fmt.Sprintf("%s-%s-%s", date[0:4], date[4:6], date[6:8])
|
|
|
- info_[i]["produced_date"] = info[i]["生产日期"]
|
|
|
- info_[i]["approval_number"] = info[i]["批准文号"]
|
|
|
}
|
|
|
|
|
|
redis.SetJson(global.RedisMSFXMedicineInfo+code, info_, 7*24*time.Hour)
|