刘磊
2025-04-22 a11a7e324d2b12a6637d4c84b7c0bc25c27b99cd
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
using AngleSharp.Dom;
using Mapster;
using Masuit.Tools;
using SqlSugar;
using System.Collections.Generic;
using System.Drawing.Printing;
using System.Linq.Expressions;
using WIDESEA_Common;
using WIDESEA_Core;
using WIDESEA_StorageBasicRepository;
using WIDESEAWCS_BasicInfoRepository;
 
namespace WIDESEA_StorageBasicService;
 
public class Dt_WheelsStock_OldService : ServiceBase<Dt_WheelsStock_Old, IDt_WheelsStock_OldRepository>, IDt_WheelsStock_OldService
{
    private readonly string oldLocationAddress = "http://172.21.5.167:8028/wms5/api/gzdcd/Check_St";  //旧库获取库存数据地址
 
    public Dt_WheelsStock_OldService(IDt_WheelsStock_OldRepository BaseDal) : base(BaseDal)
    {
 
 
    }
 
    public WebResponseContent GetOldLocationWheels()
    {
        WebResponseContent content = new WebResponseContent();
        try
        {
            var currentList = BaseDal.QueryData();
 
            string respon = HttpsClient.Post(oldLocationAddress);
 
            List<Dt_WheelsStock_Old> oldWheels = JsonConvert.DeserializeObject<List<Dt_WheelsStock_Old>>(respon.ToString());
 
            if (oldWheels == null || oldWheels.Count == 0) throw new Exception("获取失败:接口数据为空");
 
            oldWheels = oldWheels.Where(x => !string.IsNullOrEmpty(x.wheel_code)).ToList();
 
            var deleteList = currentList.Except(oldWheels).ToList();
            //currentList.Where(x=>x.wheel_code)
 
            if (BaseDal.AddData(oldWheels) > 1)
            {
                return content.OK("旧库数据获取成功");
            }
            else
            {
                return content.Error();
            }
        }
        catch (Exception ex)
        {
            if (ex.Message.Contains("404"))
            {
                return content.Error("旧库程序未启动,无法访问接口");
            }
            else
            {
                return content.Error(ex.Message);
            }
 
        }
    }
 
}