dengjunjie
3 天以前 aa5a0ac9a7d35d3a072fbe164ded24adbaa68b17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
using HslCommunication;
using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
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;
using WIDESEA_Core.Helper;
using WIDESEA_ISquareCabinServices;
using WIDESEA_Model.Models;
using static WIDESEA_DTO.SquareCabin.OrderDto;
using static WIDESEA_DTO.SquareCabin.TowcsDto;
 
 
namespace WIDESEA_SquareCabinServices
{
    public class MedicineGoodsServices : ServiceBase<Dt_MedicineGoods, IRepository<Dt_MedicineGoods>>, IMedicineGoodsServices
    {
        public MedicineGoodsServices(IRepository<Dt_MedicineGoods> BaseDal) : base(BaseDal)
        {
        }
        public IRepository<Dt_MedicineGoods> Repository => BaseDal;
 
 
 
        /// <summary>
        /// 同步删除删除商品信息 
        /// 药品编码
        /// </summary>
        /// <returns></returns>
        public WebResponseContent DeleteProduct(string goodsno)
        {
            try
            {
                var goods = BaseDal.Db.Queryable<Dt_MaterielInfo>().Where(x => x.MaterielCode == goodsno).First();
                if (goods == null)
                {
                    return new WebResponseContent
                    {
                        Status = false,
                        Message = $"商品编号 {goodsno} 不存在"
                    };
                }
                var medicineDTO = new ProductInfo
                {
                    //用户code
                    customerCode = "905",
                    //物料类型
                    materialCode = "YY",
                    //产品编码
                    productCode = goods.MaterielCode,
                    //产品名
                    productName = goods.MaterielName,
                    //产品条码
                    productBarCode = goods.MaterielCode,
 
                    //规格
                    productSpecifications = goods.MaterielSpec,
                    //单位
                    unit = goods.MaterielUnit,
                    //长
                    singleProductLongNum = goods.MaterielLength.ToString(),
                    //宽
                    singleProductWideNum = goods.MaterielWide.ToString(),
                    //高
                    singleProductHighNum = goods.MaterielHeight.ToString(),
                    //重量
                    singleProductWeight = goods.MaterielWeight.ToString(),
                    //体积
                    singleProductVolume = goods.MaterielVolume.ToString(),
                    //是否取消 0是不删除,1删除
                    isDelete = "1"
                };
                var url = "http://172.16.1.2:9357/file-admin/api/product/productSynchronous";
                //var url = "http://172.16.1.245:9357/file-admin/api/product/productSynchronous";
 
                var result = HttpHelper.Post(url, medicineDTO.ToJsonString());
                var resp = JsonConvert.DeserializeObject<TowcsResponse<object>>(result);
                if (resp != null && resp.code == "0")
                {
                    //我自己也删除
                    base.Db.Deleteable<Dt_MaterielInfo>().Where(x => x.MaterielCode == goodsno);
                    return new WebResponseContent { Status = true, Message = "删除成功" };
                }
                return new WebResponseContent { Status = false, Message = "删除失败请重试" };
            }
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
 
 
        /// <summary>
        /// 推送异常信息给上游系统1.入库单接口;2.入库单报完成接口;3.出库单接口;4.出库报完成接口;5.药品基础信息同步接口;6.供应商信息接口;7.客户信息接口;8.库存
        /// </summary>
        public void SendErrorToUpstream(int type, string code, string message, string remark)
        {
            try
            {
                var url = "http://121.37.118.63:80/GYZ2/95fck/exceptionLog";
 
                var requestData = new
                {
                    type = type.ToString(),
                    code = code,
                    message = message,
                    remark = remark
                };
 
                var result = HttpHelper.Post(url, requestData.ToJsonString());
                // 可以反序列化检查 resultCode 是否为0
            }
            catch (Exception e)
            {
                // 这里不要再抛异常了,避免死循环
                Console.WriteLine("异常接口推送失败:" + e.Message);
            }
        }
        
 
 
    }
}