wtt
2024-08-01 55e565721ef588d7ae9f421b6d1fce63b51aa55f
WebAPI/DLL/ClsSc_ICMOReportBill.cs
@@ -71,7 +71,7 @@
                //获取明细行修改前数量
                Int64 HBackQty = 0;
                Ds = oCn.RunProcReturn("select isnull(sum(isnull(HQty,0)),0) + isnull(sum(isnull(HWasterQty,0)),0) as HBackQty from Sc_ICMOReportBillSub where HInterID = " + lngBillKey, "Sc_ICMOReportBillSub");
                Ds = oCn.RunProcReturn("select isnull(sum(isnull(HQty,0)),0) + isnull(sum(isnull(HBadQty,0)),0) as HBackQty from Sc_ICMOReportBillSub where HInterID = " + lngBillKey, "Sc_ICMOReportBillSub");
                if (Ds != null && Ds.Tables[0].Rows.Count > 0)
                {
                    HBackQty = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HBackQty"]);
@@ -92,7 +92,7 @@
                      "HCloseMan,HCloseType,HRemark," +
                      "HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
                      ",HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo" +
                      ",HICMOInterID,HICMOBillNo,HBarCode,HICMOEntryID" +
                      ",HICMOInterID,HICMOBillNo,HBarCode,HICMOEntryID,HBadQty" +
                      ") values("
                      + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HMaterID.ToString() + ",'" + oSub.HMaterNumber +"'"+
                      "," + oSub.HQty.ToString() + "," + oSub.HUnitID.ToString() + ",'" + oSub.HUnitNumber + "'," + oSub.HTimes.ToString() + "," + oSub.HSourceID.ToString() +
@@ -100,20 +100,19 @@
                      ",'" + oSub.HCloseMan + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" +
                      "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
                      "," + oSub.HSeOrderInterID.ToString() + "," + oSub.HSeOrderEntryID.ToString() + ",'" + oSub.HSeOrderBillNo + "'" +
                      "," + oSub.HICMOInterID.ToString() + ",'" + oSub.HICMOBillNo + "','" + oSub.HBarCode + "'," + oSub.HICMOEntryID +
                      ") ");
                    //反写产量汇报单,质量汇报单关联字段,生产订单关联数量
                    Ds = oCn.RunProcReturn("exec h_p_Sc_ICMOReportBill_ReverseWriteQty " + omodel.HInterID + "," + oSub.HEntryID + ",'" + omodel.HBillNo + "'," +
                        DetailColl[0].HICMOInterID + "," + DetailColl[0].HICMOEntryID + "," + DetailColl[0].HICMOBillNo + ",'" + DetailColl[0].HSourceID + "','" +
                        "Edit" + "'," + HBackQty
                        , "h_p_Sc_ICMOReportBill_ReverseWriteQty");
                    if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBack"]) == "1")
                    {
                        sReturn = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBackRemark"]);
                        oCn.RollBack();
                        return false;
                    }
                      "," + oSub.HICMOInterID.ToString() + ",'" + oSub.HICMOBillNo + "','" + oSub.HBarCode + "'," + oSub.HICMOEntryID + "," + oSub.HBadQty +
                      ") ");
                }
                //反写产量汇报单,质量汇报单关联字段,生产订单关联数量
                Ds = oCn.RunProcReturn("exec h_p_Sc_ICMOReportBill_ReverseWriteQty " + omodel.HInterID + "," + oSub.HEntryID + ",'" + omodel.HBillNo + "'," +
                    DetailColl[0].HICMOInterID + "," + DetailColl[0].HICMOEntryID + ",'" + DetailColl[0].HICMOBillNo + "','" + DetailColl[0].HSourceID + "','" +
                    "Edit" + "'," + HBackQty + "," + DetailColl[0].HICMOTempID
                    , "h_p_Sc_ICMOReportBill_ReverseWriteQty");
                if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBack"]) == "1")
                {
                    sReturn = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBackRemark"]);
                    oCn.RollBack();
                    return false;
                }
                if (omodel.HCheckType == "合格")
                {
@@ -257,19 +256,18 @@
                    //                                               " HRelationBillNo ='" + omodel.HBillNo +
                    //                                               "', HRelationInterID='" + omodel.HInterID +
                    //                                               "' from Sc_ICMOBillQualityStatus_Tmp a where a.HICMOBillNo='" + DetailColl[0].HICMOBillNo + "' and a.HSourceID='" + DetailColl[0].HSourceID + "' and  HICMOInterID='" + DetailColl[0].HICMOInterID + "' and a.HICMOEntryID='" + DetailColl[0].HICMOEntryID + "'  and HRelationInterID='0'");
                    //oCn.RunProc(sql2);
                    //反写产量汇报单,质量汇报单关联字段,生产订单关联数量
                    ds = oCn.RunProcReturn("exec h_p_Sc_ICMOReportBill_ReverseWriteQty " + omodel.HInterID + "," + oSub.HEntryID + ",'" + omodel.HBillNo + "'," +
                        DetailColl[0].HICMOInterID + "," + DetailColl[0].HICMOEntryID + "," + DetailColl[0].HICMOBillNo + ",'" + DetailColl[0].HSourceID + "','" +
                        "Add" + "'," + 0
                        , "h_p_Sc_ICMOReportBill_ReverseWriteQty");
                    if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "1")
                    {
                        sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                        oCn.RollBack();
                        return false;
                    }
                    //oCn.RunProc(sql2);
                }
                //反写产量汇报单,质量汇报单关联字段,生产订单关联数量
                ds = oCn.RunProcReturn("exec h_p_Sc_ICMOReportBill_ReverseWriteQty " + omodel.HInterID + "," + oSub.HEntryID + ",'" + omodel.HBillNo + "'," +
                    DetailColl[0].HICMOInterID + "," + DetailColl[0].HICMOEntryID + ",'" + DetailColl[0].HICMOBillNo + "','" + DetailColl[0].HSourceID + "','" +
                    "Add" + "'," + 0 + "," + DetailColl[0].HICMOTempID
                    , "h_p_Sc_ICMOReportBill_ReverseWriteQty");
                if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "1")
                {
                    sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                    oCn.RollBack();
                    return false;
                }
                //
                //foreach (Model.ClsSc_ICMOReportBillSub oSub in DetailColl)
