llj
2025-09-09 02789cadcfafd3cb02f4bee8b2fbec32a7c72310
条码打印补充
3个文件已修改
124 ■■■■ 已修改文件
WebAPI/Controllers/MaterialHandingController.cs 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/SRM_MaterialBarCodeBillController.cs 111 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/WebAPI.csproj 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/MaterialHandingController.cs
@@ -263,13 +263,17 @@
            {
                //ds1获取的sql后期记得改回供应商,修改人->供应商
                var ds1 = oCN.RunProcReturn("select * from h_v_Gy_UserMaterRelationEdit where 物料代码='" + HMaterID + "'" + "and 修改人='" + user + "'", "h_v_Gy_UserMaterRelationEdit");
                var ds = oCN.RunProcReturn("select * from Gy_Material where HNumber='" + HMaterID+ "'", "Gy_Material");
                var ds = oCN.RunProcReturn("select * from Gy_Material where HNumber='" + HMaterID+ "'"+ " and HUSEORGID="+"'"+ OrganizationID+"'", "Gy_Material");
                if(ds.Tables[0].Rows.Count == 0)
                {
                    return 2;
                }
                if (param == 0)
                {
                    if (ds1.Tables[0].Rows.Count > 0)
                    if (ds1.Tables[0].Rows.Count > 0)//物料重复,弹出询问
                    {
                        return 1;
                    }
                    else
                    {
WebAPI/Controllers/SRM_MaterialBarCodeBillController.cs
@@ -165,8 +165,14 @@
                LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                #endregion
                //// 存储生成的条码列表
                List<string> generatedBarcodes = new List<string>();
                var biaoqianCount = 0;
                foreach (Model.ClsGy_MaterialBarCodeBillModel oItemSub in ls)
                {
                    biaoqianzhangshu = ls[biaoqianCount].biaoqianzhangshu;
                    biaoqianCount++;
                    //数量为0 跳过
                    if (oItemSub.HQty == 0 || oItemSub.HMinQty == 0 )
                        continue;
@@ -187,25 +193,6 @@
                        return objJsonResult;
                    }
                    string sql = "";
                    //校验批号 和 生产日期
                    //string sql = $"select top 1 HKFDate from Gy_BarCodeBill where HSupID = '{oItemSub.HSupID}' and HBatchNo = '{HBatchNo.TrimStart().TrimEnd()}' and HMaterID ={oItemSub.HMaterID} and isnull(HKFDate, '') <> ''";
                    //LogService.Write($"sql:{sql}");
                    //DataTable dt = oCn.RunProcReturn(sql, "tables").Tables[0];
                    //if (dt.Rows.Count > 0)
                    //{
                    //    LogService.Write($"HKFDate:{dt.Rows[0][0]}");
                    //    sql = $"select DATEDIFF(D,{dt.Rows[0][0]},{HKFDate})";
                    //    DataSet ds = oCn.RunProcReturn(sql, "tables2");
                    //    LogService.Write($"DATEDIFF:{Convert.ToInt32(ds.Tables[0].Rows[0][0])}");
                    //    if (ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0][0]) != 0)
                    //    {
                    //        objJsonResult.code = "0";
                    //        objJsonResult.count = 0;
                    //        objJsonResult.Message = $"物料编码{oItemSub.HMaterNumber},批号{oItemSub.HBatchNo.TrimStart().TrimEnd()},生产日期为{dt.Rows[0][0]},请核对";
                    //        objJsonResult.data = null;
                    //        return objJsonResult;
                    //    }
                    //}
                    if (ClsPub.isLong(oItemSub.HMaterID) != 0)
                    {
@@ -217,9 +204,15 @@
                        // HSumQty = ClsPub.isDoule(oItemSub.HQty);  //产品数量
                       for (int i = 0; i < biaoqianzhangshu; i++)
                        {
                            ///供应商名称+@+物料代码+@+物料简称+@+数量+@+日期+@+流水号
                            double currentQty = (i == biaoqianzhangshu - 1 && (HQty % HMinQty != 0))
                              ? (HQty % HMinQty)
                              : HMinQty;
                            ///供应商名称+@+物料代码+@+物料简称+@+数量+@条码数+@+日期+@+流水号
                            LSH += 1;
                            TM = $"{oItemSub.HSupName}@{oItemSub.HMaterID}@{oItemSub.HMaterName}@{oItemSub.biaoqianzhangshu}@{HKFDate_1}@{LSH}";
                            TM = $"{oItemSub.HSupName}@{oItemSub.HMaterID}@{oItemSub.HMaterName}@{currentQty}@{HKFDate_1}@{LSH}";
                            //TM = $"{oItemSub.HSupName}@{oItemSub.HMaterID}@{oItemSub.HMaterName}@{oItemSub.biaoqianzhangshu}@{HKFDate_1}@{LSH}";
                            // 添加到生成的条码列表
                            generatedBarcodes.Add(TM);
                            Model.ClsGy_BarCodeBill_WMS_Model bar = new Model.ClsGy_BarCodeBill_WMS_Model();
                           // var HBarCode_verify = TM.Split('@'); //校验条码信息
@@ -261,7 +254,13 @@
                        }
                }
                oCn.Commit();
                // 返回生成的条码列表
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "生成条码成功!";
                objJsonResult.data = generatedBarcodes; // 返回生成的条码列表
                WebAPIController.Add_Log("条码下推", UserName, "生成条码");
                return objJsonResult;
            }
            catch (Exception e)
            {
@@ -273,19 +272,14 @@
                return objJsonResult;
            }
            objJsonResult.code = "0";
            objJsonResult.count = 1;
            objJsonResult.Message = "生成条码成功!";
            WebAPIController.Add_Log("条码下推", UserName, "生成条码");
            objJsonResult.data = null;
            return objJsonResult;
        }
        #endregion
        #region 条码列表
        [Route("showHBarCodeBillDetail")]
        [HttpGet]
        public object showHBarCodeBillDetail(string sMsg,string Organization)
        public object showHBarCodeBillDetail(string sMsg,string user)
        {
            try
            {
@@ -331,6 +325,65 @@
        }
        #endregion
        #region 根据条码获取条码详情
        [Route("GetBarcodeDetails")]
        [HttpGet]
        public object GetBarcodeDetails(string barcodes)
        {
            try
            {
                if (string.IsNullOrEmpty(barcodes))
                {
                    objjson.code = "0";
                    objjson.count = 0;
                    objjson.Message = "条码参数不能为空";
                    objjson.data = null;
                    return objjson;
                }
                // 将逗号分隔的条码转换为SQL IN查询条件
                var barcodeList = barcodes.Split(',');
                // 构建IN子句,为每个条码添加单引号
                var inValues = new List<string>();
                foreach (var barcode in barcodeList)
                {
                    inValues.Add("'" + barcode.Replace("'", "''") + "'"); // 处理单引号转义
                }
                string inClause = string.Join(",", inValues);
                string sql = $"SELECT * FROM h_v_Gy_UserMaterRelationPrint WHERE HBarCode IN ({inClause})";
                // 直接执行SQL查询
                DataSet ds = oCn.RunProcReturn(sql, "h_v_Gy_UserMaterRelationPrint");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objjson.code = "0";
                    objjson.count = 0;
                    objjson.Message = "未找到相关条码信息";
                    objjson.data = null;
                    return objjson;
                }
                objjson.code = "0";
                objjson.count = ds.Tables[0].Rows.Count;
                objjson.Message = "获取成功";
                objjson.data = ds.Tables[0];
                return objjson;
            }
            catch (Exception e)
            {
                objjson.code = "0";
                objjson.count = 0;
                objjson.Message = "获取条码详情失败:" + e.Message;
                objjson.data = null;
                return objjson;
            }
        }
        #endregion
    }
}
WebAPI/WebAPI.csproj
@@ -263,8 +263,6 @@
    <None Include="Properties\PublishProfiles\SRMAPI.pubxml" />
    <None Include="Properties\PublishProfiles\WEBAPI.pubxml" />
    <None Include="Properties\PublishProfiles\WEBAPIConfig.pubxml" />
    <Content Include="Views\_ViewStart.cshtml" />
    <Content Include="Views\Shared\_Layout.cshtml" />
    <Content Include="Views\web.config" />
    <None Include="Web.Debug.config">
      <DependentUpon>Web.config</DependentUpon>
@@ -277,6 +275,7 @@
    <Folder Include="App_Data\" />
    <Folder Include="Data\" />
    <Folder Include="Views\MaterialHanding\" />
    <Folder Include="Views\Shared\" />
    <Folder Include="Views\SRM_MaterialBarCodeBill\" />
  </ItemGroup>
  <PropertyGroup>