yxj
3 天以前 e9c383fe6a79fab1ef58107bda1b88808b5ad00c
WebAPI/Controllers/²Ö´æ¹ÜÀí/ÌõÂëÉú³É/Sc_BarCodeController.cs
@@ -163,7 +163,7 @@
        #region [通过源单类型查找不通单据信息]
        [Route("Sc_BarCode/ReportFromBillList")]
        [HttpGet]
        public object ReportFromBillList(int page, int limit, string sWhere,string HSouceBillType,string HOrgID)
        public object ReportFromBillList(int page, int limit, string sWhere, string HSouceBillType, string HOrgID)
        {
            oSystemParameter.ShowBill(ref DBUtility.ClsPub.sExeReturnInfo);
            List<object> columnNameList = new List<object>();
@@ -176,7 +176,7 @@
                string tabname = "";
                if (sWhere == null || sWhere.Equals(""))
                {
                    sWhere = " where 1=1 and HOrgID='"+HOrgID+"' ";
                    sWhere = " where 1=1 and HOrgID='" + HOrgID + "' ";
                }
                else
                {
@@ -185,8 +185,8 @@
                switch (HSouceBillType)
                {
                    case "生产订单":
                        tabname = "h_v_IFCLD_ICMOBillList_Source";
                        count = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IFCLD_ICMOBillList_Source "+sWhere+ " and ä»»åŠ¡æ•°é‡>isnull(入库数量,0)  and çŠ¶æ€<>'结案' order by å•据号", tabname).Tables[0].Rows.Count;
                        tabname = "h_v_IFCLD_ICMOBillList_Source";
                        count = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IFCLD_ICMOBillList_Source " + sWhere + " and ä»»åŠ¡æ•°é‡>isnull(入库数量,0)  and çŠ¶æ€<>'结案' order by å•据号", tabname).Tables[0].Rows.Count;
                        sql = string.Format(@"select * from(select row_number() over (order by å•据号) as HRowNumber,* from h_v_IFCLD_ICMOBillList_Source " + sWhere + " and ä»»åŠ¡æ•°é‡>isnull(入库数量,0)  and çŠ¶æ€<>'结案')   as A where HRowNumber >" + pageSize + " *(" + pageNum + "-1)");
                        break;
                    case "生产汇报单":
@@ -347,7 +347,7 @@
            List<object> ListRows = new List<object>();
            try
            {
                msg2 = msg2.Replace("\\", "");
                msg2 = msg2.Replace("\n", "");  //\n
                List<DBUtility.BillSelect> oList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<DBUtility.BillSelect>>(msg2);
@@ -360,7 +360,7 @@
                            //得到信息
                            ds = oCN.RunProcReturn("select * from h_v_IFCLD_ICMOList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_IFCLD_ICMOList");
                            //写入信息
                            ListRows.Add(HSourceOrderList(ds.Tables[0],ordrlist, HBarCodeType));
                            ListRows.Add(HSourceOrderList(ds.Tables[0], ordrlist, HBarCodeType));
                            break;
                        case "3711": //生产汇报单
                            //得到信息
@@ -393,7 +393,7 @@
                            ListRows.Add(HSourceOrderList1(ds.Tables[0], ordrlist, HBarCodeType, HSourceBillType));
                            break;
                        case "1202": //生产入库
                             //得到信息
                                     //得到信息
                            ds = oWebs.getDataSetBySQL("select * from h_v_IF_ProductInBillList_Source where HMainID=" + oSelectRow.BillMainID + " and HSubID=" + oSelectRow.BillSubID, "h_v_IF_ProductInBillList_Source", ref DBUtility.ClsPub.sExeReturnInfo);
                            //写入信息
                            ListRows.Add(Sub_WriteInForm_InOut(ds.Tables[0], ordrlist, HBarCodeType, HSourceBillType));
@@ -460,7 +460,7 @@
            return objJsonResult;
        }
        public object HSourceOrderList(DataTable dt, HSouceOrderList ordrlist,string HBarCodeType)
        public object HSourceOrderList(DataTable dt, HSouceOrderList ordrlist, string HBarCodeType)
        {
            oSystemParameter.ShowBill(ref DBUtility.ClsPub.sExeReturnInfo);
            for (int i = 0; i < dt.Rows.Count; i++)
@@ -514,7 +514,7 @@
                {
                    ordrlist.HMinQty = dt.Rows[i]["未生成条码数量"].ToString();
                }
                else if (HBarCodeType == "仪器外购件条码普通规则"|| HBarCodeType == "仪器成品条码规则"|| HBarCodeType == "试剂成品条码规则")
                else if (HBarCodeType == "仪器外购件条码普通规则" || HBarCodeType == "仪器成品条码规则" || HBarCodeType == "试剂成品条码规则")
                {
                    ordrlist.HMinQty = "1";
                }
@@ -526,7 +526,7 @@
            return ordrlist;
        }
        public object HSourceOrderList1(DataTable dt, HSouceOrderList ordrlist, string HBarCodeType,string HSourceBillType)
        public object HSourceOrderList1(DataTable dt, HSouceOrderList ordrlist, string HBarCodeType, string HSourceBillType)
        {
            oSystemParameter.ShowBill(ref DBUtility.ClsPub.sExeReturnInfo);
            for (int i = 0; i < dt.Rows.Count; i++)
@@ -553,7 +553,7 @@
                ordrlist.HRemark = dt.Rows[i]["备注"].ToString();
                ordrlist.HMTONo = dt.Rows[i]["计划跟踪号"].ToString();
                if(HSourceBillType == "收料通知单")
                if (HSourceBillType == "收料通知单")
                {
                    if (oSystemParameter.omodel.WMS_CampanyName != "瑞与祺")
                    {
@@ -576,10 +576,10 @@
                    ordrlist.HMinQty = dt.Rows[i]["最小包装数"].ToString();
                }
                ordrlist.HMaker = ClsPub.CurUserName;
                if (HSourceBillType== "收料通知单"|| HSourceBillType== "采购订单"|| HSourceBillType=="委外订单"|| HSourceBillType== "采购入库单")
                if (HSourceBillType == "收料通知单" || HSourceBillType == "采购订单" || HSourceBillType == "委外订单" || HSourceBillType == "采购入库单")
                {
                    ordrlist.HInnerBillNo = dt.Rows[i]["内部采购订单号"].ToString();
                    ordrlist.HSupID= dt.Rows[i]["hsupid"].ToString();
                    ordrlist.HSupID = dt.Rows[i]["hsupid"].ToString();
                    ordrlist.HSupNumber = dt.Rows[i]["供应商代码"].ToString();
                    ordrlist.HSupName = dt.Rows[i]["供应商"].ToString();
                    if (HSourceBillType == "收料通知单")
@@ -602,7 +602,7 @@
                {
                    ordrlist.HCusID = dt.Rows[i]["HCusID"].ToString();
                    ordrlist.HCusNumber = dt.Rows[i]["客户代码"].ToString();
                    ordrlist.HCusName= dt.Rows[i]["客户"].ToString();
                    ordrlist.HCusName = dt.Rows[i]["客户"].ToString();
                }
                if (HSourceBillType == "其他入库单" || HSourceBillType == "领料出库单")
                {
@@ -613,7 +613,7 @@
                    ordrlist.HSPNumber = dt.Rows[i]["仓位代码"].ToString();
                    ordrlist.HSPName = dt.Rows[i]["仓位"].ToString();
                }
                if(HSourceBillType == "销售出库单")
                if (HSourceBillType == "销售出库单")
                {
                    ordrlist.HWhID = dt.Rows[i]["HWhID"].ToString();
                    ordrlist.HWhNumber = dt.Rows[i]["仓库代码"].ToString();
@@ -660,7 +660,7 @@
                ordrlist.HSPNumber = dt.Rows[i]["仓位代码"].ToString();
                ordrlist.HSPName = dt.Rows[i]["仓位"].ToString();
                ordrlist.HMTONo = dt.Rows[i]["计划跟踪号"].ToString();
                ordrlist.HDate = dt.Rows[i]["日期"].ToString();
                ordrlist.HDate = dt.Rows[i]["日期"].ToString();
                ordrlist.HShowDate = DateTime.Now.ToString();
            }
            return ordrlist;
@@ -707,7 +707,7 @@
                if (oDs == null && oDs.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "1";
                    objJsonResult.Message= "[0000-2-053]生成批次失败!";
                    objJsonResult.Message = "[0000-2-053]生成批次失败!";
                    return objJsonResult;
                }
                else if (DBUtility.ClsPub.isStrNull(oDs.Tables[0].Rows[0][0]) == "1")
@@ -724,7 +724,7 @@
            if (b == false)
            {
                objJsonResult.code = "1";
                objJsonResult.Message= "[3899-2-003]没有需要生成批次的明细行!";
                objJsonResult.Message = "[3899-2-003]没有需要生成批次的明细行!";
                return objJsonResult;
            }
            else //完全封闭
@@ -748,7 +748,7 @@
                string HOrgType = sArray[1].ToString();
                string HSourceBillTypeName = sArray[2].ToString();
                string HSelectBarCodeType = sArray[3].ToString();
                string CampanyName = sArray[4].ToString()=="xxx"?"": sArray[4].ToString();
                string CampanyName = sArray[4].ToString() == "xxx" ? "" : sArray[4].ToString();
                string UserName = sArray[5].ToString();
                ClsPub.CurUserName = UserName;
@@ -842,7 +842,7 @@
        #endregion
        #region[条码生成方法]
        private object SaveBarCode(string msg2, string HSelectBarCodeType, string CampanyName,string HSourceBillTypeName)
        private object SaveBarCode(string msg2, string HSelectBarCodeType, string CampanyName, string HSourceBillTypeName)
        {
            int LSHlen = 6;             //流水号长度
            int SumLen = 10;            //总长度
@@ -963,7 +963,8 @@
                            //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                            LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        }
                        else if (CampanyName == "瑞与祺") {
                        else if (CampanyName == "瑞与祺")
                        {
                            var date = DateTime.Now.ToString("yyMMdd");//日期
                            if (HSourceBillTypeName == "收料通知单")
                            {
@@ -1142,7 +1143,7 @@
                    HMinQty = ClsPub.isDoule(ordrlist[j].HMinQty);
                    HSumQty = ClsPub.isDoule(ordrlist[j].HQty);
                    n = 0;
                    for (int i = k; i < HBQty; i++)
                    {
                        if (HSumQty - HMinQty > 0)
@@ -1521,7 +1522,7 @@
        {
            try
            {
                oCN.RunProc("update Gy_BarCodeBill set HPrintQty=isnull(HPrintQty,0)+1 where HitemID in("+msg+")", ref DBUtility.ClsPub.sExeReturnInfo);
                oCN.RunProc("update Gy_BarCodeBill set HPrintQty=isnull(HPrintQty,0)+1 where HitemID in(" + msg + ")", ref DBUtility.ClsPub.sExeReturnInfo);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "更新打印次数成功";
@@ -1537,6 +1538,109 @@
        }
        #endregion
        #region æ¡ç å­˜å…¥æ¡ç ä¸»æ¡£
        /// <summary>
        /// æ¡ç è½¬å­˜æ¡ç ä¸»æ¡£
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        [Route("Sc_BarCode/SaveBarCode_NoGenerate")]
        [HttpPost]
        public object SaveBarCode_NoGenerate([FromBody] JObject msg)
        {
            try
            {
                var _value = msg["msg"].ToString();
                string msg1 = _value.ToString();
                string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                string msg2 = sArray[0].ToString();
                string HOrgType = sArray[1].ToString();
                string HSourceBillTypeName = sArray[2].ToString();
                string HSelectBarCodeType = sArray[3].ToString();
                string CampanyName = sArray[4].ToString() == "xxx" ? "" : sArray[4].ToString();
                string UserName = sArray[5].ToString();
                string barCodeNo = sArray[6].ToString();
                ClsPub.CurUserName = UserName;
                //获取内码
                HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
                DAL.ClsGy_ORGANIZATIONS_View oClsGy_ORGANIZATIONS_View = new DAL.ClsGy_ORGANIZATIONS_View();
                HOrgNumber = "";
                if (oClsGy_ORGANIZATIONS_View.GetInfoByName(HOrgType))
                {
                    HOrgID = oClsGy_ORGANIZATIONS_View.omodel.HItemID;
                    HOrgNumber = DBUtility.ClsPub.isStrNull(oClsGy_ORGANIZATIONS_View.omodel.HNumber);
                }
                if (HOrgID == -1)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "[0000-2-055]选择组织有错误!";
                    return objJsonResult;
                }
                if (!Sub_AllowSave(msg2, HSelectBarCodeType))//单据完整性判断
                {
                    return objJsonResult;
                }
                if (HSelectBarCodeType == "仪器成品条码规则")
                {
                    //客户定制
                }
                else
                {
                    // æ¡ç è½¬å­˜
                    msg2 = msg2.Replace("\\", "");
                    msg2 = msg2.Replace("\n", "");  //\n
                    List<HSouceOrderList> ordrlist = Newtonsoft.Json.JsonConvert.DeserializeObject<List<HSouceOrderList>>(msg2);
                    LogService.Write(ordrlist[0]);
                    long HSourceInterID = string.IsNullOrEmpty(ordrlist[0].HMainID) == true ? 0 : ClsPub.isLong(ordrlist[0].HMainID);
                    long HSourceEntryID = string.IsNullOrEmpty(ordrlist[0].HSubID) == true ? 0 : ClsPub.isLong(ordrlist[0].HSubID);
                    DataSet ds1 = oCN.RunProcReturn("exec h_p_SC_BarCode_Transfer " +
                        "@HBarCodeNo = N'" + barCodeNo + "'" +
                        ",@HSubID = " + ordrlist[0].HSubID +
                        ",@HMaterID = " + ordrlist[0].HMaterID +
                        ",@HGiveAwayFlag = " + ordrlist[0].HGiveAwayFlag +
                        ",@HQty = " + ordrlist[0].HQty +
                        ",@HUnitID = " + ordrlist[0].HUnitID +
                        ",@HMinQty = " + ordrlist[0].HMinQty +
                        ",@HSupID = " + ordrlist[0].HSupID +
                        ",@HBatchNo = N'" + ordrlist[0].HBatchNo + "'" +
                        ",@HMTONO = N'" + ordrlist[0].HMTONo + "'" +
                        ",@HBarCodeDate = N'" + ordrlist[0].HDate + "'" +
                        ",@HEmpID = " + ordrlist[0].HEmpID +
                        ",@HGroupID = " + ordrlist[0].HGroupID +
                        ",@HSourceInterID = " + HSourceInterID +
                        ",@HSourceEntryID = " + HSourceEntryID +
                        ",@HBarCodeType = N'" + HSelectBarCodeType + "'"+
                        ",@HSourceBillNo = N'" + ordrlist[0].HBillNo + "'"+
                        ",@HMaker = N'" + UserName + "'"
                        , "h_p_SC_BarCode_Transfer");
                    if ((bool)ds1.Tables[0].Rows[0]["returntype"] == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = ds1.Tables[0].Rows[0]["mesg"].ToString();
                    }
                    else
                    {
                        throw new Exception(ds1.Tables[0].Rows[0]["mesg"].ToString());
                    }
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "[3899-2-006]条码生成失败!" + e.Message;
                return objJsonResult;
            }
            return objJsonResult;
        }
        #endregion
        #region [条码生成接口-迦南]
        [Route("Sc_BarCode/Sub_SaveBill_JiaNan")]
@@ -1740,7 +1844,7 @@
                            oCN.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");           //更新最大流水号
                        }
                    }
                    else if(HSelectBarCodeType == "BarCode_Box")
                    else if (HSelectBarCodeType == "BarCode_Box")
                    {
                        int HBQty = ClsPub.isInt(ordrlist[i].HBQty);                            //箱数