| | |
| | | #region FuMa-Model |
| | | |
| | | /// <summary> |
| | | /// 发送接收赋码系统接口参数的model |
| | | /// 接收赋码系统接口返回的参数 model |
| | | /// </summary> |
| | | public class FuMaModel |
| | | { |
| | | /// <summary> |
| | | /// 状态码 0 成功 -1失败 |
| | | /// </summary> |
| | | public int Success { get; set; } |
| | | public bool IsSuccess { get; set; } |
| | | /// <summary> |
| | | /// 信息详情 |
| | | /// </summary> |
| | | public string Message { get; set; } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取箱码信息参数Model |
| | | /// </summary> |
| | | public class FuMaGetBoxModel:FuMaModel |
| | | { |
| | | /// <summary> |
| | | /// 产品信息 |
| | | /// </summary> |
| | | public ProductModel Product { get; set; } |
| | | /// <summary> |
| | | /// 箱支信息 |
| | | /// </summary> |
| | | public List<BarcodesModel> Barcodes { get; set; } |
| | | /// <summary> |
| | | /// 包装比例 |
| | | /// </summary> |
| | | public string PkgRatio { get; set; } |
| | | /// <summary> |
| | | /// 整箱小包装数量 |
| | | /// </summary> |
| | | public decimal BoxItemQty { get; set; } |
| | | /// <summary> |
| | | /// 物料编码 |
| | | /// </summary> |
| | | public string MaterialNum { get; set; } |
| | | /// <summary> |
| | | /// 标准重量 |
| | | /// </summary> |
| | | public decimal StandarWeight { get; set; } |
| | | /// <summary> |
| | | /// 产线名称 |
| | | /// </summary> |
| | | public string LineName { get; set; } |
| | | /// <summary> |
| | | /// 车间名称 |
| | | /// </summary> |
| | | public string WorkShop { get; set; } |
| | | /// <summary> |
| | | /// 负责人 |
| | | /// </summary> |
| | | public string HeadMan { get; set; } |
| | | |
| | | } |
| | | public class ProductModel |
| | | { |
| | | /// <summary> |
| | | /// 产品编号 |
| | | /// </summary> |
| | | public string ProductCode { get; set; } |
| | | /// <summary> |
| | | /// 产品名称 |
| | | /// </summary> |
| | | public string ProductName { get; set; } |
| | | public int SubtypeId { get; set; } |
| | | /// <summary> |
| | | /// 子类编码 |
| | | /// </summary> |
| | | public string SubType { get; set; } |
| | | public string Type { get; set; } |
| | | /// <summary> |
| | | /// 规格 |
| | | /// </summary> |
| | | public string Spec { get; set; } |
| | | /// <summary> |
| | | /// 包装规格 |
| | | /// </summary> |
| | | public string PackageSpec { get; set; } |
| | | /// <summary> |
| | | /// 包装单位 |
| | | /// </summary> |
| | | public string PackUnit { get; set; } |
| | | public string PhysicDetailType { get; set; } |
| | | public bool IsSpecial { get; set; } |
| | | public bool Is789 { get; set; } |
| | | /// <summary> |
| | | /// 批准文号 |
| | | /// </summary> |
| | | public string AuthorizedNo { get; set; } |
| | | public List<string> PkgRatio { get; set; } |
| | | |
| | | } |
| | | |
| | | public class BarcodesModel |
| | | { |
| | | /// <summary> |
| | | /// 箱号/支号 |
| | | /// </summary> |
| | | public string Barcode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public int ScanTaskId { get; set; } |
| | | /// <summary> |
| | | /// 生产批号 |
| | | /// </summary> |
| | | public string BatchNo { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 拼箱后的批号 |
| | | /// </summary> |
| | | public string MixedBatchNo { get; set; } |
| | | /// <summary> |
| | | /// 包装级别 |
| | | /// </summary> |
| | | public string Level { get; set; } |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public string ParentBarcode { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 状态,整箱、零箱、拼箱 |
| | | /// </summary> |
| | | public string Status { get; set; } |
| | | /// <summary> |
| | | /// 箱内小包装数量 |
| | | /// </summary> |
| | | public string BoxItemQty { get; set; } |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public string ScanTime { get; set; } |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public string MixedScanTime { get; set; } |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public string MixedTaskId { get; set; } |
| | | /// <summary> |
| | | /// 物流号 |
| | | /// </summary> |
| | | public string LogisticsNum { get; set; } |
| | | /// <summary> |
| | | /// 包装人 |
| | | /// </summary> |
| | | public string PackageMan { get; set; } |
| | | /// <summary> |
| | | /// 托盘码 |
| | | /// </summary> |
| | | public string PalletCode { get; set; } |
| | | /// <summary> |
| | | /// 生产日期 |
| | | /// </summary> |
| | | public string ProductionDate { get; set; } |
| | | /// <summary> |
| | | /// 有效期至 |
| | | /// </summary> |
| | | public string ExpirationDate { get; set; } |
| | | /// <summary> |
| | | /// 实际重量 |
| | | /// </summary> |
| | | public decimal Weight { get; set; } |
| | | /// <summary> |
| | | /// 箱内件数 |
| | | /// </summary> |
| | | public int MinLevelCount { get; set; } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | public static string DoGet(string url, Dictionary<string, string> paramDic = null, Dictionary<string, string> headerDic = null) |
| | | public static string DoGet(string url, string str, string logStr, Dictionary<string, string> paramDic = null, Dictionary<string, string> headerDic = null) |
| | | { |
| | | var paramString = GetUrlParamString(paramDic); |
| | | var request = GetHttpWebRequest(url + paramString, headerDic, "GET"); |
| | | request.ContentType = "application/json"; |
| | | //log路径 |
| | | var logStr2 = $@".\log\{str}\{logStr}" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; |
| | | try |
| | | { |
| | | return GetResponseString(request); |
| | | |
| | | |
| | | //记录log |
| | | LogFile.SaveLogToFile($"{str}:( {paramString} ),", logStr2); |
| | | var requestData = GetResponseString(request); |
| | | //记录log |
| | | LogFile.SaveLogToFile($"{str}反馈:( {requestData} ),", logStr2); |
| | | return requestData; |
| | | } |
| | | catch (WebException ex) |
| | | { |
| | | |
| | | //记录log |
| | | LogFile.SaveLogToFile($"{str}反馈:( {ex.Message} ),", logStr2); |
| | | throw ex; |
| | | } |
| | | } |
| | |
| | | |
| | | ////程序正式发布后放开 |
| | | //var time1 = DateTime.Now;//发送时间 .ToString("yyyy-MM-dd HH:mm:ss") |
| | | //var response = HttpHelper.DoPost(url, jsonData, "获取箱码信息", "赋码"); |
| | | ////var response = HttpHelper.DoGet(url, jsonData, "获取箱码信息", "赋码"); |
| | | //var time2 = DateTime.Now;//返回时间 .ToString("yyyy-MM-dd HH:mm:ss") |
| | | |
| | | ////解析返回数据 |
| | | //var fuMaModel = JsonConvert.DeserializeObject<FuMaModel>(response); |
| | | //if (fuMaModel.Success == 0) |
| | | //var fuMaModel = JsonConvert.DeserializeObject<FuMaGetBoxModel>(response); |
| | | //if (fuMaModel.IsSuccess) |
| | | //{ |
| | | // //赋码返回信息成功状态 |
| | | // if (fuMaModel.Product == null || fuMaModel.Barcodes.Count == 0) |
| | | // { |
| | | // throw new Exception("产品信息或箱支信息为空"); |
| | | // } |
| | | |
| | | // foreach (var item in fuMaModel.Barcodes) |
| | | // { |
| | | // if (item.Barcode != boxNo) |
| | | // { |
| | | // throw new Exception("获取信息不一致"); |
| | | // } |
| | | |
| | | // var sku = Db.Queryable<SysMaterials>().First(m => m.IsDel == "0" && m.SkuNo == fuMaModel.Product.ProductCode); |
| | | // if (sku == null) |
| | | // { |
| | | // throw new Exception("未查询到箱码中的物料信息"); |
| | | // } |
| | | // //var boxInfo = new BllBoxInfo() |
| | | // //{ |
| | | // // ASNNo = "", |
| | | // // //ASNDetailNo = 0, |
| | | // // OrderCode = "", |
| | | // // //BindNo = 0, |
| | | // // BoxNo = item.BoxNo, |
| | | // // BoxNo2 = item.BoxNo2, |
| | | // // BoxNo3 = item.Barcode, |
| | | // // 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(); |
| | | //} |
| | | //if (fuMaModel.Success == -1) |
| | | //else |
| | | //{ |
| | | // //赋码返回信息失败状态 |
| | | // throw new Exception($"赋码系统返回状态异常:{fuMaModel.Message}"); |
| | | //} |
| | | //} |
| | | #endregion |
| | | |
| | | } |
| | |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public List<BoxInfoDto> GetBindBoxInfos(BoxInfoVm model) |
| | | public List<BoxInfoDto> GetBindBoxInfos(BoxInfoVm model, string url) |
| | | { |
| | | try |
| | | { |
| | |
| | | var count = Db.Queryable<BllBoxInfo>().Count(m => m.IsDel == "0" && m.Status == "0" && m.BoxNo == model.BoxNo); |
| | | if (count == 0) |
| | | { |
| | | GetBoxInfoByFuMa(model.BoxNo, ""); //从赋码系统获取箱码信息 |
| | | GetBoxInfoByFuMa(model.BoxNo, url); //从赋码系统获取箱码信息 |
| | | } |
| | | } |
| | | } |
| | |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public List<BoxInfoDto> GetBindBoxInfo2s(BoxInfoVm model) |
| | | public List<BoxInfoDto> GetBindBoxInfo2s(BoxInfoVm model, string url) |
| | | { |
| | | try |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | // GetBoxInfoByFuMa(model.BoxNo3, ""); //从赋码系统获取箱码信息 |
| | | } |
| | | GetBoxInfoByFuMa(model.BoxNo3, url); //从赋码系统获取箱码信息 |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | }; |
| | | #endregion |
| | | |
| | | #region 通过接口发送至erp 或 mes |
| | | #region 通过接口发送至mes |
| | | //系统对接后放开 |
| | | var jsonData = JsonConvert.SerializeObject(data); |
| | | |
| | |
| | | return ""; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取赋码token令牌 |
| | | /// </summary> |
| | | /// <param name="url">获取赋码token令牌</param> |
| | | /// <returns></returns> |
| | | public string GetFuMaToken(string url) |
| | | { |
| | | try |
| | | { |
| | | var str = ""; |
| | | |
| | | //首先判断系统内是否有token值,效期是否失效 |
| | | var sysToken = Db.Queryable<SysToken>().First(m => m.IsDel == "0" && m.SystemName == "FuMa"); |
| | | if (sysToken != null && !string.IsNullOrWhiteSpace(sysToken.Token) && sysToken.ExpireTime > DateTime.Now) |
| | | { |
| | | str = sysToken.Token; |
| | | return str; //返回token值 |
| | | } |
| | | return str; |
| | | //#region 获取新的令牌 |
| | | ////对接时更改路径 |
| | | //var user = MesConfig.MesUser; |
| | | //var pass = MesConfig.MesPassWord; |
| | | //var secretKey = Md5Tools.CalcMd5(pass); |
| | | //var nonce = Guid.NewGuid().ToString("N"); |
| | | //var timestamp = DateTimeOffset.Now.ToUnixTimeSeconds().ToString(); |
| | | |
| | | //var info = new string[] { user, secretKey, nonce, timestamp }; |
| | | //Array.Sort(info, string.CompareOrdinal); //ASCII排序 |
| | | //var miyao = string.Join("", info); //数组转换成字符串 |
| | | //var sign = Md5Tools.CalcMd5(miyao); //签名 |
| | | |
| | | //var data = new |
| | | //{ |
| | | // user = user, |
| | | // nonce = nonce, |
| | | // timestamp = timestamp, |
| | | // sign = sign, |
| | | // jwt = true, //是否返回JWT令牌 |
| | | //}; |
| | | //#endregion |
| | | |
| | | //#region 通过接口发送至赋码 |
| | | ////系统对接后放开 |
| | | //var jsonData = JsonConvert.SerializeObject(data); |
| | | |
| | | //var response = HttpHelper.DoPost(url, jsonData, "FuMa申请获取令牌", "Fuma"); |
| | | |
| | | //var obj = JsonConvert.DeserializeObject<MesTokenModel>(response);//解析返回数据 |
| | | |
| | | //if (obj.status != "success") |
| | | //{ |
| | | // throw new Exception("上传失败" + obj.message); |
| | | //} |
| | | //else |
| | | //{ |
| | | // var token = obj.Data.token; |
| | | // var expireTime = obj.Data.expire_time; |
| | | // var time = DateTime.Now.AddMilliseconds(double.Parse(expireTime)); |
| | | // if (sysToken == null)//添加 |
| | | // { |
| | | // var addToken = new SysToken() |
| | | // { |
| | | // SystemName = "MES", |
| | | // Token = token, |
| | | // ExpireTime = time, |
| | | // CreateUser = 0 |
| | | // }; |
| | | // Db.Insertable(addToken).ExecuteCommand(); |
| | | // return token; |
| | | // } |
| | | // else //修改 |
| | | // { |
| | | // sysToken.Token = token; |
| | | // sysToken.ExpireTime = time; |
| | | // sysToken.UpdateTime = DateTime.Now; |
| | | // Db.Updateable(sysToken).ExecuteCommand(); |
| | | // return token; |
| | | // } |
| | | //} |
| | | |
| | | //#endregion |
| | | } |
| | | catch (Exception) |
| | | { |
| | | return ""; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | void GetBoxInfoByFuMa(string boxNo, string url); |
| | | |
| | | // 根据箱码获取标签箱码信息 |
| | | List<BoxInfoDto> GetBindBoxInfos(BoxInfoVm model); |
| | | List<BoxInfoDto> GetBindBoxInfos(BoxInfoVm model, string url); |
| | | // 根据箱码获取标签最小追溯码信息 |
| | | List<BoxInfoDto> GetBindBoxInfo2s(BoxInfoVm model); |
| | | List<BoxInfoDto> GetBindBoxInfo2s(BoxInfoVm model,string url); |
| | | |
| | | //根据单据号获取单据明细列表 |
| | | List<ArrivalNoticeDetailDto> GetBindArrivalNoticeDetails(ArrivalNoticeVm model); |
| | |
| | | using Microsoft.AspNetCore.Authorization; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using Microsoft.Extensions.Options; |
| | | using Model.ModelVm; |
| | | using Model.ModelVm.BllAsnVm; |
| | | using Model.ModelVm.PdaVm; |
| | | using System; |
| | | using System.Security.Claims; |
| | | using Wms.Tools; |
| | | using WMS.Entity.BllAsnEntity; |
| | | using WMS.IBLL.IPdaServer; |
| | | |
| | |
| | | { |
| | | #region 依赖注入 |
| | | private readonly IPdaAsnServer _PdaAsnSvc; |
| | | private readonly ApiUrlConfig _config; //接口交互路径 |
| | | |
| | | public PdaAsnController(IPdaAsnServer pdaAsnSvc) |
| | | public PdaAsnController(IPdaAsnServer pdaAsnSvc, IOptions<ApiUrlConfig> setting) |
| | | { |
| | | _PdaAsnSvc = pdaAsnSvc; |
| | | _PdaAsnSvc = pdaAsnSvc; |
| | | _config = setting.Value; |
| | | } |
| | | #endregion |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | var models = _PdaAsnSvc.GetBindBoxInfos(model); |
| | | var models = _PdaAsnSvc.GetBindBoxInfos(model, _config.BoxHost + _config.FuMaGetBoxUrl); |
| | | |
| | | return Ok(new { code = 0, msg = "标签箱码信息", data = models }); |
| | | } |
| | |
| | | { |
| | | try |
| | | { |
| | | var models = _PdaAsnSvc.GetBindBoxInfo2s(model); |
| | | var models = _PdaAsnSvc.GetBindBoxInfo2s(model, _config.BoxHost + _config.FuMaGetBoxUrl); |
| | | |
| | | return Ok(new { code = 0, msg = "标签箱码信息", data = models }); |
| | | } |
| | |
| | | |
| | | #endregion |
| | | |
| | | #region 赋码系统 |
| | | |
| | | /// <summary> |
| | | /// 获取箱码信息 |
| | | /// </summary> |
| | | public string FuMaGetBoxUrl { get; set; } |
| | | |
| | | #endregion |
| | | |
| | | #region 下游系统 |
| | | |
| | | /// <summary> |
| | |
| | | "MesBeiLiaoUrl": "/port/mes/service/mes/save_morder_feedback", //备料反馈(原料备料到生产车间缓存区) |
| | | "MesGetTokenUrl": "/port/mes/service/system/sign_login", //获取令牌 |
| | | // 赋码 |
| | | |
| | | "FuMaGetBoxUrl": "/port/mes/service/system/sign_login", //获取赋码箱码信息 |
| | | |
| | | // AGV |
| | | "GenAgvSchedulingTask": "http://IP:PORT/rcms/services/rest/hikRpcService/genAgvSchedulingTask", //生成任务单接口 |