1
huanghongfeng
2025-06-25 b1c2dd1869a51b8f0e4acb9ddeb148f796db147f
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
 
using Masuit.Tools;
using Newtonsoft.Json;
using System.Text.Json.Nodes;
using System.Xml.Serialization;
using WIDESEA.Common;
using WIDESEA_Common;
using WIDESEA_Common.ZY;
using WIDESEA_Core;
using WIDESEA_Core.Enums;
using WIDESEA_Core.Helper;
using WIDESEA_Model.Models;
 
namespace WIDESEA_StoragIntegrationServices
{
    public partial class ToAPPService
    {
        public WebResponseContent SaveCLinfo(SaveModel saveModel)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                //如当前存在未开始入库的车轮或制动盘数据,则禁止保存新数据 以防数据混乱
                var waitInbound = _InWheels_MesRepository.QueryFirst(x => x.Wheels_CurrentStatue == "0");
                if (waitInbound != null) throw new Exception("当前存在未开始入库的车轮或制动盘,请先入库后再保存信息!");
 
                //车轮码
                string clCode = saveModel.MainData["code"].ToString();
                //车轮号
                string clh = saveModel.MainData["clh"].ToString();
                if (string.IsNullOrEmpty(clCode) || string.IsNullOrEmpty(clh))
                    throw new Exception($"车轮条码不能为空");
 
                if (!clCode.Contains("/") && !clCode.ToUpper().StartsWith("L")) throw new Exception($"车轮条码错误,请重新核对");
 
                var clinfo = _InWheels_MesRepository.QueryFirst(x => x.Wheels_code == clCode || x.Wheels_Num == clh);
                if (clinfo != null) throw new Exception("车轮录入信息已存在");
 
                //检测库存是否已存在
                _WheelsStockRepository.QueryFirst(x => x.Wheels_code == clCode || x.Wheels_Num == clh);
                if (clinfo != null) throw new Exception("库内已存在,请检查库存");
 
                //序列号
                //string madeUnit = saveModel.MainData["xlh"].ToString();
 
                //轮对条码  
                string ldtm = saveModel.MainData["ldtm"].ToString();
                //车型
                string Cartype = saveModel.MainData["chexing"].ToString();
                if (string.IsNullOrEmpty(Cartype)) throw new Exception($"车型参数为空,不允许入库");
                //配属局
                string psj = saveModel.MainData["psj"].ToString();
                //车组号
                string lcch = saveModel.MainData["lcch"].ToString();
                //新旧 (0-新 1-旧)
                string newOrOld = saveModel.MainData["neworold"].ToString();
                if (string.IsNullOrEmpty(newOrOld)) throw new Exception($"新旧参数为空,不允许入库");
                //轮对号
                string ldh = saveModel.MainData["ldh"].ToString();
                //轮型
                string ldxh = saveModel.MainData["ldxh"].ToString();
                if (string.IsNullOrEmpty(ldxh)) throw new Exception($"轮型参数为空,不允许入库");
                //毂孔等级
                string gkdj = saveModel.MainData["gkdj"].ToString();
                if (string.IsNullOrEmpty(gkdj)) throw new Exception($"毂孔等级参数为空,不允许入库");
                //毂孔a界面均值
                string gkzja = saveModel.MainData["gkzja"].ToString();
                //毂孔b界面均值
                string gkzjb = saveModel.MainData["gkzjb"].ToString();
                //毂孔c界面均值
                string gkzjc = saveModel.MainData["gkzjc"].ToString();
                //轮径值
                string ljz = saveModel.MainData["ljz"].ToString();
 
                //预估轮径值
                string yglj = saveModel.MainData["yglj"].ToString();
                //属性
                string WheelsProps = saveModel.MainData["clsx"].ToString();
                //轮缘
                string lyh = saveModel.MainData["lyh"].ToString();
                //动拖属性
                string mttype = saveModel.MainData["mttype"].ToString();
                if (string.IsNullOrEmpty(mttype)) throw new Exception($"动拖属性参数为空,不允许入库");
                //毂孔均值
                string gkcc = saveModel.MainData["gkcc"].ToString();
                if (string.IsNullOrEmpty(gkcc)) throw new Exception($"毂孔均值参数为空,不允许入库");
                //入库时间
                string rksj = saveModel.MainData["rksj"].ToString();
                if (string.IsNullOrEmpty(rksj)) throw new Exception($"入库时间参数为空,不允许入库");
 
                //检测剩余空库位数量是否足够 --todo:内外侧空库位检测
                if (_locationRepository.QueryData(x => x.LocationStatus == (int)LocationEnum.Free && x.EnalbeStatus == 1).Count < 2) throw new Exception($"库位数量不足,不允许入库");
 
                //if (newOrOld == "0")
                //{
                gkdj = LevelChangeHelper.LevelChangeType(gkdj);
                if (string.IsNullOrEmpty(gkdj)) throw new Exception("等级转换失败,请检查接口等级参数");
                //}
 
                Dt_InWheels_mes wheels_Mes = new Dt_InWheels_mes
                {
                    Wheels_code = clCode,
                    Wheels_Type = "1",
                    Wheels_Num = clh,
                    CreateDate = DateTime.Now,
                    Creater = "admin",
                    WheelsProps = WheelsProps,
                    Wheels_CarNo = lcch,
                    Wheels_CarType = Cartype,
                    Wheels_ldxh = ldxh,
                    Wheels_CurrentStatue = "0",
                    Wheels_ldtm = ldtm,
                    Wheels_InDate = rksj,
                    Wheels_level = gkdj,
                    Wheels_NewOrOld = newOrOld == "旧" ? "1" : "0",
                    Wheels_psj = psj,
                    Wheels_gkcc = gkcc,
                    Wheels_gkzja = gkzja,
                    Wheels_gkzjb = gkzjb,
                    Wheels_gkzjc = gkzjc,
                    Wheels_ldh = ldh,
                    Wheels_ljz = ljz,
                    Wheels_mttype = mttype,
                    //Wheels_SequenceNum = "",
                    Wheels_ygljz = yglj,
                    Wheels_LYH = lyh
                };
 
                if (_InWheels_MesRepository.AddData(wheels_Mes) > 0)
                {
                    return content.OK("保存成功");
                }
                else
                {
                    return content.Error("保存失败");
                }
            }
            catch (Exception ex)
            {
                return content.Error($"{ex.Message}");
            }
        }
    }
}