1
yangle
2023-10-26 dfaeb9635591ed4b13f0ae265022872b081c0758
WebAPI/Controllers/Sc_ProcessMangementController.cs
@@ -21,7 +21,7 @@
        private json objJsonResult = new json();
        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
        public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        DataSet ds;
@@ -405,6 +405,10 @@
        {
            try
            {
                string sErr = "";
                oSystemParameter.ShowBill(ref sErr);
                //获取生产汇报单最大InterID和单据号
                Int64 HInterID = DBUtility.ClsPub.CreateBillID("3711", ref DBUtility.ClsPub.sExeReturnInfo);
                string HBillNo = DBUtility.ClsPub.CreateBillCode("3711", ref DBUtility.ClsPub.sExeReturnInfo, true);
@@ -521,7 +525,10 @@
                    FentityModel.Add("FCostRate", dr1["FCostRate"].ToString());// 成本权重
                    FentityModel.Add("FISBACKFLUSH", dr1["FISBACKFLUSH"].ToString() == "1" ? true : false);// 倒冲领料
                    FentityModel.Add("FMOMAINENTRYID", dr1["FMOENTRYID"].ToString());//
                    //FentityModel.Add("F_bsv_Base1", new JObject() { ["Fnumber"] = dr1["FPREBDONENUMBER"].ToString() }); //包装标识
                    if (oSystemParameter.omodel.WMS_CampanyName == "瑞与祺")
                    {
                        FentityModel.Add("F_bsv_Base1", new JObject() { ["Fnumber"] = dr1["FPREBDONENUMBER"].ToString() });//包装标识
                    }
                    FentityModel.Add("FLot", new JObject() { ["FNumber"] = dr1["FBATCHNO"].ToString() }); //批号
                    FentityModel.Add("F_bsv_Text", dr1["工序流转卡号"].ToString()); //流转卡号
                    JArray Fentity2 = new JArray();
@@ -686,6 +693,16 @@
                //
                //DataSet ds1 = oCN.RunProcReturn("select * from  h_v_TOERPProcduct_LastProc where HLastProc = '是' and  hbillno='" + BillNo.ToString() + "'", "h_v_TOERPProcduct_LastProc");
                DataSet ds1 = oCN.RunProcReturn("exec h_p_TOERPProcduct_LastProc '" + BillNo + "'", "h_p_TOERPProcduct_LastProc");
                if (ds1 == null || ds1.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "未找到对应的本地或金蝶云生产汇报单记录;1.未查询到对应的生产汇报单;2.请确保当前工序是末道工序3.汇报单对应的入库数量已满 请在金蝶云查看入库记录!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                DataRow dr1 = ds1.Tables[0].Rows[0];
                if (double.Parse(dr1[0].ToString()) <= 0)
                {
@@ -730,6 +747,19 @@
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        //判断唯一ID是否为空
                        foreach (DataRow item in ds1.Tables[0].Rows)
                        {
                            if (item["HWYID"].ToString() == null || item["HWYID"].ToString() == "" || item["HWYID"].ToString() == "undefined")
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "唯一ID为空,请重新手动入库或联系管理员!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                        }
                    }
                }
@@ -1003,6 +1033,14 @@
                //
                //DataSet ds1 = oCN.RunProcReturn("select * from  h_v_TOERPProcduct_LastProc where HLastProc = '是' and  hbillno='" + BillNo.ToString() + "'", "h_v_TOERPProcduct_LastProc");
                DataSet ds1 = oCN.RunProcReturn("exec h_p_TOERPProcduct_LastProc_BF '" + BillNo + "'", "h_p_TOERPProcduct_LastProc_BF");
                if (ds1.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "操作失败,查不到对应的出站单据!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                DataRow dr1 = ds1.Tables[0].Rows[0];
                JObject model = new JObject();
@@ -1065,7 +1103,7 @@
                    FentityModel.Add("FSrcInterId", item["HSourceInterID"].ToString());//  
                    FentityModel.Add("FBasePrdRealQty", item["数量"].ToString());//
                    FentityModel.Add("FIsFinished", "false");//
                    FentityModel.Add("FStockStatusId", new JObject() { ["FNumber"] = "KCZT08_SYS" }); //
                    FentityModel.Add("FStockStatusId", new JObject() { ["FNumber"] = "KCZT001" }); //
                    FentityModel.Add("FSrcEntrySeq", item["HSourceSeQ"].ToString());//  源单分录行号
                    FentityModel.Add("FMOMAINENTRYID", item["HMOEntryID"].ToString());//
                    FentityModel.Add("FKeeperTypeId", "BD_KeeperOrg");
@@ -1205,7 +1243,7 @@
            Int64 HSourceEntryID, string HSourceBillNo, string user,
            Int64 HWHID, Int64 HSPID, Int64 HSupID, Int64 HKeeperID,
            Int64 HMaterID, string HSourceBillType, Int64 HSLInterID,
            Int64 HSLEntryID, string HSLBillNo, Int64 HSLSeQ, string HBillNo, Int64 HInterID)
            Int64 HSLEntryID, string HSLBillNo, Int64 HSLSeQ, string HBillNo, Int64 HInterID, string HBatchNo)
        {
            try
            {
@@ -1300,6 +1338,7 @@
                FentityModel.Add("FBaseAcceptQty", HRightQty.ToString());//基本单位接收数
                FentityModel.Add("FCurrency", new JObject() { ["Fnumber"] = "PRE001" });//币别
                FentityModel.Add("FIsSplitRow ", false);// 是否拆分行
                FentityModel.Add("FLot", new JObject() { ["Fnumber"] = HBatchNo.ToString() });//批号
                JArray Fentity2 = new JArray();
                JObject FentityModel2 = new JObject();
@@ -2990,6 +3029,115 @@
        }
        #endregion
        #region 不良品处理单关闭/反关闭功能
        [Route("Sc_ProcessMangement/CloseSc_ProcessMangement")]
        [HttpGet]
        public object CloseSc_ProcessMangement(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有删除权限
                if (!DBUtility.ClsPub.Security_Log("QC_NoPassProdCheckBill_Close", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限关闭!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "QC_NoPassProdCheckBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 关闭  2  反关闭
                if (Type == 1)
                {
                    //判断单据是否已经关闭
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已关闭!不需要再关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //关闭单据
                    if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "关闭失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                else
                {
                    //判断单据是否已经反关闭
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已反关闭!不需要再反关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    //反关闭单据
                    if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反关闭失败!原因:" + ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                oCN.Commit();//提交事务
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "执行成功!";
                objJsonResult.data = null;
                return objJsonResult; ;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "执行失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        /// <summary>
        /// PDA工序汇报单保存
        /// </summary>