| | |
| | | { |
| | | try |
| | | { |
| | | if (levelType == "0") |
| | | { |
| | | throw new Exception("未找到该物料的箱包装级别"); |
| | | } |
| | | if (levelType == "3") |
| | | { |
| | | throw new Exception("未调试该级别包装!"); |
| | | } |
| | | var list = new List<BllBoxInfo>(); |
| | | |
| | | var data = new { BoxNo = boxNo }; |
| | |
| | | |
| | | #region 测试版本 |
| | | |
| | | //读取json文件,添加数据 |
| | | var ss = AppDomain.CurrentDomain.BaseDirectory; |
| | | string filePath = Path.Combine(ss, "CreateBoxInfo.json"); |
| | | string json = File.ReadAllText(filePath); |
| | | var person = JsonConvert.DeserializeObject<List<BllBoxInfo>>(json); |
| | | ////读取json文件,添加数据 |
| | | //var ss = AppDomain.CurrentDomain.BaseDirectory; |
| | | //string filePath = Path.Combine(ss, "CreateBoxInfo.json"); |
| | | //string json = File.ReadAllText(filePath); |
| | | //var person = JsonConvert.DeserializeObject<List<BllBoxInfo>>(json); |
| | | |
| | | var comTime = DateTime.Now; |
| | | //添加箱码信息表中 //暂时这些写--添加数据,后续需要和赋码系统对接后 根据明确返回的数据格式更改 |
| | | foreach (var item in person) |
| | | { |
| | | if (item.BoxNo!= boxNo) |
| | | { |
| | | continue; |
| | | } |
| | | ////添加箱码信息表中 //暂时这些写--添加数据,后续需要和赋码系统对接后 根据明确返回的数据格式更改 |
| | | //foreach (var item in person) |
| | | //{ |
| | | // if (item.BoxNo!= boxNo) |
| | | // { |
| | | // continue; |
| | | // } |
| | | |
| | | var sku = Db.Queryable<SysMaterials>().First(m=>m.IsDel =="0" && m.SkuNo == item.SkuNo); |
| | | if (sku == null) |
| | | { |
| | | continue; |
| | | } |
| | | var boxInfo = new BllBoxInfo() |
| | | { |
| | | ASNNo = "", |
| | | //ASNDetailNo = 0, |
| | | OrderCode = "", |
| | | //BindNo = 0, |
| | | BoxNo = item.BoxNo, |
| | | BoxNo2 = item.BoxNo2, |
| | | BoxNo3 = item.BoxNo3, |
| | | PalletNo = "", |
| | | Qty = item.Qty, |
| | | FullQty = item.FullQty, |
| | | Status = "0", |
| | | SkuNo = item.SkuNo, |
| | | SkuName = sku.SkuName, |
| | | LotNo = item.LotNo, |
| | | LotText = item.LotText, |
| | | SupplierLot = item.SupplierLot, |
| | | ProductionTime = item.ProductionTime, |
| | | ExpirationTime = item.ExpirationTime, |
| | | //CompleteTime = comTime, |
| | | InspectMark = item.InspectMark, |
| | | BitBoxMark = item.BitBoxMark, |
| | | InspectStatus = item.InspectStatus, |
| | | Origin = "赋码", |
| | | Standard = item.Standard, |
| | | PackageStandard = item.PackageStandard, |
| | | StoreTime = item.StoreTime, |
| | | QtyOrd = item.QtyOrd, |
| | | QtyCount = item.QtyCount, |
| | | CreateUser = 0, |
| | | CreateTime = comTime, |
| | | }; |
| | | list.Add(boxInfo); |
| | | } |
| | | Db.Insertable(list).ExecuteCommand(); |
| | | // var sku = Db.Queryable<SysMaterials>().First(m=>m.IsDel =="0" && m.SkuNo == item.SkuNo); |
| | | // if (sku == null) |
| | | // { |
| | | // continue; |
| | | // } |
| | | // var boxInfo = new BllBoxInfo() |
| | | // { |
| | | // ASNNo = "", |
| | | // //ASNDetailNo = 0, |
| | | // OrderCode = "", |
| | | // //BindNo = 0, |
| | | // BoxNo = item.BoxNo, |
| | | // BoxNo2 = item.BoxNo2, |
| | | // BoxNo3 = item.BoxNo3, |
| | | // PalletNo = "", |
| | | // Qty = item.Qty, |
| | | // FullQty = item.FullQty, |
| | | // Status = "0", |
| | | // SkuNo = item.SkuNo, |
| | | // SkuName = sku.SkuName, |
| | | // LotNo = item.LotNo, |
| | | // LotText = item.LotText, |
| | | // SupplierLot = item.SupplierLot, |
| | | // ProductionTime = item.ProductionTime, |
| | | // ExpirationTime = item.ExpirationTime, |
| | | // //CompleteTime = comTime, |
| | | // InspectMark = item.InspectMark, |
| | | // BitBoxMark = item.BitBoxMark, |
| | | // InspectStatus = item.InspectStatus, |
| | | // Origin = "赋码", |
| | | // Standard = item.Standard, |
| | | // PackageStandard = item.PackageStandard, |
| | | // StoreTime = item.StoreTime, |
| | | // QtyOrd = item.QtyOrd, |
| | | // QtyCount = item.QtyCount, |
| | | // CreateUser = 0, |
| | | // CreateTime = comTime, |
| | | // }; |
| | | // list.Add(boxInfo); |
| | | //} |
| | | //Db.Insertable(list).ExecuteCommand(); |
| | | |
| | | #endregion |
| | | |
| | | #region 正式版本 |
| | | var token = new Token().GetFuMaToken(fuMaTokenUrl); |
| | | var getParentVal = levelType == "1" ? "true" : "false"; |
| | | var getChildrenVal = levelType == "3" ? "true" : "false"; |
| | | var getChildrenVal = levelType == "2" ? "true" : "false"; |
| | | Dictionary<string, string> paramDic = new Dictionary<string, string> |
| | | { |
| | | { "Token", token }, //分配的令牌(变量) |
| | | { "Barcode", boxNo },//要查询的条码 |
| | | { "getParent", getParentVal },//是否查询父码 |
| | | { "getChildren", getChildrenVal } //是否查询子码 |
| | | { "getChildren", getChildrenVal } //是否查询子码 aaa |
| | | }; |
| | | |
| | | //程序正式发布后放开 |
| | |
| | | throw new Exception("产品信息或箱支信息为空"); |
| | | } |
| | | |
| | | foreach (var item in fuMaModel.Barcodes) |
| | | if (levelType == "1") |
| | | { |
| | | if (item.Barcode != boxNo) |
| | | if (fuMaModel.Barcodes.First().Barcode != boxNo) |
| | | { |
| | | throw new Exception("获取信息不一致"); |
| | | } |
| | | |
| | | var sku = Db.Queryable<SysMaterials>().First(m => m.IsDel == "0" && m.SkuNo == fuMaModel.Product.ProductCode); |
| | | var sku = Db.Queryable<SysMaterials>().First(m => m.IsDel == "0" && m.SkuNo == fuMaModel.MaterialNum); |
| | | if (sku == null) |
| | | { |
| | | throw new Exception("未查询到箱码中的物料信息"); |
| | | throw new Exception("未查询到箱码中和赋码提供的物料信息一致的数据"); |
| | | } |
| | | var boxInfo = new BllBoxInfo() |
| | | { |
| | |
| | | //ASNDetailNo = 0, |
| | | OrderCode = "", |
| | | //BindNo = 0, |
| | | BoxNo = item.Barcode, |
| | | BoxNo2 = item.Barcode, |
| | | BoxNo3 = item.Barcode, |
| | | BoxNo = fuMaModel.Barcodes.First().Barcode, |
| | | PalletNo = "", |
| | | Qty = item.BoxItemQty, |
| | | Qty = fuMaModel.Barcodes.First().BoxItemQty, |
| | | FullQty = fuMaModel.BoxItemQty, |
| | | Status = "0", |
| | | SkuNo = sku.SkuNo, |
| | | SkuName = sku.SkuName, |
| | | LotNo = item.BatchNo, |
| | | LotNo = fuMaModel.Barcodes.First().BatchNo, |
| | | //LotText = "", |
| | | //SupplierLot = item.SupplierLot, |
| | | ProductionTime = DateTime.Parse(item.ProductionDate), |
| | | ExpirationTime = DateTime.Parse(item.ExpirationDate), |
| | | ProductionTime = DateTime.Parse(fuMaModel.Barcodes.First().ProductionDate), |
| | | ExpirationTime = DateTime.Parse(fuMaModel.Barcodes.First().ExpirationDate), |
| | | //CompleteTime = comTime, |
| | | InspectMark = "0", |
| | | BitBoxMark = item.Status == "零箱"? "1":"0", |
| | | BitBoxMark = fuMaModel.Barcodes.First().Status == "零箱" ? "1" : "0", |
| | | InspectStatus = "0", |
| | | Origin = "赋码", |
| | | Standard = fuMaModel.Product.Spec, |
| | |
| | | }; |
| | | list.Add(boxInfo); |
| | | } |
| | | else |
| | | { |
| | | foreach (var item in fuMaModel.Barcodes) |
| | | { |
| | | if (item.Barcode == boxNo) |
| | | { |
| | | continue; //获取支码时第一个码为父码 |
| | | } |
| | | |
| | | var sku = Db.Queryable<SysMaterials>().First(m => m.IsDel == "0" && m.SkuNo == fuMaModel.MaterialNum); |
| | | if (sku == null) |
| | | { |
| | | throw new Exception("未查询到箱码中和赋码提供的物料信息一致的数据"); |
| | | } |
| | | var boxInfo = new BllBoxInfo() |
| | | { |
| | | ASNNo = "", |
| | | //ASNDetailNo = 0, |
| | | OrderCode = "", |
| | | //BindNo = 0, |
| | | BoxNo = item.ParentBarcode, |
| | | BoxNo3 = item.Barcode, |
| | | PalletNo = "", |
| | | Qty = item.MinLevelCount, |
| | | FullQty = fuMaModel.BoxItemQty, |
| | | Status = "0", |
| | | SkuNo = sku.SkuNo, |
| | | SkuName = sku.SkuName, |
| | | LotNo = item.BatchNo, |
| | | //LotText = "", |
| | | //SupplierLot = item.SupplierLot, |
| | | ProductionTime = DateTime.Parse(item.ProductionDate), |
| | | ExpirationTime = DateTime.Parse(item.ExpirationDate), |
| | | //CompleteTime = comTime, |
| | | InspectMark = "0", |
| | | BitBoxMark = item.Status == "零箱" ? "1" : "0", |
| | | InspectStatus = "0", |
| | | Origin = "赋码", |
| | | Standard = fuMaModel.Product.AuthorizedNo, |
| | | PackageStandard = fuMaModel.Product.PackageSpec, |
| | | //StoreTime = item.StoreTime, |
| | | //QtyOrd = item.QtyOrd, |
| | | QtyCount = (int)fuMaModel.BoxItemQty, |
| | | CreateUser = 0, |
| | | CreateTime = comTime, |
| | | }; |
| | | list.Add(boxInfo); |
| | | } |
| | | } |
| | | |
| | | Db.Insertable(list).ExecuteCommand(); |
| | | } |
| | | else |
| | |
| | | var count = Db.Queryable<BllBoxInfo>().Count(m => m.IsDel == "0" && m.Status == "0" && m.BoxNo == model.BoxNo); |
| | | if (count == 0) |
| | | { |
| | | GetBoxInfoByFuMa(model.BoxNo, url, fuMaTokenUrl,"1"); //从赋码系统获取箱码信息 |
| | | //获取物料包装级别 |
| | | string level = "0"; |
| | | var levelType = Db.Queryable<SysPackag>().First(w => w.IsDel == "0" && w.PackagNo == detail.SkuNo); |
| | | if (levelType.L1Name == "箱") |
| | | { |
| | | level = "1"; |
| | | } |
| | | if (levelType.L2Name == "箱") |
| | | { |
| | | level = "2"; |
| | | } |
| | | if (levelType.L3Name == "箱") |
| | | { |
| | | level = "3"; |
| | | } |
| | | GetBoxInfoByFuMa(model.BoxNo, url, fuMaTokenUrl, level); //从赋码系统获取箱码信息 |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | DateTime proTime; |
| | | DateTime expTime; |
| | | DateTime sortTime; |
| | | var bl1 = DateTime.TryParse(detail.Lot1, out proTime); |
| | | var bl2 = DateTime.TryParse(detail.Lot2, out expTime); |
| | | |