/// <summary>人員配置のセーブ /// </summary> public XmlElement SaveRequirePatterns(XmlDocument doc, CTimeTable all) { XmlElement element = doc.CreateElement("requires"); SaveTmElement(doc, element, all.Requires); for (int i = 0; i < all.Requires.Size(true); i++) { CRequirePatterns require = all.Requires[i, true]; if (!require.BuiltIn) { XmlElement pNode = doc.CreateElement("require"); SaveTmElement(doc, pNode, require); pNode.SetAttribute("name", require.Name); // シフトごとの人数 for (int j = 0; j < require.Size(); j++) { CPattern pattern = require.GetPattern(j); int needs = require.GetRequire(pattern); if (needs > 0) { XmlElement nNode = doc.CreateElement("pattern"); nNode.SetAttribute("patternid", pattern.ObjectID.ToString()); nNode.SetAttribute("requirenums", needs.ToString()); pNode.AppendChild(nNode); } } // エレメントを追加 element.AppendChild(pNode); } } return(element); }
/// <summary> /// パターンに対してマッチしているか? /// </summary> /// <param name="pattern">パターン</param> /// <returns>割合</returns> private double CheckPatternMuches(CPattern pattern) { double ret = 0; CRequirePatterns require = sdate.Require; if (require == null || require == CRequirePatterns.DAYOFF || require == CRequirePatterns.NULL) { // 休みなら常に条件を満たすことにする(必要人数が0だから) ret = 1.0; } else { int need = require.GetRequire(pattern); if (need <= 0) { // 必要人数が0なら条件を常に満たす・・かな? ret = 1.0; } else { // 割合を計算してみる int seed = GetPatternMemberCount(pattern); ret = (double)seed / (double)need; if (ret < 1) { if (ret <= 0.0) { AddItem(EvaluationResult.ERROR, pattern.Name + "が必要な人数を満たしていません。(" + need + "人中" + seed + "人)"); } else if (ret < 0.5) { AddItem(EvaluationResult.WARNING, pattern.Name + "が必要な人数の半分を満たしていません。(" + need + "人中" + seed + "人)"); } else if (ret < 1) { AddItem(EvaluationResult.NOTICE, pattern.Name + "が必要な人数を満たしていません。(" + need + "人中" + seed + "人)"); } } } } return(ret); }
/// <summary>勤務シフトに対してマッチしているか? /// </summary> /// <param name="pattern">勤務シフト</param> /// <returns>割合</returns> private double CheckPatternMuches(CPattern pattern) { double ret = 0; CRequirePatterns require = sdate.Require; if (require == null || require == CRequirePatterns.DAYOFF || require == CRequirePatterns.NULL) { // 休みなら常に条件を満たすことにする(人員配置が0だから) ret = 1.0; } else { int need = require.GetRequire(pattern); if (need <= 0) { // 人員配置が0なら条件を常に満たす・・かな? ret = 1.0; } else { // 割合を計算してみる int seed = GetPatternMemberCount(pattern); ret = (double)seed / (double)need; if (ret < 1) { if (ret <= 0.0) { AddItem(EEvaluationResult.ERROR, GenerateMessage(msg_needs_unmuch_error, new string[] { pattern.Name, need.ToString(), seed.ToString() })); } else if (ret < 0.5) { AddItem(EEvaluationResult.WORNING, GenerateMessage(msg_needs_unmuch_worning, new string[] { pattern.Name, need.ToString(), seed.ToString() })); } else if (ret < 1) { AddItem(EEvaluationResult.NOTICE, GenerateMessage(msg_needs_unmuch_notice, new string[] { pattern.Name, need.ToString(), seed.ToString() })); } } } } return(ret); }
/// <summary>人員配置のインポート /// </summary> /// <param name="requires">インポートする人員配置</param> /// <returns>成功:追加したエレメント/不成功:null</returns> private CRequirePatterns ImportRequires(CRequirePatterns requires) { #region 重複チェック CRequirePatternsCollection col = Target.Requires; if (col.GetByName(requires.Name) != null) { return(null); } if (col.Size() >= FMainForm.MaxItemCount) { return(null); } #endregion #region インポート CRequirePatterns newrequires = col.CreateRequirePatterns(true); newrequires.Name = requires.Name; for (int i = 0; i < Source.Patterns.Size(true); i++) { CPattern pattern = Source.Patterns[i, true]; int needs = requires.GetRequire(pattern); if (!pattern.BuiltIn && (pattern.Removed == null || needs > 0)) { CPattern newpattern = Target.Patterns.GetByName(pattern.Name); if (newpattern == null) { newpattern = ImportPattern(pattern); } newrequires.SetRequire(newpattern, needs); } } newrequires.Notes = requires.Notes + "\nインポートされました。"; foreach (string key in requires.properties.AllKeys) { newrequires[key] = requires[key]; } #endregion col.AddRequirePatterns(newrequires); // 終端 return(newrequires); }