1
yangle
19 小时以前 6d0bfe2160e06a4502dc3052c43fab9813341db3
WebAPI/Controllers/SCGL/Èռƻ®¹ÜÀí/JIT_DayPlanPlatFormBillController.cs
@@ -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)
                        {
@@ -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}行生产资源有重复,请修改!";
@@ -580,35 +580,64 @@
        }
        public json AddBillSub(string HInterID, string HBillNo, DateTime date, double HQTY, Dictionary<string, string> dic)
        {
        {
            string sReturn = "";
            oSystemParameter.ShowBill(ref sReturn);
            //获取表格数据
            ds = oCN.RunProcReturn($"select * from  h_v_JIT_Sc_WorkBillSortBill_PC where å•据号='{HBillNo}'", "h_v_JIT_Sc_WorkBillSortBill_PC");
            int count = 0;
            if (ds.Tables[0].Rows.Count > 0)
            {
                //判断子表是否有当日的日期以及日期所对应的数量
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                if (oSystemParameter.omodel.WMS_CampanyName == "添康科技") //系统参数  å®¢æˆ·å®šåˆ¶åŒ–名称     ç©ºç™½ä¸ºé€šç”¨
                {
                    if (DateTime.Parse(ds.Tables[0].Rows[i]["日计划生产日期"].ToString()) == date)
                    //判断子表是否有当日的日期以及日期所对应的数量
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        oCN.RunProc($"update Sc_WorkBillSortBillSub set HMasterDate='{date}',HQty={HQTY},HUseTimes={(dic["小时产能"]=="0"?0: HQTY / float.Parse(dic["小时产能"].ToString()))}" +
                            $"  where HInterID={HInterID} and HEntryID={ds.Tables[0].Rows[i]["hsubid"].ToString()}");
                        count += 1;
                        if (DateTime.Parse(ds.Tables[0].Rows[i]["日计划生产日期"].ToString()) == date)
                        {
                            oCN.RunProc($"update Sc_WorkBillSortBillSub set HMasterDate='{date}',HQty={HQTY},HUseTimes={(dic["产线总产能"] == "0" ? 0 : HQTY / float.Parse(dic["产线总产能"].ToString()))}" +
                                $"  where HInterID={HInterID} and HEntryID={ds.Tables[0].Rows[i]["hsubid"].ToString()}");
                            count += 1;
                        }
                    }
                }
                else
                {
                    //判断子表是否有当日的日期以及日期所对应的数量
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        if (DateTime.Parse(ds.Tables[0].Rows[i]["日计划生产日期"].ToString()) == date)
                        {
                            oCN.RunProc($"update Sc_WorkBillSortBillSub set HMasterDate='{date}',HQty={HQTY},HUseTimes={(dic["小时产能"] == "0" ? 0 : HQTY / float.Parse(dic["小时产能"].ToString()))}" +
                                $"  where HInterID={HInterID} and HEntryID={ds.Tables[0].Rows[i]["hsubid"].ToString()}");
                            count += 1;
                        }
                    }
                }
            }
           
            if (count != 1)
            {
                //插入子表
                oCN.RunProc("insert into Sc_WorkBillSortBillSub(HInterID,HSEQ," +
                    "HMasterDate,HQty,HUseTimes)" +
                            $"values({HInterID}, {(ds.Tables[0].Rows.Count + 1)}," +
                            $" '{date}', {HQTY},{ ((dic["小时产能"] == "0.0000" ? 0 : dic["小时产能"] == "0" ? 0 : HQTY / float.Parse(dic["小时产能"].ToString())).ToString() == "非数字" ? 0 : dic["小时产能"] == "0.0000" ? 0 : dic["小时产能"] == "0" ? 0 : HQTY / float.Parse(dic["小时产能"].ToString())) })");
                if (oSystemParameter.omodel.WMS_CampanyName == "添康科技") //系统参数  å®¢æˆ·å®šåˆ¶åŒ–名称     ç©ºç™½ä¸ºé€šç”¨
                {
                    //插入子表
                    oCN.RunProc("insert into Sc_WorkBillSortBillSub(HInterID,HSEQ," +
                        "HMasterDate,HQty,HUseTimes)" +
                                $"values({HInterID}, {(ds.Tables[0].Rows.Count + 1)}," +
                                $" '{date}', {HQTY},{ ((dic["产线总产能"] == "0.0000" ? 0 : dic["产线总产能"] == "0" ? 0 : HQTY / float.Parse(dic["产线总产能"].ToString())).ToString() == "非数字" ? 0 : dic["产线总产能"] == "0.0000" ? 0 : dic["产线总产能"] == "0" ? 0 : HQTY / float.Parse(dic["产线总产能"].ToString())) })");
                }
                else
                {
                    //插入子表
                    oCN.RunProc("insert into Sc_WorkBillSortBillSub(HInterID,HSEQ," +
                        "HMasterDate,HQty,HUseTimes)" +
                                $"values({HInterID}, {(ds.Tables[0].Rows.Count + 1)}," +
                                $" '{date}', {HQTY},{ ((dic["小时产能"] == "0.0000" ? 0 : dic["小时产能"] == "0" ? 0 : HQTY / float.Parse(dic["小时产能"].ToString())).ToString() == "非数字" ? 0 : dic["小时产能"] == "0.0000" ? 0 : dic["小时产能"] == "0" ? 0 : HQTY / float.Parse(dic["小时产能"].ToString())) })");
                }
            }
            string sReturn = "";
            oSystemParameter.ShowBill(ref sReturn);
            if (oSystemParameter.omodel.WMS_CampanyName == "添康科技") //系统参数  å®¢æˆ·å®šåˆ¶åŒ–名称     ç©ºç™½ä¸ºé€šç”¨
            {
                //把排产订单完工日期反写到金蝶销售订单上
@@ -961,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
            {
@@ -1410,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 ç”Ÿäº§æ—¥è®¡åˆ’平台 ææ–™è¿ç®—
@@ -1775,6 +1901,7 @@
                string fProWorkShopId = omdelMian.HWorkShopID.ToString();
                var fPrdOrgId = omdelMian.HProdORGID;
                string sqlName = "";//AIS20210811135644
                string WMS_CampanyName = "";    //客户名称
                //客户制定
                string sErr = "";
                if (oSystemParameter.ShowBill(ref sErr))
@@ -1782,36 +1909,58 @@
                    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 == "宝工")
                    {
                        sqlName = "AIS20250102123554";
                        WMS_CampanyName = "宝工";
                    }
                    else
                    {
                        sqlName = "AIS20210811135644";
                    }
                    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;
                }
                if (HTLType == "缺料")
                else
                {
                    objJsonResult = (json)JIT_QL(fProWorkShopId, fPrdOrgId, user, sqlName);
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "获取系统参数失败! " + sErr;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else if (HTLType == "生产用料清单")
                {
                 objJsonResult=(json)JIT_PPBOM(fProWorkShopId, fPrdOrgId, user, sqlName);
                }
                return objJsonResult;
            }
            catch (Exception e)
            {
@@ -2733,6 +2882,95 @@
                return objJsonResult;
            }
        }
        /// <summary>
        /// é€šè¿‡æ¬ æ–™è¡¨   ç®—提料 å®å·¥
        /// </summary>
        /// <returns></returns>
        public object JIT_MOMaterLack(string HWorkShopID, int? HProdORGID, string user)
        {
            try
            {
                ds = oCN.RunProcReturn("exec h_p_JIT_PODemandPlanBill_MOMaterLack " + HWorkShopID.ToString() + ",'" + user + "'," + HProdORGID.ToString(), "h_p_JIT_PODemandPlanBill_MOMaterLack");
                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;
            }
        }
        /// <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 ç”Ÿäº§æ—¥è®¡åˆ’平台 é”å®š
@@ -3376,5 +3614,7 @@
        }
        #endregion
    }
}