jinghz@oceic.com
2023-07-03 a7290cd76e9fc87988ccfde74194fadf7b46a7df
WebAPI/Controllers/²©ÈÕ×Ô¶¯É¨ÂëÏß/ScanlineAPIController.cs
@@ -9,6 +9,7 @@
using System.Net.Http;
using System.Web.Http;
using System.Web.Script.Serialization;
using ViewAPI;
using WebAPI.Models;
namespace WebAPI.Controllers.博日自动扫码线
@@ -44,9 +45,9 @@
                    sPeriod = sPeriod.Substring(sPeriod.Length - 2, 2);
                    string sDay = "0" + ClsPub.isDate(sDate).Day.ToString();
                    sDay = sDay.Substring(sDay.Length - 2, 2);
                    string  sTMNumber ="ZX"+ sYear + sPeriod + sDay;
                    string sTMNumber = "ZX" + sYear + sPeriod + sDay;
                    ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                    int LSH = ClsPub.isInt(ds.Tables[0].Rows[0][0])+1;  //流水号加1
                    int LSH = ClsPub.isInt(ds.Tables[0].Rows[0][0]) + 1;  //流水号加1
                    string TM = sTMNumber + LSH;
                    jsn.packagebarcode = TM;
                    oCN.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
@@ -54,14 +55,15 @@
                }
                objJsonResult.status = 0;
                objJsonResult.msg = "查询数据成功!";
                objJsonResult.data =objJsonResult.data;
                objJsonResult.data = objJsonResult.data;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.status =-1;
                LogService.Write("错误:" + e.Message.ToString());
                objJsonResult.status = -1;
                objJsonResult.msg = "生成箱条码失败!";
                objJsonResult.data =null;
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
@@ -74,43 +76,48 @@
        {
            try
            {
                Log.LogInfo(msg.ToString()); //记录提交数据
                JavaScriptSerializer js = new JavaScriptSerializer();   //实例化一个能够序列化数据的类
                ScanLineCode list = js.Deserialize<ScanLineCode>(msg.ToString());    //将json数据转化为对象类型并赋值给list
                if (list.billno != "" && list.billno != null)  //任务单号,非必须,非空则校验barcodes里barcode是否由此任务单制作生成的
                {
                    ds = oCN.RunProcReturn("Select HBarCode barcode from Gy_BarCodeBill where HSourceBillNo='" + list.billno.ToString().Trim()+"'  Order by HItemID ", "Gy_BarCodeBill");
                    ds = oCN.RunProcReturn("Select HBarCode barcode,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType from Gy_BarCodeBill where HSourceBillNo='" + list.billno.ToString().Trim() + "'  Order by HItemID ", "Gy_BarCodeBill");
                    if (ds == null || ds.Tables[0].Rows.Count == 0)
                    {
                        LogService.Write("当前订单无绑定条码");
                        objJsonResult.status = -1;
                        objJsonResult.msg = "当前订单无绑定条码!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    List<string> NameList = (from r in ds.Tables[0].AsEnumerable() select r.Field<string>("barcode")).ToList();
                    List<string> NameList1= list.barcodes.Select(t => t.barcode).ToList();
                    List<string> NameList1 = list.barcodes.Select(t => t.barcode).ToList();
                    var strList = NameList1.Except(NameList).ToList();  //判断提交数据中条码是否存在于订单中
                    if (strList.Count > 0)
                    if (strList.Count > 0)
                    {
                        string Str=String.Join(",", strList.ToArray());
                        string Str = String.Join(",", strList.ToArray());
                        LogService.Write("条码:" + Str.ToString() + " ä¸åŒ…含在订单:" + list.billno + "中!");
                        objJsonResult.status = -1;
                        objJsonResult.msg = "条码:"+ Str.ToString()+" ä¸åŒ…含在订单:"+list.billno+"中!";
                        objJsonResult.msg = "条码:" + Str.ToString() + " ä¸åŒ…含在订单:" + list.billno + "中!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    }
                }
                DLL.ClsSc_PackUnionBill oBill = new DLL.ClsSc_PackUnionBill();
                //判断箱码是否存在
                bool IsBarCodePack = oBill.IsBarCodePack(list.packagebarcode);
                if (IsBarCodePack == false)
                if (IsBarCodePack == false)
                {
                    LogService.Write($"箱码:{list.packagebarcode}已存在,不能重复绑定!");
                    objJsonResult.status = -1;
                    objJsonResult.msg = "箱码已存在,不能重复绑定!";
                    objJsonResult.msg = $"箱码:{list.packagebarcode}已存在,不能重复绑定!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = oCN.RunProcReturn("Select * from Gy_BarCodeBill where HBarCode='" + list.packagebarcode.ToString().Trim() + "' and HStopflag='1'", "Gy_BarCodeBill");
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    LogService.Write("此箱条码已作废");
                    objJsonResult.status = -1;
                    objJsonResult.msg = "此箱条码已作废";
                    objJsonResult.data = null;
@@ -122,7 +129,7 @@
                oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month);
                oItem.HBillType = "3783";
                oItem.HBillSubType = "3783";
                oItem.HDate= DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
                oItem.HDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
                oItem.HBillNo = DBUtility.ClsPub.CreateBillCode(oItem.HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
                oItem.HBillStatus = 1;
                oItem.HCheckItemNowID = 0;
@@ -144,32 +151,33 @@
                oItem.HDeleteDate = "";
                oItem.HICMOInterID = 0;
                oItem.HICMOBillNo = "";
                oItem.HBarCode_Pack= list.packagebarcode;
                oItem.HBarCode_Pack = list.packagebarcode;
                oItem.HMaterID = 0;
                oItem.HUnitID = 0;
                oItem.HUseFlag =false;   //有效状态
                oItem.HUseFlag = false;   //有效状态
                oBill.omodel = oItem;
                for (int i = 0; i < list.barcodes.Count; i++)
                {
                    //判断条码是否存在
                    bool IsBarCode = oBill.IsBarCodePack(list.barcodes[i].barcode);
                    if (IsBarCodePack == false)
                    bool IsBarCode = oBill.IsBarCode(list.barcodes[i].barcode);
                    if (IsBarCode == false)
                    {
                        DataTable dt = oCN.RunProcReturn("Select HBarCode_Pack from Sc_PackUnionBillSub Where  HBarCode='" + list.barcodes[i].barcode + "'", "Sc_PackUnionBillSub").Tables[0];
                        objJsonResult.status = -1;
                        objJsonResult.msg = "条码已存在,不能重复绑定!";
                        objJsonResult.msg = $"条码:{list.barcodes[i].barcode},已存在箱码:{dt.Rows[0]["HBarCode_Pack"]}中,本次绑定箱码为:{list.packagebarcode},绑定失败,不能重复绑定!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    Models.ClsSc_PackUnionBillSub oItemSub = new ClsSc_PackUnionBillSub();
                    ds0 = oCN.RunProcReturn("Select HBarCode,HMaterID,HUnitID,HQty,HSourceID,HGroupID,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType from Gy_BarCodeBill where HSourceBillNo='" + list.billno.ToString().Trim() + "' and HBarCode='" + list.barcodes[i].barcode + "'  Order by HItemID ", "Gy_BarCodeBill");
                    oItemSub.HEntryID = i+1;
                    oItemSub.HEntryID = i + 1;
                    oItemSub.HMaterID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HMaterID"].ToString());
                    oItemSub.HUnitID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HUnitID"].ToString());
                    oItemSub.HQty = DBUtility.ClsPub.isDoule(ds0.Tables[0].Rows[0]["HQty"].ToString());
                    oItemSub.HSourceID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HSourceID"].ToString());
                    oItemSub.HEquipID = 0;
                    oItemSub.HGroupID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HGroupID"].ToString());
                    oItemSub.HWorkerID = 0;
                    oItemSub.HWorkerID = 0;
                    oItemSub.HBarCode = list.barcodes[i].barcode;
                    oItemSub.HBarCode_Pack = list.packagebarcode;
                    oItemSub.HCloseMan = "";
@@ -197,6 +205,8 @@
                }
                if (bResult)
                {
                    LogService.Write("提交成功箱条码:" + list.packagebarcode);
                    Log.LogSaveInfo("提交成功箱条码:" + list.packagebarcode); //记录提交数据
                    objJsonResult.status = 0;
                    objJsonResult.msg = "success";
                    objJsonResult.data = null;
@@ -204,6 +214,7 @@
                }
                else
                {
                    LogService.Write("保存失败:" +DBUtility.ClsPub.sExeReturnInfo);
                    objJsonResult.status = -1;
                    objJsonResult.msg = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo;
                    objJsonResult.data = null;
@@ -212,7 +223,8 @@
            }
            catch (Exception e)
            {
                objJsonResult.status =-1;
                LogService.Write("箱条码绑定关系提交接口 æŠ›å‡ºå¼‚常" + e.Message.ToString());
                objJsonResult.status = -1;
                objJsonResult.msg = e.Message;
                objJsonResult.data = null;
                return objJsonResult;
@@ -227,7 +239,17 @@
        {
            try
            {
                ds = oCN.RunProcReturn("Select * from Gy_BarCodeBill where HBarCode='" + packagebarcode.ToString().Trim() + "'", "Gy_BarCodeBill");
                //判断是否入库
                ds = oCN.RunProcReturn("select * from Sc_ScanLineInStock where HBarCode_Pack='" + packagebarcode + "'", "Sc_ScanLineInStock");
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    objJsonResult.status = -1;
                    objJsonResult.msg = "该箱条码已入库不允许取消!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = oCN.RunProcReturn("Select 1 from Gy_BarCodeBill where HBarCode='" + packagebarcode.ToString().Trim() + "'", "Gy_BarCodeBill");
                if (ds == null && ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.status = -1;
@@ -235,8 +257,8 @@
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = oCN.RunProcReturn("Select * from Gy_BarCodeBill where HBarCode='" + packagebarcode.ToString().Trim() + "' and HStopflag='1'", "Gy_BarCodeBill");
                if (ds != null && ds.Tables[0].Rows.Count>0)
                ds = oCN.RunProcReturn("Select 1 from Gy_BarCodeBill where HBarCode='" + packagebarcode.ToString().Trim() + "' and HStopflag='1'", "Gy_BarCodeBill");
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    objJsonResult.status = -1;
                    objJsonResult.msg = "此箱条码已作废";
@@ -246,12 +268,14 @@
                //
                oCN.BeginTran();
                //删除SUM主表
                oCN.RunProc("Delete From Sc_PackUnionBillSub_Sum  where HBarCode_Pack='" + packagebarcode.ToString() + "'");
                //删除子表
                oCN.RunProc("Delete From Sc_PackUnionBillSub  where HBarCode_Pack='"+ packagebarcode.ToString() + "'");
                oCN.RunProc("Delete From Sc_PackUnionBillSub  where HBarCode_Pack='" + packagebarcode.ToString() + "'");
                //删除主表
                oCN.RunProc("Delete From Sc_PackUnionBillMain  where HBarCode_Pack='" + packagebarcode.ToString() + "'");
                //作废条码档案表
                oCN.RunProc("Update  Gy_BarCodeBill set HStopflag='1'  where HBarCode='"+ packagebarcode .ToString()+ "'");
                oCN.RunProc("Update  Gy_BarCodeBill set HStopflag='1'  where HBarCode='" + packagebarcode.ToString() + "'");
                oCN.Commit();
@@ -281,7 +305,7 @@
                //string aa=list.getWeek(Convert.ToDateTime(tim));
                string aa = list.GetCodeDateStr(Convert.ToDateTime(tim));
                objJsonResult.status = 0;
                objJsonResult.msg =aa.ToString();
                objJsonResult.msg = aa.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }