智云SRM-WEBAPI(目前客户通用API)
yusijie
2024-09-24 c7a507c5d77652d5ceb722ff032f68514d369deb
WebAPI/Controllers/BarCodeController.cs
@@ -23,7 +23,7 @@
    {
        private JsonResult objJsonResult = new JsonResult();
        private json objjson = new json();
        public new ClsCNSRM oCn = new ClsCNSRM();
        public new ClsCN oCn = new ClsCN();
        //获取系统参数
        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
        public T ScriptDeserialize<T>(string strJson)
@@ -47,7 +47,7 @@
            string msg1 = _value.ToString();
            try
            {
                SQLHelper.ClsCNSRM oCn = new SQLHelper.ClsCNSRM();
                SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
                oCn.RunProc("exec H_p_SRM_BarCodeBill_PrintQty '" + msg1 + "'");
                objJsonResult.code = "0";
                objJsonResult.count = 0;
@@ -132,7 +132,7 @@
                string WeiShu = ""; //尾数
                //string sKFDate = DateTime.Now.ToString("yyyy-MM-dd");
                DataSet Ds;
                SQLHelper.ClsCNSRM oCn = new SQLHelper.ClsCNSRM();
                SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
                foreach (Model.ClsGy_MaterialList_WMS_Model oItemSub in ls)
                {
                    if (ClsPub.isLong(oItemSub.HMaterID) != 0)
@@ -339,7 +339,7 @@
                string WeiShu = ""; //尾数
                //string sKFDate = DateTime.Now.ToString("yyyy-MM-dd");
                DataSet Ds;
                SQLHelper.ClsCNSRM oCn = new SQLHelper.ClsCNSRM();
                SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
                Ds = oCn.RunProcReturn("exec GetLSH '" + DateTime.Today + "'", "GetLSH");
                LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                foreach (Model.ClsGy_MaterialList_WMS_Model oItemSub in ls)
@@ -551,7 +551,7 @@
                string sDay = "";            //日
                string WeiShu = ""; //尾数
                DataSet Ds;
                SQLHelper.ClsCNSRM oCn = new SQLHelper.ClsCNSRM();
                SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
                Ds = oCn.RunProcReturn("exec GetLSH '" + DateTime.Today + "'", "GetLSH");
                LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                foreach (Model.ClsGy_MaterialList_WMS_Model oItemSub in ls)
@@ -585,7 +585,7 @@
                                TM = "0" + TM;
                            }
                            //TM = "B" + TM;
                            TM = "SRM" + "B" + TM;
                            TM = "SRM" + "B" + TM;
                            if (HSumQty - HMinQty > 0)
                            {
@@ -604,6 +604,13 @@
                                }
                                HMinQty = HSumQty;
                            }
                            if (FCusName.Contains("添康科技"))
                            {
                                //外箱批次条码规则:SRMB+组织+料号+批次+;+数量
                                TM = "SRMB" + "100" + oItemSub.HMaterNumber + oItemSub.HBatchNo + ";" + HMinQty;
                            }
                            Model.ClsGy_BarCodeBill_WMS_Model bar = new Model.ClsGy_BarCodeBill_WMS_Model();
                            bar.HBarCode = TM;
                            bar.HMaterID = oItemSub.HMaterID;
@@ -632,6 +639,7 @@
                            bar.HSupBatchNo = oItemSub.HSupBatchNo;
                            bar.HSupMaterNumber = oItemSub.HSupMaterNumber;
                            bar.HISKFPERIOD = oItemSub.HISKFPERIOD;
                            bar.HMaterNumber = oItemSub.HMaterNumber;
                            ls2.Add(bar);
                        }
                    }
@@ -697,8 +705,19 @@
                            {
                                TM2 = "0" + TM2;
                            }
                            bar2.HMaterID = oItemSub2.HMaterID;
                            bar2.HBarCode = oItemSub2.HBarCode + "-" + TM2;
                            if (FCusName.Contains("添康科技"))
                            {
                                //内箱批次条码规则:SRM+组织+料号+批次+;+数量
                                TM2 = "SRM" + "100" + oItemSub2.HMaterNumber + oItemSub2.HBatchNo + ";" + HWXQty;
                                bar2.HBarCode = TM2;
                            }
                            else
                            {
                                bar2.HBarCode = oItemSub2.HBarCode + "-" + TM2;
                            }
                            bar2.HMaterID = oItemSub2.HMaterID;
                            bar2.HUnitID = oItemSub2.HUnitID;
                            bar2.HQty = HWXQty;
                            bar2.HBatchNo = DBUtility.ClsPub.isStrNull(oItemSub2.HBatchNo);
@@ -779,6 +798,12 @@
                            HBarCode = $"{oItemSub.HMaterID}";
                            HBarCodeType = "品种码_外箱";
                        }
                        if (FCusName.Contains("添康科技"))
                        {
                            //HBarCodeType = "批次条码";
                        }
                        string sql = "insert into Gy_BarCodeBill (HInterID,HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HKFDate,HKFPeriod,HKFDQDate" +
                                    ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HEndQty,HSupflag" +
                                    ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HMTONO,HSupBatchNo,HSupMaterNumber,HProduceDate,HExpiryDate,HISKFPERIOD " +
@@ -823,6 +848,12 @@
                            HBarCode = $"{oItemSub.HMaterID}";
                            HBarCodeType = "品种码";
                        }
                        if (FCusName.Contains("添康科技"))
                        {
                            //HBarCodeType = "批次条码";
                        }
                        string sql = "insert into Gy_BarCodeBill (HInterID,HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HKFDate,HKFPeriod,HKFDQDate" +
                                    ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HEndQty,HSupflag" +
                                    ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HMTONO ,HSupBatchNo,HSupMaterNumber,HProduceDate,HExpiryDate,HISKFPERIOD" +
