1
duhe
2024-12-18 ba76af92c90c52823b8140ac3be26fbf69d467bd
WebAPI/Controllers/ÌõÂë¹ÜÀí/WEBSController.cs
@@ -4497,6 +4497,8 @@
            string sJXCode = "";
            if (oSystemParameter.ShowBill(ref sErrMsg) == true)
            {
                LogService.Write("森楷扫码参数值,客户:" + oSystemParameter.omodel.WMS_CampanyName + " ,源单类型:" + HSourceBillType);
                if (oSystemParameter.omodel.WMS_CampanyName == "安瑞") //系统参数  å®¢æˆ·å®šåˆ¶åŒ–名称     ç©ºç™½ä¸ºé€šç”¨
                {
                    sJXCode = POStockInBillController.JX_Json(sBarCode, HInterID, HBillType, HStockOrgID, HBillNo, HMaker);
@@ -4504,6 +4506,7 @@
                }
                else if(oSystemParameter.omodel.WMS_CampanyName == "森楷" && HSourceBillType == "1241")
                {
                    LogService.Write("森楷其他入库扫码条码记录:" + sBarCode);
                    DataSet ds;
                    string sql = "select HBarCode,HSourceInterID,HSourceEntryID,HSourceBillNo from Gy_BarCodeBill with(nolock) where HBarCode = '" + sBarCode + "'";
                    string HDataBaseName = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "DataBaseName");//获取金蝶数据库名称
@@ -4514,6 +4517,7 @@
                    //判断条码信息是否在条码档案中
                    if (ds == null || ds.Tables[0].Rows.Count < 1)
                    {
                        LogService.Write("其他入库,条码档案中不存在此条码编号:" + sBarCode);
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "条码档案中不存在此条码编号:" + sBarCode;
@@ -4741,7 +4745,7 @@
                            }
                            //更新条码源单id信息
                            sql = string.Format($@"update a set HSourceInterID = b.FID,HSourceEntryID = c.FEntryID from Gy_BarCodeBill a left join AIS20220609121235..TFKO_t_Cust100009 b on a.HSourceBillNo = b.FBillNo left join AIS20220609121235..TFKO_t_Cust_Entry100065 c on b.FID = C.FID and a.HBarcodeNo = c.FSEQ where HSourceBillNo = '{HSourceBillNo_TB}'");
                            sql = string.Format($@"update a set HSourceInterID = isnull(b.FID,0),HSourceEntryID = isnull(c.FEntryID,0) from Gy_BarCodeBill a left join AIS20220609121235..TFKO_t_Cust100009 b on a.HSourceBillNo = b.FBillNo left join AIS20220609121235..TFKO_t_Cust_Entry100065 c on b.FID = C.FID and a.HBarcodeNo = c.FSEQ where HSourceBillNo = '{HSourceBillNo_TB}'");
                            //执行更新语句
                            oCn.RunProc(sql);
@@ -5281,6 +5285,48 @@
        #endregion
        #region æ‰«æå•据条码  å·²å­˜åœ¨æ‰«ç è®°å½•且单据发生变更后两边数据不一致时,清空原扫码数据   20241216
        /// <summary>
        /// å·²å­˜åœ¨æ‰«ç è®°å½•且单据发生变更后两边数据不一致时,清空原扫码数据
        /// </summary>
        /// <returns></returns>
        [Route("WEBSController/get_ClearBarCode_BillCheck_Json")]
        [HttpGet]
        public object get_ClearBarCode_BillCheck_Json(Int64 HInterID, string HBillType, string HMaker, Int64 HStockOrgID)
        {
            try
            {
                ds = oCn.RunProcReturn("exec h_p_WMS_ClearBarCode_BillCheck " + HInterID.ToString() + ",'" + HBillType + "','" + HMaker + "'," + HStockOrgID.ToString(), "h_p_WMS_ClearBarCode_BillCheck");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "清空原扫码数据发生错误!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "清空原扫码数据失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region æ‰«æç‰©æ–™æ¡ç   å‡ºå…¥åº“模块
        /// <summary>
@@ -5294,7 +5340,7 @@
            //获取系统参数
            string sErrMsg = "";
            string sJXCode = "";
            if (oSystemParameter.ShowBill(ref sErrMsg) == true)
            if (oSystemParameter.ShowBillByOrgID(HStockOrgID, ref sErrMsg) == true)
            {
                string sSourceBarCodeCtl = "N";   //校验-是否进行源单对应条码核对('Y'为核对)
@@ -5689,7 +5735,7 @@
        #endregion
        #region ç¼“存模块    è¿”回缓存列表信息
        #region æ ¡éªŒç¼“存模块    è¿”回缓存列表信息
        /// <summary>
        /// è¿”回缓存列表信息    æ ¡éªŒæ¨¡å¼
@@ -5733,6 +5779,186 @@
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "获取缓存列表信息失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region æ ¡éªŒç¼“存模块    æ ¹æ®å•据ID,删除临时表记录    20241216
        /// <summary>
        /// æ ¹æ®å•据ID,删除临时表记录
        /// </summary>
        /// <returns></returns>
        [Route("WEBSController/DeleteTempBillList_BillCheck_Json")]
        [HttpGet]
        public object DeleteTempBillList_BillCheck_Json(long HInterID, string HBillNo, string HBillType, string HMaker, string MvarReportTitle, Int64 HStockOrgID)
        {
            string WorkList = "删除校验缓存单据,单据号:" + HBillNo;
            string SystemName = "WMS-" + MvarReportTitle + "模块";
            //获取系统参数
            string sErrMsg = "";
            if (oSystemParameter.ShowBillByOrgID(HStockOrgID, ref sErrMsg) == true)
            {
                string sSourceBarCodeCtl = "N";   //校验-是否进行源单对应条码核对('Y'为核对)
                #region ç³»ç»Ÿå‚数获取
                //采购入库单
                if (HBillType == "1201")
                {
                    //校验-是否进行源单对应条码核对('Y'为核对)
                    if (oSystemParameter.omodel.Kf_POStockInBillCheck_SourceBarCodeCtl == "Y")
                    {
                        sSourceBarCodeCtl = "Y";
                    }
                }
                //生产入库单
                if (HBillType == "1202")
                {
                    //校验-是否进行源单对应条码核对('Y'为核对)
                    if (oSystemParameter.omodel.Kf_ProductInBillCheck_SourceBarCodeCtl == "Y")
                    {
                        sSourceBarCodeCtl = "Y";
                    }
                }
                //其他入库单
                if (HBillType == "1203")
                {
                    //校验-是否进行源单对应条码核对('Y'为核对)
                    if (oSystemParameter.omodel.Kf_OtherInBillCheck_SourceBarCodeCtl == "Y")
                    {
                        sSourceBarCodeCtl = "Y";
                    }
                }
                //领料出库单
                else if (HBillType == "1204")
                {
                    //校验-是否进行源单对应条码核对('Y'为核对)
                    if (oSystemParameter.omodel.Kf_MateOutBillCheck_SourceBarCodeCtl == "Y")
                    {
                        sSourceBarCodeCtl = "Y";
                    }
                }
                //销售出库单
                else if (HBillType == "1205")
                {
                    //校验-是否进行源单对应条码核对('Y'为核对)
                    if (oSystemParameter.omodel.Kf_SellOutBillCheck_SourceBarCodeCtl == "Y")
                    {
                        sSourceBarCodeCtl = "Y";
                    }
                }
                //其他出库单
                else if (HBillType == "1206")
                {
                    //校验-是否进行源单对应条码核对('Y'为核对)
                    if (oSystemParameter.omodel.Kf_OtherOutBillCheck_SourceBarCodeCtl == "Y")
                    {
                        sSourceBarCodeCtl = "Y";
                    }
                }
                //委外领料单
                else if (HBillType == "1211")
                {
                    //校验-是否进行源单对应条码核对('Y'为核对)
                    if (oSystemParameter.omodel.Kf_EntrustOutBillCheck_SourceBarCodeCtl == "Y")
                    {
                        sSourceBarCodeCtl = "Y";
                    }
                }
                //生产补料单
                else if (HBillType == "1254")
                {
                    //校验-是否进行源单对应条码核对('Y'为核对)
                    if (oSystemParameter.omodel.Kf_MateReplenishOutBillCheck_SourceBarCodeCtl == "Y")
                    {
                        sSourceBarCodeCtl = "Y";
                    }
                }
                //委外补料单
                else if (HBillType == "1255")
                {
                    //校验-是否进行源单对应条码核对('Y'为核对)
                    if (oSystemParameter.omodel.Kf_EntrustReplenishOutBillCheck_SourceBarCodeCtl == "Y")
                    {
                        sSourceBarCodeCtl = "Y";
                    }
                }
                //直接调拨单
                else if (HBillType == "1207")
                {
                    //校验-是否进行源单对应条码核对('Y'为核对)
                    if (oSystemParameter.omodel.Kf_MoveStockBillCheck_SourceBarCodeCtl == "Y")
                    {
                        sSourceBarCodeCtl = "Y";
                    }
                }
                #endregion
                //原单据为扫码生成,对原扫描的条码进行核对,删除条码出入库校验缓存记录
                if (sSourceBarCodeCtl == "Y")
                {
                    try
                    {
                        oCn.BeginTran();
                        oCn.RunProc("Delete from KF_PonderationBillMain_Temp_Verify where HInterID=" + HInterID.ToString() + " and HBillType='" + HBillType + "'", ref DBUtility.ClsPub.sExeReturnInfo);
                        //写入日志
                        oCn.RunProc("Insert into System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " +
                            "(getdate(),'" + HMaker + "','" + ComputerName + "','" + WorkList + "','" + SystemName + "','','删除')"
                            );
                        oCn.Commit();
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "单据号:" + HBillNo + " åˆ é™¤æˆåŠŸ";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    catch (Exception e)
                    {
                        oCn.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "删除所选单据条码出入库临时表记录失败!" + e.ToString();
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                //原单据非扫码生成,删除条码出入库缓存列表记录
                else
                {
                    try
                    {
                        oCn.BeginTran();
                        oCn.RunProc("Delete from KF_PonderationBillMain_Temp where HInterID=" + HInterID.ToString() + " and HBillType='" + HBillType + "' and HSubBillType=1", ref DBUtility.ClsPub.sExeReturnInfo);
                        //写入日志
                        oCn.RunProc("Insert into System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " +
                            "(getdate(),'" + HMaker + "','" + ComputerName + "','" + WorkList + "','" + SystemName + "','','删除')"
                            );
                        oCn.Commit();
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "单据号:" + HBillNo + " åˆ é™¤æˆåŠŸ";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    catch (Exception e)
                    {
                        oCn.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "删除所选单据条码出入库临时表记录失败!" + e.ToString();
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
            }
            else
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "获取系统参数失败! " + sErrMsg;
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -5816,6 +6042,227 @@
        #endregion
        #region æ ¡éªŒç¼“存模块  å·²ä¸Šä¼ æŸ¥è¯¢ç•Œé¢åˆ·æ–°   20241216
        /// <summary>
        /// å·²ä¸Šä¼ æŸ¥è¯¢ç•Œé¢ï¼Œæ ¹æ®å•据类型、单据号、用户查询已上传单据信息
        /// </summary>
        /// <returns></returns>
        [Route("WEBSController/GetKf_ICStockBillQueryList_User_BillCheck_Json")]
        [HttpGet]
        public object GetKf_ICStockBillQueryList_User_BillCheck_Json(string HBillType, string HBillNo, string HMaker, Int64 HStockOrgID)
        {
            try
            {
                ds = oCn.RunProcReturn("exec h_p_Kf_ICStockBillQueryByUserList_BillCheck '" + HBillType + "','" + HBillNo + "','" + HMaker + "'," + HStockOrgID.ToString(), "h_p_Kf_ICStockBillQueryByUserList_BillCheck");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "查询不到该单据记录!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    List<object> columnNameList = new List<object>();
                    //添加列名
                    foreach (DataColumn col in ds.Tables[0].Columns)
                    {
                        Type dataType = col.DataType;
                        string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                        columnNameList.Add(JsonConvert.DeserializeObject(ColmString));  //获取到DataColumn列对象的列名
                    }
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "获取单据信息成功!";
                    objJsonResult.data = ds.Tables[0];
                    objJsonResult.list = columnNameList;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "获取已上传单据信息失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region æ ¡éªŒç¼“存模块  å·²ä¸Šä¼ åˆ—表界面,撤销功能,删除WMS表记录,并更新TEMP表中的上传字段 HRelationInterID=0     20241216
        /// <summary>
        /// å·²ä¸Šä¼ åˆ—表界面,撤销功能,删除WMS表记录,并更新TEMP表中的上传字段 HRelationInterID=0
        /// </summary>
        /// <returns></returns>
        [Route("WEBSController/set_DeleteICStockBillAndWMS_BillCheck_Json")]
        [HttpGet]
        public object set_DeleteICStockBillAndWMS_BillCheck_Json(Int64 HInterID, string HBillNo, string HBillType, string HMaker, string MvarReportTitle, Int64 HStockOrgID)
        {
            string WorkList = "撤销校验已上传单据,单据号:" + HBillNo;
            string SystemName = "WMS-" + MvarReportTitle + "模块";
            //获取系统参数
            string sErrMsg = "";
            if (oSystemParameter.ShowBillByOrgID(HStockOrgID, ref sErrMsg) == true)
            {
                string sERPMode = oSystemParameter.omodel.WMS_WMSStockCtl_ERPMode;   //库存控制-WMS库存控制ERP模式   (WISE、CLOUD、MES)
                string sSourceBarCodeCtl = "N";   //校验-是否进行源单对应条码核对('Y'为核对)
                #region ç³»ç»Ÿå‚数获取
                //采购入库单
                if (HBillType == "1201")
                {
                    //校验-是否进行源单对应条码核对('Y'为核对)
                    if (oSystemParameter.omodel.Kf_POStockInBillCheck_SourceBarCodeCtl == "Y")
                    {
                        sSourceBarCodeCtl = "Y";
                    }
                }
                //生产入库单
                if (HBillType == "1202")
                {
                    //校验-是否进行源单对应条码核对('Y'为核对)
                    if (oSystemParameter.omodel.Kf_ProductInBillCheck_SourceBarCodeCtl == "Y")
                    {
                        sSourceBarCodeCtl = "Y";
                    }
                }
                //其他入库单
                if (HBillType == "1203")
                {
                    //校验-是否进行源单对应条码核对('Y'为核对)
                    if (oSystemParameter.omodel.Kf_OtherInBillCheck_SourceBarCodeCtl == "Y")
                    {
                        sSourceBarCodeCtl = "Y";
                    }
                }
                //领料出库单
                else if (HBillType == "1204")
                {
                    //校验-是否进行源单对应条码核对('Y'为核对)
                    if (oSystemParameter.omodel.Kf_MateOutBillCheck_SourceBarCodeCtl == "Y")
                    {
                        sSourceBarCodeCtl = "Y";
                    }
                }
                //销售出库单
                else if (HBillType == "1205")
                {
                    //校验-是否进行源单对应条码核对('Y'为核对)
                    if (oSystemParameter.omodel.Kf_SellOutBillCheck_SourceBarCodeCtl == "Y")
                    {
                        sSourceBarCodeCtl = "Y";
                    }
                }
                //其他出库单
                else if (HBillType == "1206")
                {
                    //校验-是否进行源单对应条码核对('Y'为核对)
                    if (oSystemParameter.omodel.Kf_OtherOutBillCheck_SourceBarCodeCtl == "Y")
                    {
                        sSourceBarCodeCtl = "Y";
                    }
                }
                //委外领料单
                else if (HBillType == "1211")
                {
                    //校验-是否进行源单对应条码核对('Y'为核对)
                    if (oSystemParameter.omodel.Kf_EntrustOutBillCheck_SourceBarCodeCtl == "Y")
                    {
                        sSourceBarCodeCtl = "Y";
                    }
                }
                //生产补料单
                else if (HBillType == "1254")
                {
                    //校验-是否进行源单对应条码核对('Y'为核对)
                    if (oSystemParameter.omodel.Kf_MateReplenishOutBillCheck_SourceBarCodeCtl == "Y")
                    {
                        sSourceBarCodeCtl = "Y";
                    }
                }
                //委外补料单
                else if (HBillType == "1255")
                {
                    //校验-是否进行源单对应条码核对('Y'为核对)
                    if (oSystemParameter.omodel.Kf_EntrustReplenishOutBillCheck_SourceBarCodeCtl == "Y")
                    {
                        sSourceBarCodeCtl = "Y";
                    }
                }
                //直接调拨单
                else if (HBillType == "1207")
                {
                    //校验-是否进行源单对应条码核对('Y'为核对)
                    if (oSystemParameter.omodel.Kf_MoveStockBillCheck_SourceBarCodeCtl == "Y")
                    {
                        sSourceBarCodeCtl = "Y";
                    }
                }
                #endregion
                try
                {
                    oCn.BeginTran();
                    ds = oCn.RunProcReturn("exec h_p_WMS_ICStockBillAndWMS_Delete_BillCheck " + HInterID + ",'" + HBillNo + "','" + HBillType + "','" + sSourceBarCodeCtl + "','" + sERPMode + "'", "h_p_WMS_ICStockBillAndWMS_Delete_BillCheck");
                    if (ds == null || ds.Tables[0].Rows.Count == 0)
                    {
                        oCn.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "撤销单据已上传记录失败,撤销单据判断错误!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) == 1)
                    {
                        oCn.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;  //失败!
                        objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]);
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        //写入日志
                        oCn.RunProc("Insert into  System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " +
                            "(getdate(),'" + HMaker + "','" + ComputerName + "','" + WorkList + "','" + SystemName + "','','撤销')"
                            );
                        oCn.Commit();
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;  //成功!
                        objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]);
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                catch (Exception e)
                {
                    oCn.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "撤销单据已上传记录失败!" + e.ToString();
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            else
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "获取系统参数失败! " + sErrMsg;
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region ç¼“存模块    å·²ä¸Šä¼ åˆ—表界面,撤销功能
        /// <summary>