@@ -439,6 +437,7 @@
                }
                else
                {
                    oSystemParameter.ShowBill(ref sReturn);
                    JObject model = new JObject();
                    model.Add("FBillType", new JObject() { ["FNumber"] = Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FBillType"]) }); //单据类型
                    model.Add("FDate", Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FDate"])); //单据日期                   
@@ -461,7 +460,7 @@
                        FentityModel.Add("FMTONO", item["FMTONO"].ToString());//   计划跟踪号
                        FentityModel.Add("FCheckProduct", item["FCheckProduct"].ToString());//   产品检验
                        FentityModel.Add("FISENTRUST", item["FISENTRUST"].ToString());//      组织委托加工
                        FentityModel.Add("FSrcBillType", "FSRCBILLTYPE");//   源单类型
                        FentityModel.Add("FSrcBillType", item["FSRCBILLTYPE"].ToString());//   源单类型
                        FentityModel.Add("FMOBILLNO", item["FMOBILLNO"].ToString());//  生产订单
                        FentityModel.Add("FSrcBillNo", item["FSrcBillNo"].ToString());//   源单编号
                        FentityModel.Add("FMoEntrySeq", item["FMoEntrySeq"].ToString());//生产订单行号
@@ -501,7 +500,8 @@
                            FentityModel.Add("FShiftGroupId", new JObject() { ["FNumber"] = item["FShiftGroupId"].ToString() });//班组
                            FentityModel.Add("F_UUBK_CZG1", new JObject() { ["FSTAFFNUMBER"] = item["F_UUBK_CZG1"].ToString() });// 操作员
                        }
                        FentityModel.Add("FBOMID", new JObject() { ["FNumber"] = item["FBOMID"].ToString() });// BOM版本
                        //sJson_BatchNo +
@@ -580,16 +580,29 @@
                        //提交审核
                        string result1 = string.Empty;
                        string result2 = string.Empty;
                        var fID = JObject.Parse(result)["Result"]["Id"].ToString();
                        var fBillNo = JObject.Parse(result)["Result"]["Number"].ToString();
                        var json = new
                        {
                            Ids = fID,
                        };
                        if (oSystemParameter.omodel.Sc_ICMOReportBill_AutoCheck == "Y") //系统参数  自动审核 
                        {
                            result1 = InvokeHelper.Submit("PRD_MORPT", JsonConvert.SerializeObject(jsonRoot));//提交
                            result2 = InvokeHelper.Audit("PRD_MORPT", JsonConvert.SerializeObject(jsonRoot));//审核
                            result1 = InvokeHelper.Submit("PRD_MORPT", JsonConvert.SerializeObject(json));//提交
                            result2 = InvokeHelper.Audit("PRD_MORPT", JsonConvert.SerializeObject(json));//审核
                            if (JObject.Parse(result1)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
                            {
                                sReturn = "生产汇报单单号:" + HBillNo + ",提交失败" + result;
                                sReturn = "生产汇报单单号:" + HBillNo + ",提交失败" + result1;
                                oCn.RollBack();
                                return false;                              
                            }
                            if (JObject.Parse(result2)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
                            {
                                sReturn = "生产汇报单单号:" + HBillNo + ",审核失败" + result2;
                                oCn.RollBack();
                                return false;
                            }
                        }                       
                    }                   
@@ -672,14 +685,14 @@
        }
        //删除单据
        public virtual bool DeleteBill(Int64 lngBillKey, ref string sReturn)
        public virtual bool DeleteBill(Int64 lngBillKey, string HBillNo, string procName, string user, ref string sReturn)
        {
            try
            {
                oCn.BeginTran();
                //查询生产汇报单表数量
                DataSet ds = oCn.RunProcReturn("select a.HBillNo,b.HICMOInterID,b.HICMOEntryID  from Sc_ICMOReportBillMain a inner join Sc_ICMOReportBillSub b on a.HInterID = b.HInterID where a.HInterID = '" + lngBillKey + "'", "Sc_ICMOReportBillMain");
                string HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
                HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
                string HICMOInterID = ds.Tables[0].Rows[0]["HICMOInterID"].ToString();
                string HICMOEntryID = ds.Tables[0].Rows[0]["HICMOEntryID"].ToString();
                //
@@ -706,6 +719,24 @@
                //删除主表
                DeleteBillMain(lngBillKey);
                //删除后控制==================================================================================
                string sql2 = "exec " + procName + " " + lngBillKey + ",'" + HBillNo + "','" + user + "'";
                ds = oCn.RunProcReturn(sql2, procName);
                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                {
                    sReturn = "删除失败!原因:删除后判断失败,请与网络管理人员联系";
                    oCn.RollBack();
                    return false;
                }
                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                {
                    sReturn = "删除失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString();
                    oCn.RollBack();
                    return false;
                }
                //==============================================================================================
                sReturn = "删除单据成功!";
                oCn.Commit();
                return true;