qinchulong
3 天以前 dc467182bfaeeb0dfd9bc2d6c4ec8fe64b179446
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
using LogLibrary.Log;
using Masuit.Tools;
using Newtonsoft.Json;
using WIDESEA_Common.FangCang;
using WIDESEA_Core;
using WIDESEA_DTO;
using WIDESEA_Model.Models;
 
namespace WIDESEA_StoragIntegrationServices
{
    public partial class ToMESService
    {
        /// <summary>
        /// EDI出库订单  接收医药出库订单数据
        /// </summary>
        /// <param name="jsondata"></param>
        /// <returns></returns>
        public WebResponseContent ediOut(object jsondata)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                if (string.IsNullOrEmpty(jsondata.ToString())) throw new Exception("上传参数为空");
                
 
                var result = JsonConvert.DeserializeObject<ediOut>(jsondata.ToString());
 
                //todo 完成添加出库订单逻辑
                if(result.outOrderType == "10")   //一般交易出库订单
                {
                    foreach (var item in result.details)
                    {
                        //to 循环查询库存是否满足
                        var stockInfos= _stockInfoRepository.QueryData(x => x.StockStatus == 1);
                        if (stockInfos.Count <= 0) throw new Exception($"{item.productName}库存不足");
                    }
                }
                else if(result.outOrderType == "20")  //盘点出库单
                {
 
                }
                else if(result.outOrderType == "30")  //盘亏出库单
                {
                    if (result.details[0].stocktakingDetails.Count <= 0) throw new Exception($"盘亏明细为空");
                }
 
 
                LogFactory.GetLog("EDI出库订单接口").Info(true, $"\r\r--------------------------------------");
                LogFactory.GetLog("EDI出库订单接口").Info(true, jsondata.ToJsonString());
 
                return content;
 
            }
            catch (Exception ex)
            {
                LogFactory.GetLog("EDI出库订单接口").Info(true, $"\r\r--------------------------------------");
                LogFactory.GetLog("EDI出库订单接口").Info(true, ex.Message);
                return content.Error($"EDI出库订单接口请求异常:{ex.Message}");
            }
        }
    }
}