| | |
| | | [HotUpdate] |
| | | public class Pro_ScDayImport : AbstractDynamicFormPlugIn |
| | | { |
| | | CloudClient cloudClient = new CloudClient("http://localhost/K3Cloud/"); |
| | | private string fileFullPath = string.Empty; |
| | | //public override void BarItemClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BarItemClickEventArgs e) |
| | | //{ |
| | |
| | | DataTable dayPlanDt = DBServiceHelper.ExecuteDataSet(Context, sql).Tables[0]; |
| | | if (dayPlanDt.Rows.Count > 0) |
| | | { |
| | | fDayPlanID = _dt.Rows[0]["FID"].ToString(); |
| | | fDayPlanBillNo = _dt.Rows[0]["FBILLNO"].ToString(); |
| | | fDayPlanID = dayPlanDt.Rows[0]["FID"].ToString(); |
| | | fDayPlanBillNo = dayPlanDt.Rows[0]["FBILLNO"].ToString(); |
| | | } |
| | | //DynamicObject row = new DynamicObject(entity.DynamicObjectType); |
| | | this.Model.CreateNewEntryRow("FEntity"); |
| | |
| | | try |
| | | { |
| | | LogService.WriteAsync("测试"); |
| | | |
| | | string sql; |
| | | DateTime date = Convert.ToDateTime(this.Model.GetValue("F_Paez_Date")); |
| | | //获取单据体信息 |
| | | Entity entity = this.View.BillBusinessInfo.GetEntity("FEntity"); |
| | | //单据体信息转换为列表集合 |
| | | DynamicObjectCollection entityDataObjoct = this.View.Model.GetEntityDataObject(entity); |
| | | |
| | | List<string> sqlList = new List<string>(); |
| | | foreach (DynamicObject current in entityDataObjoct) |
| | | { |
| | | if (Convert.ToString(current["FDayPlanID"]) == "0") |
| | | continue; |
| | | for (int i = 0; i <= 60; i++) |
| | | { |
| | | JObject jsonFPOOrderEntry = new JObject(); |
| | | sql = string.Format($"update SC_WORKBILLSORTBILLSub set FHQTY ='{Convert.ToString(current["FT" + "" + i + ""])}' where FID ={Convert.ToString(current["FDayPlanID"])} and FHMASTERDATE ={date.AddDays(i).ToShortDateString()} and FHLOCKEDSUB = 0"); |
| | | sqlList.Add(sql); |
| | | } |
| | | } |
| | | int res = DBServiceHelper.ExecuteBatch(Context, sqlList); |
| | | string _result = ""; |
| | | foreach (DynamicObject current in entityDataObjoct) |
| | | { |
| | |
| | | this.View.ShowErrMessage(_result); |
| | | return; |
| | | } |
| | | |
| | | foreach (DynamicObject current in entityDataObjoct) |
| | | { |
| | | if (Convert.ToInt32(current["FNoScheduled"]) < 0) |
| | | _result += "序号:" + Convert.ToString(current["SEQ"]) + ",日计划总数量超出生产订单数量"; |
| | | |
| | | } |
| | | if (_result != "") |
| | | { |
| | | this.View.ShowErrMessage(_result); |
| | | return; |
| | | } |
| | | |
| | | foreach (DynamicObject current in entityDataObjoct) |
| | | { |
| | | if (string.IsNullOrEmpty(Convert.ToString(current["FSalOrderNo"])) || string.IsNullOrEmpty(Convert.ToString(current["FSCOrderNo"]))) |
| | | continue; |
| | | |
| | | //根据生产订单号和物料查询是否存在明细 |
| | | sql = string.Format(@"/*dialect*/SELECT T1.FBILLNO,T2.* FROM T_PRD_MO T1 |
| | | LEFT JOIN T_PRD_MOENTRY T2 ON T1.FID = T2.FID |
| | |
| | | dt = DBServiceHelper.ExecuteDataSet(Context, sql).Tables[0]; |
| | | if (dt.Rows.Count == 0) |
| | | continue; |
| | | |
| | | string FID = "";//FID 源单主内码 |
| | | string FENTRYID = "";//FENTRYID 源单子内码 |
| | | string FLOT = "";//FLOT 批次 |
| | | string FQTY = "";//FQTY 生产订单数量 |
| | | string FBILLNO = "";//FBILLNO 原单号 |
| | | |
| | | if (dt.Rows.Count > 0) |
| | | { |
| | | FID = dt.Rows[0]["FID"].ToString(); |
| | |
| | | jsonRoot.Add("Creator", ""); |
| | | jsonRoot.Add("NeedUpDateFields", new JArray()); |
| | | jsonRoot.Add("NeedReturnFields", new JArray()); |
| | | jsonRoot.Add("IsDeleteEntry", "true"); |
| | | jsonRoot.Add("IsDeleteEntry", "false"); |
| | | jsonRoot.Add("SubSystemId", ""); |
| | | jsonRoot.Add("IsVerifyBaseDataField", ""); |
| | | |
| | | JObject jsonModel = new JObject(); |
| | | jsonModel.Add("FPreparatDate", date.ToString());//编制日期 |
| | | jsonModel.Add("FSCOrderNo", current["FSCOrderNo"].ToString()); //生产订单号FSCOrderNo |
| | |
| | | jsonModel.Add("FPrdBillNo", FBILLNO); ;//源单编号 |
| | | jsonModel.Add("FPRDMOMAINID", FID); ;//源单主内码 |
| | | jsonModel.Add("FPRDMOENTYID", FENTRYID); ;//源单子内码 |
| | | |
| | | jsonModel.Add("FOrderQuantity", current["FOrderQuantity"].ToString()); ;//生产订单数量 |
| | | jsonModel.Add("FDayPlanQuantity", current["FDayPlanQuantity"].ToString()); ;//日计划数量 |
| | | jsonModel.Add("FNoScheduled", current["FNoScheduled"].ToString()); ;//未排数量 |
| | | |
| | | |
| | | |
| | | |
| | | JObject jsonFHMaterID = new JObject(); |
| | | jsonFHMaterID.Add("FNumber", (current["FMatrailId"] as DynamicObject)["Number"].ToString()); |
| | | jsonModel.Add("FHMaterID", jsonFHMaterID);//FHMaterID 物料 |
| | | |
| | | if (Convert.ToString(current["FORGID_Id"]) != "0") |
| | | { |
| | | JObject jsonFHPRDORGID = new JObject(); |
| | |
| | | jsonFProductWorkShopId.Add("FNumber", (current["FResourcesId"] as DynamicObject)["Number"].ToString()); |
| | | jsonModel.Add("FHSourceID", jsonFProductWorkShopId);//FHSourceID 生产车间 |
| | | } |
| | | |
| | | if (Convert.ToString(current["FProductWorkShopId_Id"]) != "0") |
| | | { |
| | | JObject jsonFResourcesId = new JObject(); |
| | |
| | | jsonModel.Add("FHWorkShopID", jsonFResourcesId);//FHWorkShopID 生产资源 |
| | | } |
| | | JArray Entry = new JArray(); |
| | | for (int i = 0; i <= 60; i++) |
| | | if (Convert.ToString(current["FDayPlanID"]) != "0") |
| | | { |
| | | JObject jsonFPOOrderEntry = new JObject(); |
| | | |
| | | jsonFPOOrderEntry.Add("FHMasterDate", date.AddDays(i).ToShortDateString()); ;//主日期 |
| | | jsonFPOOrderEntry.Add("FHQty ", Convert.ToString(current["FT" + "" + i + ""])); ;//日计划数量 |
| | | jsonFPOOrderEntry.Add("FColumn", "FT" + "" + i + ""); ;//对应的列头 |
| | | //jsonFPOOrderEntry.Add("FHMainSourceBillType ", "生产订单"); ;//源单类型 |
| | | //jsonFPOOrderEntry.Add("FHMainSourceBillNo", FBILLNO); ;//源单编号 |
| | | //jsonFPOOrderEntry.Add("FHMainSourceInterID", FID); ;//源单主内码 |
| | | //jsonFPOOrderEntry.Add("FHMainSourceEntryID", FENTRYID); ;//源单子内码 |
| | | |
| | | Entry.Add(jsonFPOOrderEntry); |
| | | sql = $"select max(FHMASTERDATE)FHMASTERDATE from SC_WORKBILLSORTBILLSub where FID={Convert.ToString(current["FDayPlanID"])} "; |
| | | DateTime EndDate = DBServiceHelper.ExecuteScalar<DateTime>(Context, sql, DateTime.Now); |
| | | for (int i = 0; i <= 60; i++) |
| | | { |
| | | if (EndDate >= date.AddDays(i)) |
| | | continue; |
| | | JObject jsonFPOOrderEntry = new JObject(); |
| | | jsonFPOOrderEntry.Add("FHMasterDate", date.AddDays(i).ToShortDateString()); ;//主日期 |
| | | jsonFPOOrderEntry.Add("FHQty ", Convert.ToString(current["FT" + "" + i + ""])); ;//日计划数量 |
| | | jsonFPOOrderEntry.Add("FColumn", "FT" + "" + i + ""); ;//对应的列头 |
| | | Entry.Add(jsonFPOOrderEntry); |
| | | } |
| | | } |
| | | |
| | | jsonModel.Add("FEntity", Entry); |
| | | //日计划工单不为空时update |
| | | if (Convert.ToString(current["FDayPlanID"]) != "0") |
| | |
| | | |
| | | this.Model.SetValue("FDayPlanBillNo", FDayPlanBillNo, Convert.ToInt32(current["SEQ"]) - 1);// |
| | | this.Model.SetValue("FDayPlanID", FDayPlanID, Convert.ToInt32(current["SEQ"]) - 1);// |
| | | |
| | | |
| | | this.View.ShowMessage("导入成功"); |
| | | |
| | | } |
| | |
| | | |
| | | } |
| | | } |
| | | |
| | | this.View.UpdateView(); |
| | | |
| | | |
| | | } |
| | | } |
| | | catch (Exception ex) |