| | |
| | | { |
| | | dynamic resultInfos = new ExpandoObject(); |
| | | resultInfos.tbBillList = new ExpandoObject(); |
| | | resultInfos.tbBillList.printInfo = _mCf.getPrintInfo(unity); |
| | | //resultInfos.tbBillList.printInfo = _mCf.getPrintInfo(unity); |
| | | var scanResult = m.BarCF(unity); |
| | | resultInfos.tbBillList.cfBarInfo = _mCf.getCfInfo(scanResult); |
| | | return new ResponseResult |
| | |
| | | return ResponseResult.ResponseError(ex); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取条码信息和物料信息(入库前拆分) |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost("GetBarInfoBefore")] |
| | | public ResponseResult GetBarInfoBefore(WarehouseQuery unity) |
| | | { |
| | | try |
| | | { |
| | | dynamic resultInfos = new ExpandoObject(); |
| | | resultInfos.tbBillList = m.GetBarInfoBefore(unity); |
| | | resultInfos.tbMesItems = m.GetItemNo(resultInfos.tbBillList.ITEM_ID); |
| | | return new ResponseResult |
| | | { |
| | | status = 0, |
| | | message = "OK", |
| | | data = resultInfos |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return ResponseResult.ResponseError(ex); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取条码信息和物料信息 (入库前拆分) |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost("BarCfBefore")] |
| | | public ResponseResult BarCfBefore(WarehouseQuery unity) |
| | | { |
| | | try |
| | | { |
| | | dynamic resultInfos = new ExpandoObject(); |
| | | resultInfos.tbBillList = new ExpandoObject(); |
| | | resultInfos.tbBillList.printInfo = _mCf.getPrintInfo(unity); |
| | | var scanResult = m.BarCfBefore(unity); |
| | | resultInfos.tbBillList.cfBarInfo = _mCf.getCfBeforeInfo(scanResult); |
| | | return new ResponseResult |
| | | { |
| | | status = 0, |
| | | message = "OK", |
| | | data = resultInfos |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return ResponseResult.ResponseError(ex); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | public string? itemNo { get; set; } |
| | | public string? message { get; set; } |
| | | public string? cgrkType { get; set; } |
| | | |
| | | } |
| | |
| | | var xmlFile = |
| | | $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; |
| | | var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); |
| | | c.IncludeXmlComments(xmlPath, true); |
| | | //c.IncludeXmlComments(xmlPath, true); |
| | | }); |
| | | |
| | | //配置JSON.NET |
| | |
| | | "TestErpUrl": "http://192.168.1.149:8066/WebService1.asmx/MesToErpinfoTest", |
| | | "ProductionErpUrl": "http://192.168.1.149:8066/WebService1.asmx/MesToErpinfoTest", |
| | | //"DataBaseConn": "Data Source=192.168.1.146;Initial Catalog=TEST_MES;User ID=sa;Password =qixi123;Encrypt=True;TrustServerCertificate=True;" |
| | | "DataBaseConn": "Data Source=192.168.1.146;Initial Catalog=GS_MES;User ID=mesUser;Password =qixi1qaz@WSXmes;Encrypt=True;TrustServerCertificate=True;" |
| | | "DataBaseConn": "Data Source=192.168.1.187;Initial Catalog=TEST_MES;User ID=sa;Password =LongWei@2025;Encrypt=True;TrustServerCertificate=True;" |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | //入库前拆分 |
| | | public dynamic GetBarInfoBefore(WarehouseQuery unity) |
| | | { |
| | | |
| | | // 使用参数化查询防止SQL注入 |
| | | var sqlParams = new List<SugarParameter> { new("@barcode", unity.barcode) }; |
| | | |
| | | var sql1 = @"SELECT 1 FROM MES_INV_ITEM_STOCKS WHERE ITEM_BARCODE =@barcode "; |
| | | |
| | | var KcInfo = Db.Ado.SqlQuery<dynamic>(sql1, sqlParams); |
| | | |
| | | if (KcInfo.Count > 0) throw new Exception("该条码已入库不能进行入库前拆分!"); |
| | | |
| | | var sql2 = @"SELECT ITEM_ID,QUANTITY FROM MES_INV_ITEM_BARCODES WHERE ITEM_BARCODE =@barcode "; |
| | | |
| | | var barInfo = Db.Ado.SqlQuery<dynamic>(sql2, sqlParams).FirstOrDefault(); |
| | | |
| | | if (barInfo is null) throw new Exception("该条码信息不存在!"); |
| | | |
| | | return barInfo; |
| | | } |
| | | //入库前拆分 |
| | | public ProductionPickDto BarCfBefore(WarehouseQuery unity) |
| | | { |
| | | var _strMsg = ""; |
| | | var _intSum = ""; |
| | | var _cfBar = "";//拆分后条码 |
| | | using (var conn = new SqlConnection(DbHelperSQL.strConn)) |
| | | { |
| | | if (unity.userName.IsNullOrEmpty()) throw new Exception("用户名不允许为空"); |
| | | if (unity.CfNum <= 0) throw new Exception("拆分数量需大于等于0"); |
| | | if (unity.barcode.IsNullOrEmpty()) throw new Exception("条码不允许为空"); |
| | | |
| | | using (var cmd = new SqlCommand("[prc_pda_bar_cf_before]", conn)) |
| | | { |
| | | try |
| | | { |
| | | conn.Open(); |
| | | cmd.CommandType = CommandType.StoredProcedure; |
| | | SqlParameter[] parameters = |
| | | { |
| | | new("@outMsg", SqlDbType.NVarChar, 300), |
| | | new("@outSum", SqlDbType.NVarChar, 300), |
| | | new("@barcode_new", SqlDbType.NVarChar, 300), |
| | | new("@c_user", unity.userName), |
| | | new("@p_old_barcode", unity.barcode), |
| | | new("@p_qty", unity.CfNum), |
| | | |
| | | }; |
| | | parameters[0].Direction = ParameterDirection.Output; |
| | | parameters[1].Direction = ParameterDirection.Output; |
| | | parameters[2].Direction = ParameterDirection.Output; |
| | | |
| | | foreach (var parameter in parameters) |
| | | cmd.Parameters.Add(parameter); |
| | | cmd.ExecuteNonQuery(); |
| | | _strMsg = parameters[0].Value.ToString(); |
| | | _intSum = parameters[1].Value.ToString(); |
| | | _cfBar = parameters[2].Value.ToString(); |
| | | |
| | | |
| | | var result = Convert.ToInt32(_intSum); |
| | | if (result <= 0) throw new Exception(_strMsg); |
| | | |
| | | var dto = new ProductionPickDto |
| | | { |
| | | barcode = unity.barcode,//原条码 |
| | | cfBarcode = _cfBar//拆分后条码 |
| | | }; |
| | | return dto; |
| | | |
| | | //var result = Convert.ToInt32(_intSum); |
| | | //if (result <= 0) throw new Exception(_strMsg); |
| | | |
| | | //return _strMsg; |
| | | |
| | | //return 0; |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception(ex.Message); |
| | | } |
| | | finally |
| | | { |
| | | conn.Close(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | using Masuit.Tools.Models; |
| | | using Masuit.Tools; |
| | | using Masuit.Tools.Models; |
| | | using NewPdaSqlServer.DB; |
| | | using NewPdaSqlServer.Dto.service; |
| | | using NewPdaSqlServer.entity; |
| | |
| | | using NewPdaSqlServer.util; |
| | | using Newtonsoft.Json; |
| | | using SqlSugar; |
| | | using System.Data; |
| | | using System.Data.SqlClient; |
| | | using static Microsoft.EntityFrameworkCore.DbLoggerCategory; |
| | | |
| | | namespace NewPdaSqlServer.service.Warehouse; |
| | |
| | | public class MesInvItemInCDetailsManager : Repository<MesInvItemInCDetails> |
| | | { |
| | | //当前类已经继承了 Repository 增、删、查、改的方法 |
| | | |
| | | |
| | | // public ItemInBaseModel SaveBarCodes(WarehouseQuery entity) |
| | | // { |
| | | // var _strMsg = ""; |
| | | // var _intSum = ""; |
| | | // using (var conn = new SqlConnection(DbHelperSQL.strConn)) |
| | | // { |
| | | // if (entity.userName.IsNullOrEmpty()) throw new Exception("用户名不允许为空"); |
| | | // if (entity.sectionCode.IsNullOrEmpty()) throw new Exception("库位编号不允许为空"); |
| | | // if (entity.barcode.IsNullOrEmpty()) throw new Exception("条码不允许为空"); |
| | | // if (entity.cgrkType.IsNullOrEmpty()) throw new Exception("采购入库类型不允许为空"); |
| | | |
| | | // using (var cmd = new SqlCommand("[prc_pda_inv_cgrk]", conn)) |
| | | // { |
| | | // try |
| | | // { |
| | | // conn.Open(); |
| | | // cmd.CommandType = CommandType.StoredProcedure; |
| | | // SqlParameter[] parameters = |
| | | // { |
| | | // new("@pi_user", SqlDbType.NVarChar, 100) { Value = entity.userName }, |
| | | // new("@pi_barcode", SqlDbType.NVarChar, 100) { Value = entity.barcode }, |
| | | // new("@pi_cgrkType", SqlDbType.NVarChar, 30) { Value = entity.cgrkType }, |
| | | // new("@po_outMsg", SqlDbType.NVarChar, 300), |
| | | // new("@po_outSum", SqlDbType.NVarChar, 300) |
| | | //}; |
| | | |
| | | // foreach (var parameter in parameters) |
| | | // cmd.Parameters.Add(parameter); |
| | | // cmd.ExecuteNonQuery(); |
| | | // _strMsg = parameters[4].Value.ToString(); |
| | | // _intSum = parameters[5].Value.ToString(); |
| | | |
| | | // var result = Convert.ToInt32(_intSum); |
| | | // if (result <= 0) throw new Exception(_strMsg); |
| | | |
| | | // return _strMsg; |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // throw new Exception(ex.Message); |
| | | // } |
| | | // finally |
| | | // { |
| | | // conn.Close(); |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | public ItemInBaseModel SaveBarCodes(WarehouseQuery entity) |
| | | { |
| | |
| | | throw new Exception("此条码不属于到货条码,无法用采购入库!"); |
| | | |
| | | var inventory = Db.Queryable<MesInvItemArn>() |
| | | .Where(it => it.BillNo == itemBarcodeDetails.BillNo && it.Fstatus == true ) |
| | | .Where(it => it.BillNo == itemBarcodeDetails.BillNo && it.Fstatus == true) |
| | | .First(); |
| | | |
| | | if (inventory == null) |
| | |
| | | var sql1 = @"SELECT *FROM v_dhmx WHERE dhmxGuid = @dhmxGuid "; |
| | | var dhjymx = Db.Ado.SqlQuery<vDhmx>(sql1, sqlParams).First(); |
| | | //判定检验能否入库 |
| | | if (dhjymx.CanStore!= 1) |
| | | if (dhjymx.CanStore != 1) |
| | | { |
| | | throw new Exception($"该条码对应的收料单检验结果:【{dhjymx.InspectionResult}】,判定结果:【{dhjymx.JudgmentResult}】,处理意见:【{dhjymx.HandlingSuggestion}】,无法入库"); |
| | | } |
| | |
| | | |
| | | result.itemDetail = mesItems; |
| | | |
| | | result.ItemInDetails = db.Queryable<MesInvItemInCItems,MesItems>( |
| | | result.ItemInDetails = db.Queryable<MesInvItemInCItems, MesItems>( |
| | | (a, b) => new JoinQueryInfos( |
| | | JoinType.Left, |
| | | a.ItemId == b.ItemId) |
| | | ) |
| | | .Where(a => a.ItemInId == cId && a.ItemId == itemBarcodeDetails.ItemId) |
| | | .Select<dynamic>((a, b) => new |
| | | .Select<dynamic>((a, b) => new |
| | | { |
| | | ItemNo = b.ItemNo, |
| | | ItemName = b.ItemName, |
| | |
| | | |
| | | var purchaseInventory = getPurchaseInventory(entity); |
| | | |
| | | |
| | | |
| | | //result.ItemInDetails = purchaseInventory.ItemInDetails; |
| | | //result.InvItemInCDetails = purchaseInventory.InvItemInCDetails; |
| | | |
| | |
| | | // public List<dynamic> oldBarInfo { get; set; } |
| | | // } |
| | | |
| | | public dynamic getCfBeforeInfo(dynamic query) // 使用具体类型替代dynamic |
| | | { |
| | | // 参数校验 |
| | | if (string.IsNullOrEmpty(query?.cfBarcode)) |
| | | throw new ArgumentException("拆分条码不能为空"); |
| | | if (string.IsNullOrEmpty(query?.barcode)) |
| | | throw new ArgumentException("原始条码不能为空"); |
| | | |
| | | } |
| | | // 使用强类型参数 |
| | | var sqlParams = new List<SugarParameter> { |
| | | new("@cfBar", query.cfBarcode.Trim()), |
| | | new("@oldBar", query.barcode.Trim()) |
| | | }; |
| | | |
| | | var sql = @"SELECT TOP 1 C.ITEM_NO,C.item_name,C.item_model,B.OLDQTY as QUANTITY,B.CREATE_DATE, '拆分条码' AS BarType,B.ITEM_BARCODE,GETDATE() as print_date |
| | | FROM MES_INV_ITEM_BARCODES B |
| | | LEFT JOIN MES_ITEMS C ON C.item_id = B.ITEM_ID |
| | | WHERE B.ITEM_BARCODE = @cfBar |
| | | |
| | | UNION ALL |
| | | |
| | | SELECT TOP 1 C.ITEM_NO,C.item_name,C.item_model,B.QUANTITY as QUANTITY,B.CREATE_DATE, '原始条码' AS BarType,B.ITEM_BARCODE,GETDATE() as print_date |
| | | FROM MES_INV_ITEM_BARCODES B |
| | | LEFT JOIN MES_ITEMS C ON C.item_id = B.ITEM_ID |
| | | WHERE B.ITEM_BARCODE = @oldBar"; |
| | | |
| | | var mergedData = Db.Ado.SqlQuery<dynamic>(sql, sqlParams); |
| | | |
| | | if (mergedData.Count < 2) throw new Exception("条码信息存在异常,请联系管理员!"); |
| | | |
| | | return mergedData; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |