WebAPI/Controllers/SCGL/Èռƻ®¹ÜÀí/JIT_DayPlanPlatFormBillController.cs
@@ -8,6 +8,7 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Diagnostics;
using System.Threading;
namespace WebAPI.Controllers.SCGL.日计划管理
{
@@ -221,14 +222,16 @@
                            " HMaterID, HMaterName, HMaterModel, HUnitID, HSeOrderBillQty," +
                            " HOrderNeedQty, HSplitQty, HDayPlanSumQty,HPlanBeginDate," +
                            "HSeOrderBillNo,HICMOBillType,HSourceStockInQty,HLeftPlanQty,HOrderLev,HPreparatDate," +
                            "HMainSourceInterID,HMainSourceEntryID,HICMOInterID_Sec,HICMOEntryID_Sec,HPlanQty)values" +
                            "HMainSourceInterID,HMainSourceEntryID,HICMOInterID_Sec,HICMOEntryID_Sec,HPlanQty" +
                            ",HICMOInterID,HICMOEntryID)values" +
                            $"({HInterID},'{HBillNo}',{DateTime.Now.Year},{DateTime.Now.Month},'{BillType}'," +
                            $"'{BillType}',GETDATE(),1,'{user}',getdate(),'{HICMOBillNo}','{HOrderType}'," +
                            $"{(HICMOEntrySEQ == "" ? 0.ToString() : HICMOEntrySEQ)},{(HWorkShopID == "" ? 0.ToString() : HWorkShopID)},{(HSourceID == "" ? 0.ToString() : HSourceID)}, {(HYX == "" ? 0.ToString() : HYX)}, {(HProdORGID == "" ? 0.ToString() : HProdORGID)}," +
                            $" {(HMaterID == "" ? 0.ToString() : HMaterID)}, '{HMaterName}', '{HMaterModel}', {(HUnitID == "" ? 0.ToString() : HUnitID)}, {(HSeOrderBillQty == "" ? 0.ToString() : HSeOrderBillQty)}," +
                            $" 0, {(HSplitQty == "" ? 0.ToString() : HSplitQty)}, {(HDayPlanSumQty == "" ? 0.ToString() : HDayPlanSumQty)},'{HPlanBeginDate}'," +
                            $"'{HSeOrderBillNo}','{HICMOBillType}',{(HSourceStockInQty == "" ? 0.ToString() : HSourceStockInQty)},{(HLeftPlanQty == "" ? 0.ToString() : HLeftPlanQty)},'{HOrderLev}',getdate()," +
                            $"{HMainSourceInterID},{HMainSourceEntryID},{HMainSourceInterID},{HMainSourceEntryID},{HPlanQty})";
                            $"{HMainSourceInterID},{HMainSourceEntryID},{HMainSourceInterID},{HMainSourceEntryID},{HPlanQty}," +
                            $"{HMainSourceInterID},{HMainSourceEntryID})";
                        //LogService.Write("sql:" + sql);
                        //主表
@@ -242,6 +245,13 @@
                        var HICMOEntrySEQ = list[i]["生产订单明细行号"].ToString();
                        var HSourceID = list[i]["HSourceID"].ToString();
                        var HYX = list[i]["优先级"].ToString();
                        var HWorkQty = list[i]["小时产能"].ToString();
                        var HProdTimes = list[i]["生产周期"].ToString();
                        var HReadyTimes = list[i]["开工余量"].ToString();
                        var HLastBeginDate = list[i]["最迟开工日期"].ToString();
                        var HLastEndDate = list[i]["最迟完工日期"].ToString();
                        var HOrderNeedQty = list[i]["订单需求数量"].ToString();
                        var HOrderCommitDate = list[i]["订单交货期"].ToString();
                        if (HSourceID == "" || HSourceID == "0")
                        {
@@ -273,7 +283,10 @@
                            return objJsonResult;
                        }
                        oCN.RunProc($"update Sc_WorkBillSortBillMain set HSourceID={(HSourceID == "" ? 0.ToString() : HSourceID)},HYX={HYX} where HInterID={list[i]["hmainid"].ToString()} and HBillNo='{list[i]["单据号"].ToString()}'");
                        oCN.RunProc($"update Sc_WorkBillSortBillMain set HSourceID={(HSourceID == "" ? 0.ToString() : HSourceID)},HYX={HYX}" +
                            $",HWorkQty={HWorkQty},HProdTimes={HProdTimes},HReadyTimes={HReadyTimes},HLastBeginDate='{HLastBeginDate}'" +
                            $",HLastEndDate='{HLastEndDate}',HOrderNeedQty={HOrderNeedQty},HOrderCommitDate='{HOrderCommitDate}'" +
                            $" where HInterID={list[i]["hmainid"].ToString()} and HBillNo='{list[i]["单据号"].ToString()}'");
                    }
                    oCN.RunProc($"update Sc_WorkBillSortBillMain set HDayPlanSumQty={list[i]["日计划数量总量"].ToString()} where HInterID={(HInterID==0?int.Parse(list[i]["hmainid"].ToString()):HInterID)} and HBillNo='{(HBillNo==""?list[i]["单据号"].ToString(): HBillNo)}'");
@@ -2588,5 +2601,68 @@
        }
        #endregion
        #region ç”Ÿäº§æ—¥è®¡åˆ’平台 æ•°æ®å‡†å¤‡ è®¾ç½®ä»»åŠ¡å•ç›¸å…³ä¿¡æ¯
        [Route("JIT_DayPlanPlatFormBill/ReadyData")]
        [HttpGet]
        public object ReadyData(string HICOMNum)
        {
            try
            {
                var list = HICOMNum.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));
                for (int i = 0; i < list.Length; i++)
                {
                    string HICMOInterID = list[i].Split(';')[0].ToString();
                    string HICMOEntryID = list[i].Split(';')[1].ToString();
                    Thread.Sleep(100);
                    ds = oCN.RunProcReturn("exec h_p_Sc_GetInfoByICMOBillNo " + HICMOInterID+","+ HICMOEntryID, "h_p_Sc_GetInfoByICMOBillNo");
                    if (ds == null || ds.Tables[0].Rows.Count == 0)
                    {
                    }
                    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
    }
}