@@ -927,7 +958,7 @@
                string sPeriod = "";        //月
                string sDay = "";            //日
                DataSet Ds;
                SQLHelper.ClsCNSRM oCn = new SQLHelper.ClsCNSRM();
                SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
                Ds = oCn.RunProcReturn("exec GetLSH '" + DateTime.Today + "'", "GetLSH");
                LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                foreach (Model.ClsGy_MaterialList_WMS_Model oItemSub in ls)
@@ -1375,7 +1406,7 @@
            {
                string VsWhere = "";
                string PcWhere = "";
                SQLHelper.ClsCNSRM oCn = new SQLHelper.ClsCNSRM();
                SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
                DataSet ds;
                string sql = " Where hsupid in (select HSupID from h_v_Gy_UserSupplierList where 用户=''" + HSupNo.Trim() + "'') " + sqlWhere;
@@ -1395,7 +1426,7 @@
                {
                    objjson.code = "0";
                    objjson.count = 0;
                    objjson.Message = "获取失败";
                    objjson.Message = "无相关条码信息!";
                    objjson.data = null;
                    return objjson;
                }
@@ -1596,7 +1627,7 @@
                string sDay = "";            //日
                string WeiShu = ""; //尾数
                DataSet Ds;
                SQLHelper.ClsCNSRM oCn = new SQLHelper.ClsCNSRM();
                SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
                oCn.BeginTran();
                Ds = oCn.RunProcReturn("exec GetLSH '" + DateTime.Today + "'", "GetLSH");
                LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
@@ -1873,6 +1904,7 @@
                                        + "','" + HBatchNo + "','" + SubModel.Count + "','" + count + "'," + HSupID + "," + HGroupID + ",'" + ClsPub.CurUserName + "','" + DateTime.Today + "'," + HPrintQty + ",'" + HWei + "',1"
                                        + "," + HSourceInterID + "," + HSourceEntryID + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HMTONO + "','"
                                        + HKFDate + "','" + HKFDQDate + "'," + HISKFPERIOD + ")";
                            LogService.Write("生成外箱条码: " + sql);
                            oCn.RunProc(sql);
                            oCn.RunProc("exec setLSH '" + DateTime.Today + "'");
                            count++;
@@ -1919,6 +1951,7 @@
                                      + "','" + HBatchNo + "','" + SubModel.Count + "','" + _count + "'," + HSupID + "," + HGroupID + ",'" + ClsPub.CurUserName + "','" + DateTime.Today + "'," + HPrintQty + ",'" + HWei + "',1"
                                      + "," + HSourceInterID + "," + HSourceEntryID + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HMTONO + "','" 
                                      + HKFDate + "','" + HKFDQDate + "'," + HISKFPERIOD + ")";
                            LogService.Write("生成内箱条码: "+ sql);
                            oCn.RunProc(sql);
                            _count++;
                        }
@@ -1951,6 +1984,7 @@
            }
            catch (Exception e)
            {
                LogService.Write("生成条码发生错误: " + e);
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "" + e.Message + DBUtility.ClsPub.sExeReturnInfo;
@@ -2105,11 +2139,20 @@
                            oCN.RunProc($"update Cg_POOrderBillSub set HBarcodeCount -= {dr["HQty"]} where  HInterID ={dr["HSourceInterID"]} and  HEntryID ={dr["HSourceEntryID"]}");
                        //反写打印数量到委外订单
                        if (dr["HBarCodeType"].ToString() == "箱号内条码" && dr["HSourceBillType"].ToString() == "1601")
                            oCN.RunProc($"update WW_EntrustOrderBillSub set HBarcodeCount -= {dr["HQty"]} where  HInterID ={dr["HSourceInterID"]} and  HEntryID ={dr["HSourceEntryID"]}");
                        //反写打印数量到送货单 (不需要反写 送货单直接是关联查询取的数量 没有在源单上做保存)
                        if (dr["HSourceBillType"].ToString() == "1103")
                            oCN.RunProc("Delete From Gy_BarCodeBill where HItemID in(" + dr["HItemID"] + ") ");
                        //oCN.RunProc($"update WW_EntrustOrderBillSub set HBarcodeCount -= {dr["HQty"]} where  HInterID ={dr["HSourceInterID"]} and  HEntryID ={dr["HSourceEntryID"]}");
                            oCN.RunProc($"update WW_EntrustOrderBillSub set HBarcodeCount -= {dr["HQty"]} where  HInterID ={dr["HSourceInterID"]} and  HEntryID ={dr["HSourceEntryID"]}");
                        if (FCusName.Contains("添康科技"))
                        {
                            _HBarCodeType = "箱号内条码";
                            if (dr["HSourceBillType"].ToString() == "1103" && dr["HBarCodeType"].ToString() == _HBarCodeType)
                                oCN.RunProc($"update Cg_POInStockBillSub set HRelationBarCodeQty -= {dr["HQty"]} where  HInterID ={dr["HSourceInterID"]} and  HEntryID ={dr["HSourceEntryID"]}");
                        }
                        else
                        {
                            //反写打印数量到送货单 (不需要反写 送货单直接是关联查询取的数量 没有在源单上做保存)
                            if (dr["HSourceBillType"].ToString() == "1103")
                                oCN.RunProc("Delete From Gy_BarCodeBill where HItemID in(" + dr["HItemID"] + ") ");
                            //oCN.RunProc($"update WW_EntrustOrderBillSub set HBarcodeCount -= {dr["HQty"]} where  HInterID ={dr["HSourceInterID"]} and  HEntryID ={dr["HSourceEntryID"]}");
                        }
                    }
                }
                oCN.RunProc("Delete From Gy_BarCodeBill where HItemID in(" + HInterID + ") ");