dengjunjie
2025-10-23 4cca607ddce9577864b8a5c9c8edf7c83915b787
н¨Îļþ¼Ð/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/MedicineGoodsServices.cs
@@ -7,6 +7,7 @@
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Common;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
@@ -37,11 +38,11 @@
            var responseContent = new WebResponseContent();
            try
            {
              var url = "http://121.37.118.63:80/GYZ2/95fck/goodsInfo";
                var url = "http://121.37.118.63:80/GYZ2/95fck/goodsInfo";
                if (string.IsNullOrEmpty(SearchDate)) SearchDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                //if (string.IsNullOrEmpty(SearchDate)) SearchDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                //请求参数
                var requestData = new
                {
@@ -52,7 +53,7 @@
                //    // é»˜è®¤æŸ¥è¯¢è¿‡åŽ»24小时的数据
                //    SearchDate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
                //}
                //// è¯·æ±‚参数
                // è¯·æ±‚参数
                //var requestData = new
                //{
                //    searchDate = SearchDate
@@ -84,14 +85,14 @@
                var entityList = response.data.Where(Medicat => !existingGoodsNos.Contains(Medicat.goods_no)).Select(Medicat => new Dt_MaterielInfo
                {
                    MaterielCode = Medicat.goods_no,
                    MaterielErpType = Medicat.materialCode,
                    MaterielErpType = Medicat.goods_type,
                    item = Medicat.goods_tym, //通用名
                    MaterielName = Medicat.goods_spm,//物料名称
                    MaterielSpec = Medicat.model,
                    Factory = Medicat.factory,
                    MaterielUnit = Medicat.unit,//单位
                    // ä½¿ç”¨ ?? è¿ç®—符提供默认值
                    MaterielLength = (float?)Medicat.item_length ,
                    MaterielLength = (float?)Medicat.item_length,
                    MaterielWide = (float?)Medicat.item_width,
                    MaterielHeight = (float?)Medicat.item_hight,
                    MaterielVolume = (float?)Medicat.item_volumn,
@@ -107,7 +108,7 @@
                ProductSynchronous();
                return responseContent.OK("同步成功");
            }
            catch (Exception ex)
            {
                SendErrorToUpstream(5, "", ex.Message, "");
@@ -126,7 +127,8 @@
            {
                //先找到所有未下发的药品
                //var list = BaseDal.QueryData(x => x.GoodStatus == "未下发").ToList();
                var list =BaseDal.Db.Queryable<Dt_MaterielInfo>().Where(x => x.GoodStatusState == "未下发").ToList();
                //把小件未下发的的信息
                var list = BaseDal.Db.Queryable<Dt_MaterielInfo>().Where(x => x.GoodStatusState == "未下发" && x.MaterielSourceType == MaterielSourceTypeEnum.SelfMadePart).ToList();
                if (list == null || !list.Any())
                {
                    return new WebResponseContent().OK("无未下发药品");
@@ -139,28 +141,28 @@
                        //用户code
                        customerCode = "905",
                        //物料类型
                        materialCode =item.MaterielErpType,
                        materialCode = item.MaterielErpType,
                        //产品编码
                        productCode= item.MaterielCode,
                        productCode = item.MaterielCode,
                        //产品名
                        productName =item.MaterielName,
                        productName = item.MaterielName,
                        //产品条码
                        productBarCode= item.MaterielCode,
                        productBarCode = item.MaterielCode,
                        //规格
                        productSpecifications=item.MaterielSpec,
                        productSpecifications = item.MaterielSpec,
                        //单位
                        unit = item.MaterielUnit,
                        //长
                        singleProductLongNum = item.MaterielLength.ToString(),
                        singleProductLongNum = (item.MaterielLength ?? 0).ToString(),
                        //宽
                        singleProductWideNum = item.MaterielWide.ToString(),
                        singleProductWideNum = (item.MaterielWide ?? 0).ToString(),
                        //高
                        singleProductHighNum = item.MaterielHeight.ToString(),
                        singleProductHighNum = (item.MaterielHeight ?? 0).ToString(),
                        //重量
                        singleProductWeight = item.MaterielWeight.ToString(),
                        singleProductWeight = (item.MaterielWeight ?? 0).ToString(),
                        //体积
                        singleProductVolume = item.MaterielVolume.ToString(),
                        singleProductVolume = (item.MaterielVolume ?? 0).ToString(),
                        //是否取消 0是不删除,1删除
                        isDelete = "0"
                    };
@@ -168,18 +170,18 @@
                    var result = HttpHelper.Post(url, medicineDTO.ToJsonString());
                    var resp = JsonConvert.DeserializeObject<TowcsResponse<object>>(result);
                    if (resp!=null&&resp.code=="0")
                    if (resp != null && resp.code == "0")
                    {
                        //更新药品状态-已完成
                        BaseDal.Db.Updateable<Dt_MaterielInfo>()
                            .SetColumns(x => x.GoodStatusState == "下发完成")
                            .Where(x => x.GoodStatusState == item.MaterielCode)
                            .ExecuteCommand();
                            .Where(x => x.MaterielCode == item.MaterielCode)
                            .ExecuteCommand();
                    }
                    else
                    {
                        SendErrorToUpstream(5, medicineDTO.materialCode, resp?.msg ?? "WCS药品信息同步失败", "");
                        return new WebResponseContent { Status = false, Message = "订单推送失败" };
                    }
@@ -203,7 +205,7 @@
        {
            try
            {
                var goods = BaseDal.Db.Queryable< Dt_MaterielInfo >().Where(x => x.MaterielCode == goodsno).First();
                var goods = BaseDal.Db.Queryable<Dt_MaterielInfo>().Where(x => x.MaterielCode == goodsno).First();
                if (goods == null)
                {
                    return new WebResponseContent
@@ -257,8 +259,7 @@
            }
            catch (Exception ex)
            {
              return new WebResponseContent { Status=false,Message = ex.Message };
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
@@ -290,6 +291,6 @@
            }
        }
    }
}