王 垚
2021-03-25 4c23c16bdda552f6e8c027de9f3e0bb1a7d210cb
src/BLL/Demo.BillView/PRD/Pro_WorkBillPlatform.cs
@@ -2,13 +2,11 @@
using Demo.Model.Model.PODemandPlan;
using K3Cloud.Extend.Utils;
using Kingdee.BOS.Core;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.Const;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Core.Metadata.EntityElement;
using Kingdee.BOS.JSON;
using Kingdee.BOS.KDThread;
@@ -18,25 +16,16 @@
using Kingdee.BOS.Util;
using Kingdee.K3.Core.SCM.STK;
using Kingdee.K3.SCM.ServiceHelper;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NPOI.HSSF.UserModel;
using NPOI.SS.Formula.Functions;
using NPOI.SS.UserModel;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using System.Windows.Documents;
using ZD.Cloud.Logger;
using ZD.Cloud.WebApi;
using ZD.Share.Common;
@@ -267,7 +256,7 @@
            jObject.Put("desc", "请点击打开附件:");
            jObject.Put("urltitle", "这是文件名");
            this.View.AddAction(JSAction.openUrlWindow, new JSONArray { jObject });
        }
        }
        /// <summary>
        /// 锁定
        /// </summary>
@@ -327,7 +316,7 @@
            Entity entity = this.View.BillBusinessInfo.GetEntity("FEntity");
            //单据体信息转换为列表集合
            DynamicObjectCollection entityDataObjoct = this.View.Model.GetEntityDataObject(entity);
            DateTime date = DateTime.Now;
            DateTime date = Convert.ToDateTime(DateTime.Now.ToString("d"));
            string _result = "";
@@ -345,34 +334,71 @@
            foreach (DynamicObject current in entityDataObjoct)
            {
                sql = $"/*dialect*/ update Sc_WorkBillSortBillMain set FOrderQuantity={current["FOrderQuantity"]},FDayPlanQuantity={current["FDayPlanQuantity"]},FNoScheduled={current["FNoScheduled"]} where FID = {current["FDayPlanWorkID"]}";
                sqlList.Add(sql);
                DateTime FBzDate = Convert.ToDateTime(Convert.ToDateTime(current["FBzDate"]));
                DateTime end = Convert.ToDateTime(Convert.ToDateTime(current["FBzDate"]).AddDays(60).ToShortDateString());//最大日期
                JObject jsonRoot = new JObject();
                jsonRoot.Add("Creator", "");
                jsonRoot.Add("NeedUpDateFields", new JArray());
                jsonRoot.Add("NeedReturnFields", new JArray());
                jsonRoot.Add("IsDeleteEntry", "false");
                jsonRoot.Add("SubSystemId", "");
                jsonRoot.Add("IsVerifyBaseDataField", "");
                JObject jsonModel = new JObject();
                jsonModel.Add("FID", Convert.ToString(current["FDayPlanWorkID"]));
                jsonModel.Add("FOrderQuantity", Convert.ToString(current["FOrderQuantity"]));
                jsonModel.Add("FDayPlanQuantity", Convert.ToString(current["FDayPlanQuantity"]));
                jsonModel.Add("FNoScheduled", Convert.ToString(current["FNoScheduled"]));
                sql = $" /*dialect*/ select FEntryID, FHMASTERDATE from SC_WORKBILLSORTBILLSub  where FID={Convert.ToString(current["FDayPlanWorkID"])} ";
                List<DayPlanModel> dayPlanModel = new List<DayPlanModel>();
                dayPlanModel = DBServiceHelper.ExecuteDataSet(Context, sql).ToModelList<DayPlanModel>();
                JArray Entry = new JArray();
                for (int i = 0; i <= 60; i++)
                {
                    DateTime start = Convert.ToDateTime(date.AddDays(i).ToShortDateString());
                    TimeSpan getDay = end.Subtract(start);
                    //编制日期+61天>date.AddDays(i).ToShortDateString() continue
                    if (getDay.Days < 0)
                        break;
                    sql = $"/*dialect*/update t1 set FHQTY='{Convert.ToString(current["FT" + "" + i + ""])}' from Sc_WorkBillSortBillSub t1 join " +
                        $" Sc_WorkBillSortBillMain t2 on  t1.FID = t2.FID where FHMASTERDATE='{date.AddDays(i).ToShortDateString()}' and t2.FID='{Convert.ToString(current["FDayPlanWorkID"])}'";
                    sqlList.Add(sql);
                    if (Convert.ToString(current["FT" + "" + i + ""]) == "" || Convert.ToString(current["FT" + "" + i + ""]) == "0")
                        continue;
                    JObject jsonFPOOrderEntry = new JObject();
                    jsonFPOOrderEntry.Add("FHMasterDate", date.AddDays(i).ToShortDateString()); ;//主日期
                    jsonFPOOrderEntry.Add("FHQty ", Convert.ToString(current["FT" + "" + i + ""])); ;//日计划数量
                    List<DayPlanModel> _dayPlanModel = dayPlanModel.Where(x => x.FHMASTERDATE == date.AddDays(i)).ToList();
                    if (_dayPlanModel.Count > 0)
                    {
                        jsonFPOOrderEntry.Add("FEntryID", _dayPlanModel.FirstOrDefault().FEntryID); ;//序号
                    }
                    Entry.Add(jsonFPOOrderEntry);
                }
                jsonModel.Add("FEntity", Entry);
                jsonRoot.Add("Model", jsonModel);
                CloudClient cloudClient = new CloudClient("http://localhost//k3cloud/");
                var result = cloudClient.Save("Paez_Sc_WorkBillAutoSortBill", jsonRoot.ToString());
                JObject saveObj = JObject.Parse(result);
                string saveIsSuc = saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper();
                if (saveIsSuc != "TRUE")
                {
                    LogHelper.Error("生产计划平台保存失败:" + jsonRoot.ToString());
                    this.View.ShowMessage("数据储存失败!请联系管理员!");
                }
                //sql = $"/*dialect*/ update Sc_WorkBillSortBillMain set FOrderQuantity={current["FOrderQuantity"]},FDayPlanQuantity={current["FDayPlanQuantity"]},FNoScheduled={current["FNoScheduled"]} where FID = {current["FDayPlanWorkID"]}";
                //sqlList.Add(sql);
                //DateTime FBzDate = Convert.ToDateTime(Convert.ToDateTime(current["FBzDate"]));
                //DateTime end = Convert.ToDateTime(Convert.ToDateTime(current["FBzDate"]).AddDays(60).ToShortDateString());//最大日期
                //for (int i = 0; i <= 60; i++)
                //{
                //    DateTime start = Convert.ToDateTime(date.AddDays(i).ToShortDateString());
                //    TimeSpan getDay = end.Subtract(start);
                //    //编制日期+61天>date.AddDays(i).ToShortDateString() continue
                //    if (getDay.Days < 0)
                //        break;
                //    sql = $"/*dialect*/update t1 set FHQTY='{Convert.ToString(current["FT" + "" + i + ""])}' from Sc_WorkBillSortBillSub t1 join " +
                //        $" Sc_WorkBillSortBillMain t2 on  t1.FID = t2.FID where FHMASTERDATE='{date.AddDays(i).ToShortDateString()}' and t2.FID='{Convert.ToString(current["FDayPlanWorkID"])}'";
                //    sqlList.Add(sql);
                //}
            }
            int result = DBServiceHelper.ExecuteBatch(Context, sqlList);
            this.View.ShowMessage("操作成功");
            SearchList();
            //if (result > 0)
            //{
            //}
            //else
            //    this.View.ShowMessage("操作失败,联系管理员!");
        }
        /// <summary>
        /// 齐套分析
