YL
2021-12-21 aca99f3c22afc557d5628a4ce89b653418636405
WebAPI/Controllers/Éú²ú¹ÜÀí/±¨¹¤Ì¨¹¤Ðò/Sc_MESBeginStepWorkBillController.cs
@@ -597,15 +597,20 @@
        public static DataSet Sc_GetMESProductReportBillList(string sWhere)
        {
            string sql = string.Format(@"select a.HInterID, a.HBillNo,a.HDate,a.HBillType,a.HBillStatus,a.HMaterID,m.HNumber HMaterCode,m.HName HMaterName,m.HModel HMaterSpec 
                                   ,a.HSourceID,s.HNumber HSourceCode,s.HName HSourceName,a.HGroupID,g.HNumber HGroupCode,g.HName HGroupName
                                   ,a.HWorkManID,e.HName HWorkManName,a.HMaker,a.HMakeDate, a.HReportType
                                   ,a.HQty,a.HICMOBillNo,a.HICMOInterID,a.HICMOEntryID
                                   ,a.HSourceInterID,a.HSourceEntryID,a.HSourceBillNo, a.HSourceBillType
                                   from Sc_ICMOBillWorkQtyStatus_Tmp a
                                   left join Gy_Material m on a.HMaterID=m.hitemid
                                   left join Gy_Source s on a.HSourceID=s.HItemID
                                   left join Gy_Group g on a.HGroupID=g.HItemID
                                   left join Gy_Employee e on a.HWorkManID=e.HItemID " + sWhere + " and HRelationInterID='0'");
                                         ,b.HSourceID,s.HNumber HSourceCode,s.HName HSourceName,a.HGroupID,g.HNumber HGroupCode,g.HName HGroupName
                                         ,b.HEmpID,b.HEmpNumber,e.HName HEmpName,a.HMaker,a.HMakeDate, '工序汇报' HReportType
                                         ,b.HQty,a.HICMOBillNo,a.HICMOInterID,pr.HProcNo,b.HProcID,p.HNumber HProcNumber,p.HName HProcName
                                         ,b.HSourceInterID,b.HSourceEntryID,b.HSourceBillNo,b.HSourceBillType
                                         from Sc_ProcessReportMain a
                                         inner join Sc_ProcessReportSub b on a.HInterID=B.HInterID
                                         inner join (select max(HProcNo) HProcNo,HBillNo,HProcID,HSourceInterID,HSourceEntryID,HSourceBillNo
                                         from Sc_ProcessPlanSub group by HBillNo,HProcID,HSourceInterID,HSourceEntryID,HSourceBillNo)
                                         pr on b.HSourceBillNo=pr.HSourceBillNo and b.HSourceInterID=pr.HSourceInterID and b.HSourceEntryID=pr.HSourceEntryID
                                         left join Gy_Process p on b.HProcID=p.HItemID
                                         left join Gy_Material m on a.HMaterID=m.hitemid
                                         left join Gy_Source s on b.HSourceID=s.HItemID
                                         left join Gy_Group g on a.HGroupID=g.HItemID
                                         left join Gy_Employee e on b.HEmpID=e.HItemID "+sWhere+"  and HRelationInterID='0'");
            return new SQLHelper.ClsCN().RunProcReturn(sql, "Sc_ICMOBillWorkQtyStatus_Tmp");
        }
        #endregion
@@ -622,7 +627,7 @@
        {
            try
            {
                ds = new SQLHelper.ClsCN().RunProcReturn("select isnull(sum(HQty),0) HQty,isnull(sum(HBadQty),0) HBadQty,isnull(sum(HWasterQty),0) HWasterQty   from Sc_ICMOBillWorkQtyStatus_Tmp with (nolock)" + sWhere, "Sc_ICMOBillWorkQtyStatus_Tmp");
                ds = new SQLHelper.ClsCN().RunProcReturn("select isnull(sum(HQty),0) HQty,isnull(sum(HBadQty),0) HBadQty,isnull(sum(HWasterQty),0) HWasterQty   from Sc_ProcessReportSub with (nolock)" + sWhere, "Sc_ProcessReportSub");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    objJsonResult.code = "1";
@@ -650,9 +655,9 @@
        }
        #endregion
        #region æŠ¥å·¥å¹³å°äº§é‡æ±‡æŠ¥ä¿å­˜/编辑
        #region æŠ¥å·¥å¹³å°å·¥åºæ±‡æŠ¥ä¿å­˜/编辑
        /// <summary>
        /// å¼€å·¥å•
        /// å·¥åºæ±‡æŠ¥æäº¤
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
@@ -669,12 +674,12 @@
            ListModels oListModels = new ListModels();
            try
            {
                DLL.ClsSc_ICMOBillWorkQtyStatus_Tmp oBill = new DLL.ClsSc_ICMOBillWorkQtyStatus_Tmp();
                List<Models.ClsSc_ICMOBillWorkQtyStatus_Tmp> lsmain = new List<Models.ClsSc_ICMOBillWorkQtyStatus_Tmp>();
                DLL.ClsSc_ProcessReport oBill = new DLL.ClsSc_ProcessReport();
                List<Models.ClsSc_ProcessReportMain> lsmain = new List<Models.ClsSc_ProcessReportMain>();
                msg2 = msg2.Replace("\\", "");
                msg2 = msg2.Replace("\n", "");  //\n
                lsmain = oListModels.getObjectByJson_Gy_MESProductReportFrom(msg2);
                foreach (Models.ClsSc_ICMOBillWorkQtyStatus_Tmp oItem in lsmain)
                lsmain = oListModels.getObjectByJson_ProcessReportMain(msg2);
                foreach (Models.ClsSc_ProcessReportMain oItem in lsmain)
                {
                    if (refSav == "Add")
                    {
@@ -725,10 +730,11 @@
                        }
                    }
                    oItem.HBillType = "3724";
                    oItem.HBillSubType = "3724";
                    oItem.HReportType = 3;//(1条码扫描,2机器汇报,3手工录入)
                    oItem.HBillType = "3714";
                    oItem.HBillSubType = "3714";
                    oItem.HBillStatus = 1;   //单据状态(1未审,2审核通过,3关闭,4作废,5审核退回,6审核中,7已阅,8已回复,9结案,10验证,11下达,12开工,13申请审批,15申请检验,16 åˆ¤å®šåˆæ ¼ï¼Œ17判定不合格)     
                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
                    oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"));
                    if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "")
                    {
                        objJsonResult.code = "0";
@@ -738,6 +744,30 @@
                        return objJsonResult;
                    }
                    oBill.omodel = oItem;
                }
                //表体数据
                msg2 = msg2.Replace("\\", "");
                msg2 = msg2.Replace("\n", "");  //\n
                List<Models.ClsSc_ProcessReportSub> ls = new List<Models.ClsSc_ProcessReportSub>();
                ls = oListModels.getObjectByJson_ProcessReportSub(msg2);
                int i = 0;
                foreach (Models.ClsSc_ProcessReportSub oItemSub in ls)
                {
                    i++;
                    oItemSub.HEntryID = i;
                    //oItemSub.HCloseMan = "";       //行关闭
                    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
                    oItemSub.HCloseType = false;   //关闭类型
                    //oItemSub.HRemark = "";         //备注
                    oItemSub.HRelationQty = 0;     //关联数量
                    //oItemSub.HRelationMoney = 0;   //关联金额
                    //oItemSub.HRepairID = 0;       //维修项目
                    //oItemSub.HRepairExplanation ="";   //维修要求
                    //oItemSub.HManagerID = 0;   //负责人ID
                    //oItemSub.HMoney = 0;        //维修费用
                    oBill.DetailColl.Add(oItemSub);
                }
                //保存
@@ -753,7 +783,7 @@
                        string sReturn = "";
                        if (oSystemParameter.ShowBill(ref sReturn) == true)
                        {
                            if (oSystemParameter.omodel.Sc_ICMOBillWorkQtyStatus_AutoCheck == "Y") //系统参数  è‡ªåŠ¨å®¡æ ¸
                            if (oSystemParameter.omodel.Sc_MESProceReportWorkBill_AutoCheck == "Y") //系统参数  è‡ªåŠ¨å®¡æ ¸
                            {
                                objJsonResult.Verify = "Y";
                            }
@@ -797,7 +827,7 @@
        }
        #endregion
        #region æŠ¥å·¥å¹³å°äº§é‡æ±‡æŠ¥å®¡æ ¸ã€åå®¡æ ¸
        #region æŠ¥å·¥å¹³å°å·¥åºæ±‡æŠ¥å®¡æ ¸ã€åå®¡æ ¸
        /// <summary>
        /// 
        /// </summary>
@@ -809,7 +839,7 @@
        [HttpGet]
        public object MESProductAuditProcessReportList(int HSourceID, int HSourceInterID, int HSourceEntryID, string HSourceBillNo, int HICMOInterID, int HICMOEntryID, int HInterID, int IsAudit, string CurUserName)
        {
            string ModRightNameCheck = "MES_ProcExchReport_Check";
            string ModRightNameCheck = "MES_ProductReport_Check";
            DBUtility.ClsPub.CurUserName = CurUserName;
            try
            {
@@ -833,7 +863,7 @@
                }
                Int64 lngBillKey = 0;
                lngBillKey = DBUtility.ClsPub.isLong(HInterID);
                DLL.ClsSc_ICMOBillWorkQtyStatus_Tmp oBill = new DLL.ClsSc_ICMOBillWorkQtyStatus_Tmp();
                DLL.ClsSc_ProcessReport oBill = new DLL.ClsSc_ProcessReport();
                //查看是否已审核,关闭,作废
                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
                {
@@ -887,7 +917,7 @@
                if (IsAudit == 0) //审核提交
                {
                    //审核提交
                    if (oBill.CheckBill(HSourceID, HSourceInterID, HSourceEntryID, HSourceBillNo, HICMOInterID, HICMOEntryID, lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
@@ -907,7 +937,7 @@
                if (IsAudit == 1) //反审核提交
                {
                    //反审核提交AbandonCheck
                    if (oBill.AbandonCheck(HSourceID, HSourceInterID, HSourceEntryID, HSourceBillNo, HICMOInterID, HICMOEntryID, lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    if (oBill.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
@@ -945,17 +975,11 @@
            try
            {
                oCN.BeginTran();
                //查询产量汇报临时表数量
                ds = oCN.RunProcReturn("select isnull(HQty,0) HQty,isnull(HWasterQty,0) HWasterQty,isnull(HBadQty,0) HBadQty  from Sc_ICMOBillWorkQtyStatus_Tmp where HInterID='" + HInterID + "' and HICMOInterID='" + HICMOInterID + "' and HICMOEntryID='" + HICMOEntryID + "'", "Sc_ICMOBillWorkQtyStatus_Tmp");
                double HQty = double.Parse(ds.Tables[0].Rows[0]["HQty"].ToString());
                double HWasterQty = double.Parse(ds.Tables[0].Rows[0]["HWasterQty"].ToString());
                double HBadQty = double.Parse(ds.Tables[0].Rows[0]["HBadQty"].ToString());
                double sumqty = HQty + HBadQty + HWasterQty;  //汇报数量+不良+报废
                //更新产量装量临时表已汇报数量
                string sql1 = string.Format(@"update Sc_ICMOBillStatus_Tmp  set  HICMOStatus='1',HFinishFlag='0', HRelationInterID=0,HSplitRelationQty=HSplitRelationQty-" + sumqty + ",HDateFinishQty=HDateFinishQty-" + sumqty + "   where  HICMOInterID='" + HICMOInterID + "' and HICMOEntryID='" + HICMOEntryID + "'");
                //删除工序汇报子表
                string sql1 = string.Format(@"delete Sc_ProcessReportSub  where HInterID='"+HInterID+"' and   HICMOInterID='" + HICMOInterID + "' and HICMOEntryID='" + HICMOEntryID + "'");
                oCN.RunProc(sql1);
                //更新切换状态值
                string sql = string.Format(@"delete Sc_ICMOBillWorkQtyStatus_Tmp  where HInterID='" + HInterID + "'");
                //删除工序汇报主表
                string sql = string.Format(@"delete Sc_ProcessReportMain  where HInterID='" + HInterID + "'");
                oCN.RunProc(sql);
                oCN.Commit();