1
wtt
23 小时以前 d82756d630f5f9bcc588fee772b68bc2a7725cb0
WebAPI/Controllers/SCGL/Èռƻ®¹ÜÀí/JIT_DayPlanPlatFormBillController.cs
@@ -242,7 +242,7 @@
                        LogService.CustomWriteLog("2.05:" + i, DateTime.Now.ToString("yyyy-MM-dd"));
                        if (oSystemParameter.omodel.WMS_CampanyName != "添康科技") //系统参数  å®¢æˆ·å®šåˆ¶åŒ–名称     ç©ºç™½ä¸ºé€šç”¨
                        if (oSystemParameter.omodel.WMS_CampanyName != "添康科技"&& oSystemParameter.omodel.WMS_CampanyName != "三升") //系统参数  å®¢æˆ·å®šåˆ¶åŒ–名称     ç©ºç™½ä¸ºé€šç”¨
                        {
                            if (HSourceID == "" || HSourceID == "0")
                            {
@@ -254,7 +254,7 @@
                            }
                        }
                        ds = oCN.RunProcReturn($"select HInterID,HICMOBillNo from Sc_WorkBillSortBillMain with(nolock) where HMainSourceInterID={HMainSourceInterID}" +
                            $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID}", "Sc_WorkBillSortBillMain");
                            $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID} and ISNULL(HDeleteMan,'')=''", "Sc_WorkBillSortBillMain");
                        if (ds.Tables[0].Rows.Count > 0)
                        {
@@ -333,7 +333,7 @@
                        LogService.CustomWriteLog("2.1:"+i, DateTime.Now.ToString("yyyy-MM-dd"));
                        
                        if (oSystemParameter.omodel.WMS_CampanyName != "添康科技") //系统参数  å®¢æˆ·å®šåˆ¶åŒ–名称     ç©ºç™½ä¸ºé€šç”¨
                        if (oSystemParameter.omodel.WMS_CampanyName != "添康科技" && oSystemParameter.omodel.WMS_CampanyName != "三升") //系统参数  å®¢æˆ·å®šåˆ¶åŒ–名称     ç©ºç™½ä¸ºé€šç”¨
                        {
                            if (HSourceID == "" || HSourceID == "0")
                            {
@@ -470,13 +470,13 @@
                        else
                        {
                            ds = oCN.RunProcReturn($"select HInterID,HICMOBillNo from Sc_WorkBillSortBillMain with(nolock) where HMainSourceInterID={HMainSourceInterID}" +
                             $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID}", "Sc_WorkBillSortBillMain");
                             $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID} and ISNULL(HDeleteMan,'') = ''", "Sc_WorkBillSortBillMain");
                            if (ds.Tables[0].Rows.Count > 1)
                            {
                                LogService.CustomWriteLog("第" + i + 1 + "行生产资源有重复,请修改", DateTime.Now.ToString("yyyy-MM-dd"));
                                LogService.CustomWriteLog($"select * from  Sc_WorkBillSortBillMain where HMainSourceInterID={HMainSourceInterID}" +
                                  $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID}", DateTime.Now.ToString("yyyy-MM-dd"));
                                  $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID} and ISNULL(HDeleteMan,'')=''", DateTime.Now.ToString("yyyy-MM-dd"));
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = $"第{i + 1}行生产资源有重复,请修改!";
@@ -518,7 +518,7 @@
                    for (int j = 0; j < SumDay; j++)
                    {
                        //主表子表都有数据
                        if (list[i][DateTime.Now.AddDays(j).ToString("yyyy-MM-dd")].ToString() != "")
                        if (list[i][DateTime.Now.AddDays(j).ToString("yyyy-MM-dd")].ToString() != ""&& Math.Round(double.Parse(list[i][DateTime.Now.AddDays(j).ToString("yyyy-MM-dd")].ToString()),1)>0)
                        {
                            SumCount += 1;
                            ////保存子表
@@ -990,9 +990,9 @@
        }
        #endregion
        [Route("JIT_DayPlanPlatFormBill/JIT_CompleteSetAnalysis")]
        [HttpGet]
        public object JIT_CompleteSetAnalysis(string sWhere, string user)
        #region é½å¥—分析    åŽŸè°ƒç”¨æ–¹æ³•
        public object JIT_CompleteSetAnalysis_Old(string sWhere, string user)
        {
            try
            {
@@ -1439,6 +1439,103 @@
                return objJsonResult;
            }
        }
        #endregion
        #region é½å¥—分析调用方法    20250402
        [Route("JIT_DayPlanPlatFormBill/JIT_CompleteSetAnalysis")]
        [HttpGet]
        public object JIT_CompleteSetAnalysis(string sWhere, string user)
        {
            try
            {
                string sErrMsg = "";
                if (oSystemParameter.ShowBill(ref sErrMsg) == true)
                {
                    if (oSystemParameter.omodel.WMS_CampanyName == "帅威"
                        || oSystemParameter.omodel.WMS_CampanyName == "凯贝奈特"
                        || oSystemParameter.omodel.WMS_CampanyName == "添康科技"
                        || oSystemParameter.omodel.WMS_CampanyName == "宝工")     //系统参数  å®¢æˆ·å®šåˆ¶åŒ–名称     ç©ºç™½ä¸ºé€šç”¨
                    {
                        objJsonResult = (json)JIT_CompleteSetAnalysis_Old(sWhere, user);
                    }
                    else
                    {
                        objJsonResult = (json)JIT_CompleteSetAnalysis_New(sWhere, user);
                    }
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "获取系统参数失败! " + sErrMsg;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                LogService.Write("齐套分析操作失败:" + e.Message.ToString());
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.Message.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        /// <summary>
        /// é½å¥—分析    æ–°è°ƒç”¨æ–¹æ³•
        /// </summary>
        /// <returns></returns>
        public object JIT_CompleteSetAnalysis_New(string sWhere, string user)
        {
            try
            {
                omdelMian = JsonConvert.DeserializeObject<Sc_WorkBillSortBillMain>(sWhere);
                string HWorkShopID = omdelMian.HWorkShopID.ToString();
                var HStockOrgID = omdelMian.HProdORGID;
                ds = oCN.RunProcReturn("exec h_p_JIT_CompleteSetAnalysis " + HWorkShopID.ToString() + ",'" + user + "'," + HStockOrgID.ToString(), "h_p_JIT_CompleteSetAnalysis");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    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)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]);
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    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)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "齐套分析失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #endregion
        #region ç”Ÿäº§æ—¥è®¡åˆ’平台 ææ–™è¿ç®—
@@ -1812,14 +1909,17 @@
                    if (oSystemParameter.omodel.WMS_CampanyName == "帅威")
                    {
                        sqlName = "AIS20230129011339";
                        WMS_CampanyName = "帅威";
                    }
                    else if (oSystemParameter.omodel.WMS_CampanyName == "凯贝奈特")
                    {
                        sqlName = "AIS20210820164804";
                        WMS_CampanyName = "凯贝奈特";
                    }
                    else if (oSystemParameter.omodel.WMS_CampanyName == "添康科技")
                    {
                        sqlName = "AIS20240809105013";
                        WMS_CampanyName = "添康科技";
                    }
                    else if (oSystemParameter.omodel.WMS_CampanyName == "宝工")
                    {
@@ -1830,22 +1930,37 @@
                    {
                        sqlName = "AIS20210811135644";
                    }
                }
                if (WMS_CampanyName == "宝工")
                {
                    objJsonResult = (json)JIT_MOMaterLack(fProWorkShopId, fPrdOrgId, user, sqlName);
                }
                else if (HTLType == "缺料")
                {
                    objJsonResult = (json)JIT_QL(fProWorkShopId, fPrdOrgId, user, sqlName);
                }
                else if (HTLType == "生产用料清单")
                {
                 objJsonResult=(json)JIT_PPBOM(fProWorkShopId, fPrdOrgId, user, sqlName);
                }
                    if (WMS_CampanyName == "宝工")
                    {
                        objJsonResult = (json)JIT_MOMaterLack(fProWorkShopId, fPrdOrgId, user);
                    }
                    else if (HTLType == "缺料")
                    {
                        if (WMS_CampanyName == "帅威" || WMS_CampanyName == "凯贝奈特" || WMS_CampanyName == "添康科技")
                        {
                            objJsonResult = (json)JIT_QL(fProWorkShopId, fPrdOrgId, user, sqlName);
                        }
                        else
                        {
                            objJsonResult = (json)JIT_MOMaterReady(fProWorkShopId, fPrdOrgId, user);
                        }
                    }
                    else if (HTLType == "生产用料清单")
                    {
                        objJsonResult = (json)JIT_PPBOM(fProWorkShopId, fPrdOrgId, user, sqlName);
                    }
                return objJsonResult;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "获取系统参数失败! " + sErr;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
@@ -2772,7 +2887,7 @@
        /// é€šè¿‡æ¬ æ–™è¡¨   ç®—提料 å®å·¥
        /// </summary>
        /// <returns></returns>
        public object JIT_MOMaterLack(string HWorkShopID, int? HProdORGID, string user, string sqlName)
        public object JIT_MOMaterLack(string HWorkShopID, int? HProdORGID, string user)
        {
            try
            {
@@ -2807,6 +2922,100 @@
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "提料运算失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        /// <summary>
        /// é€šè¿‡é½å¥—表   ç®—提料
        /// </summary>
        /// <returns></returns>
        public object JIT_MOMaterReady(string HWorkShopID, int? HProdORGID, string user)
        {
            try
            {
                ds = oCN.RunProcReturn("exec h_p_JIT_PODemandPlanBill_MOMaterReady " + HWorkShopID.ToString() + ",'" + user + "'," + HProdORGID.ToString(), "h_p_JIT_PODemandPlanBill_MOMaterReady");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    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)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]);
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    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)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "提料运算失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region ç”Ÿäº§æ—¥è®¡åˆ’平台 è¦æ–™è¿ç®—
        [Route("JIT_DayPlanPlatFormBill/JIT_YLYS")]
        [HttpGet]
        public object JIT_YLYS(string sWhere, string user)
        {
            try
            {
                omdelMian = JsonConvert.DeserializeObject<Sc_WorkBillSortBillMain>(sWhere);
                string HWorkShopID = omdelMian.HWorkShopID.ToString();
                var HStockOrgID = omdelMian.HProdORGID;
                ds = oCN.RunProcReturn("exec h_p_JIT_WorkDemandPlanBill_MOMaterReady " + HWorkShopID.ToString() + ",'" + user + "'," + HStockOrgID.ToString(), "h_p_JIT_WorkDemandPlanBill_MOMaterReady");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    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)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]);
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    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)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "要料运算失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -3035,6 +3244,74 @@
                    else
                    {
                        DataRow dr = dt.NewRow();
                        dr["小时产能"] = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[0]["产能"]);
                        dr["生产周期"] = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[0]["生产周期"]);
                        dr["开工余量"] = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[0]["开工余量"]);
                        dr["最迟开工日期"] = DBUtility.ClsPub.isDate(ds.Tables[0].Rows[0]["最迟开工日期"]);
                        dr["最迟完工日期"] = DBUtility.ClsPub.isDate(ds.Tables[0].Rows[0]["最迟完工日期"]);
                        dr["订单需求数量"] = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[0]["订单需求数"]);
                        dr["订单交货期"] = DBUtility.ClsPub.isDate(ds.Tables[0].Rows[0]["订单交货期"]);
                        dr["HICMOInterID"] = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[0]["HICMOInterID"]);
                        dr["HICMOEntryID"] = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[0]["HICMOEntryID"]);
                        dt.Rows.Add(dr);
                    }
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = dt;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region ç”Ÿäº§æ—¥è®¡åˆ’平台 æ•°æ®å‡†å¤‡ è®¾ç½®ä»»åŠ¡å•ç›¸å…³ä¿¡æ¯(三升)
        [Route("JIT_DayPlanPlatFormBill/ReadyData_SS")]
        [HttpGet]
        public object ReadyData_SS(string SWhere)
        {
            try
            {
                var list = SWhere.Split(',');
                DataTable dt = new DataTable("date");
                dt.Columns.Add("HICMOInterID", typeof(string));
                dt.Columns.Add("HICMOEntryID", typeof(string));
                dt.Columns.Add("小时产能", typeof(string));
                dt.Columns.Add("生产周期", typeof(decimal));
                dt.Columns.Add("开工余量", typeof(decimal));
                dt.Columns.Add("最迟开工日期", typeof(DateTime));
                dt.Columns.Add("最迟完工日期", typeof(DateTime));
                dt.Columns.Add("订单需求数量", typeof(decimal));
                dt.Columns.Add("订单交货期", typeof(DateTime));
                dt.Columns.Add("HSourceID", typeof(decimal));
                dt.Columns.Add("生产资源", typeof(string));
                for (int i = 0; i < list.Length; i++)
                {
                    string HICMOInterID = list[i].Split(';')[0].ToString();
                    string HICMOEntryID = list[i].Split(';')[1].ToString();
                    string HSourceID = list[i].Split(';')[2].ToString();
                    Thread.Sleep(100);
                    ds = oCN.RunProcReturn("exec h_p_Sc_GetInfoByICMOBillNo " + HICMOInterID + "," + HICMOEntryID + "," + HSourceID, "h_p_Sc_GetInfoByICMOBillNo");
                    if (ds == null || ds.Tables[0].Rows.Count == 0)
                    {
                    }
                    else
                    {
                        DataRow dr = dt.NewRow();
                        dr["HSourceID"] = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[0]["HSourceID"]);
                        dr["生产资源"] = ds.Tables[0].Rows[0]["生产资源"].ToString();
                        dr["小时产能"] = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[0]["产能"]);
                        dr["生产周期"] = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[0]["生产周期"]);
                        dr["开工余量"] = DBUtility.ClsPub.isSingle(ds.Tables[0].Rows[0]["开工余量"]);
@@ -3455,5 +3732,7 @@
        }
        #endregion
    }
}