@@ -645,7 +671,7 @@
                    if (item.FOwnerId != null)
                        jsonModel.Add("FOwnerId", new JObject() { ["FNUMBER"] = item.FOwnerId });
                    jsonRoot.Add("Model", jsonModel);
                    CloudClient cloudClient = new CloudClient("http://localhost/K3Cloud/");
                    CloudClient cloudClient = new CloudClient("http://localhost//k3cloud/");
                    var result = cloudClient.Save("paez_CompleteAnalysisTemp", jsonRoot.ToString());
                    JObject saveObj = JObject.Parse(result);
                    string saveIsSuc = saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper();
@@ -896,7 +922,7 @@
                            ["IsVerifyBaseDataField"] = "false",
                            ["Model"] = Fentity
                        };
                        CloudClient cloudClient = new CloudClient("http://localhost/K3Cloud/");
                        CloudClient cloudClient = new CloudClient("http://localhost//k3cloud/");
                        var result = cloudClient.BatchSave("paez_CompleteAnalysisTemp", jsonRoot.ToString());
                        JObject saveObj = JObject.Parse(result);
                        string saveIsSuc = saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper();
@@ -1489,7 +1515,7 @@
                            ["Model"] = model
                        };
                        CloudClient cloudClient = new CloudClient("http://localhost/K3Cloud/");
                        CloudClient cloudClient = new CloudClient("http://localhost//k3cloud/");
                        var result = cloudClient.Save("Paez_Sc_DayPlanPPBomBill", jsonRoot.ToString());
                        JObject saveObj = JObject.Parse(result);
                        string saveIsSuc = saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper();
@@ -1644,13 +1670,13 @@
                                ["IsVerifyBaseDataField"] = "false",
                                ["Model"] = Fentity
                            };
                            CloudClient cloudClient = new CloudClient("http://localhost/K3Cloud/");
                            CloudClient cloudClient = new CloudClient("http://localhost//k3cloud/");
                            var result = cloudClient.BatchSave("Paez_Sc_DayPlanPPBomBill", jsonRoot.ToString());
                            JObject saveObj = JObject.Parse(result);
                            string saveIsSuc = saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper();
                            if (saveIsSuc != "TRUE")
                            {
                                LogHelper.Error(jsonRoot.ToString());
                                LogHelper.Error(saveObj.ToString());
                            }
                            Fentity = new JArray();
                        }
@@ -2073,7 +2099,7 @@
                            ["IsVerifyBaseDataField"] = "false",
                            ["Model"] = FinalyResult
                        };
                        CloudClient cloudClient = new CloudClient("http://localhost/K3Cloud/");
                        CloudClient cloudClient = new CloudClient("http://localhost//k3cloud/");
                        var result = cloudClient.BatchSave("paez_PODemandPlan", jsonRoot.ToString());
                        JObject saveObj = JObject.Parse(result);
                        string saveIsSuc = saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper();