リビジョン 479
製品版:玄武対応
| trunk/ddl/ProductType3.SQL | ||
|---|---|---|
| 134 | 134 |
|
| 135 | 135 |
LOCK TABLES `processexcutemaster` WRITE; |
| 136 | 136 |
/*!40000 ALTER TABLE `processexcutemaster` DISABLE KEYS */; |
| 137 |
INSERT INTO `processexcutemaster` VALUES (1,1,1,NOW(),NOW()),(1,2,1,NOW(),NOW()),(1,3,1,NOW(),NOW()),(1,4,1,NOW(),NOW()),(1,5,1,NOW(),NOW()),(1,6,1,NOW(),NOW()),(1,7,1,NOW(),NOW()),(1,8,1,NOW(),NOW()),(1,9,1,NOW(),NOW()),(1,10,1,NOW(),NOW()),(1,12,1,NOW(),NOW()),(1,13,1,NOW(),NOW()),(1,19,1,NOW(),NOW()),(1,30,1,NOW(),NOW()),(1,31,1,NOW(),NOW()),(1,32,1,NOW(),NOW()),(1,37,1,NOW(),NOW()),(1,39,0,NOW(),NOW()),(1,40,1,NOW(),NOW()),(1,41,0,NOW(),NOW()),(1,42,1,NOW(),NOW()),(1,45,0,NOW(),NOW()),(1,47,1,NOW(),NOW()),(1,101,1,NOW(),NOW()),(1,102,1,NOW(),NOW()),(1,103,1,NOW(),NOW()),(1,104,1,NOW(),NOW()),(1,105,1,NOW(),NOW()),(1,106,1,NOW(),NOW()),(1,107,1,NOW(),NOW()),(1,108,1,NOW(),NOW()),(1,109,1,NOW(),NOW()),(1,110,1,NOW(),NOW()),(1,111,1,NOW(),NOW()),(1,112,1,NOW(),NOW()),(1,114,1,NOW(),NOW()),(1,117,1,NOW(),NOW()),(1,119,0,NOW(),NOW()),(1,120,1,NOW(),NOW()),(1,123,1,NOW(),NOW()),(1,124,1,NOW(),NOW()),(1,125,1,NOW(),NOW()),(1,126,1,NOW(),NOW()),(1,131,1,NOW(),NOW()),(1,132,1,NOW(),NOW()),(1,133,1,NOW(),NOW()),(1,134,1,NOW(),NOW()),(1,135,1,NOW(),NOW());
|
|
| 137 |
INSERT INTO `processexcutemaster` VALUES (1,1,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,2,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,3,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,4,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,5,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,6,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,7,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,8,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,9,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,10,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,11,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,12,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,13,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,14,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,15,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,16,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,17,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,19,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,29,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,30,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,31,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,32,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,37,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,39,0,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,40,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,41,0,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,42,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,44,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,45,0,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,47,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,101,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,102,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,103,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,104,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,105,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,106,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,107,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,108,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,109,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,110,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,111,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,112,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,114,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,115,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,116,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,117,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,119,0,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,120,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,122,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,123,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,124,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,125,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,126,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,131,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,132,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,133,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,134,1,'2020-03-26 10:11:11','2020-03-26 10:11:11'),(1,135,1,'2020-03-26 10:11:11','2020-03-26 10:11:11');
|
|
| 138 | 138 |
/*!40000 ALTER TABLE `processexcutemaster` ENABLE KEYS */; |
| 139 | 139 |
UNLOCK TABLES; |
| 140 | 140 |
|
| trunk/src/DataCheckExcute/DataCheckExcute/App.config | ||
|---|---|---|
| 1 |
<?xml version="1.0" encoding="utf-8"?> |
|
| 2 |
<configuration> |
|
| 3 |
<startup> |
|
| 4 |
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> |
|
| 5 |
</startup> |
|
| 6 |
</configuration> |
|
| trunk/src/DataCheckExcute/DataCheckExcute/Common/CommonVersion.cs | ||
|---|---|---|
| 1 |
using System; |
|
| 2 |
using System.Collections.Generic; |
|
| 3 |
using System.Linq; |
|
| 4 |
using System.Text; |
|
| 5 |
using System.Threading.Tasks; |
|
| 6 |
|
|
| 7 |
namespace ProcessManagement.Common |
|
| 8 |
{
|
|
| 9 |
/// <summary> |
|
| 10 |
/// システムバージョン定義クラス |
|
| 11 |
/// </summary> |
|
| 12 |
public static class CommonVersion |
|
| 13 |
{
|
|
| 14 |
/// <summary> |
|
| 15 |
/// 本体バージョン |
|
| 16 |
/// </summary> |
|
| 17 |
public static int s_SystemVersion = 0; |
|
| 18 |
} |
|
| 19 |
} |
|
| trunk/src/DataCheckExcute/DataCheckExcute/Common/Process/ClsChangeLedgerData.cs | ||
|---|---|---|
| 1 |
using System; |
|
| 2 |
using System.Collections.Generic; |
|
| 3 |
using System.ComponentModel; |
|
| 4 |
using System.Data; |
|
| 5 |
using System.Drawing; |
|
| 6 |
using System.Linq; |
|
| 7 |
using System.Text; |
|
| 8 |
using System.Windows.Forms; |
|
| 9 |
using System.Collections; |
|
| 10 |
using System.Diagnostics; |
|
| 11 |
|
|
| 12 |
using log4net; |
|
| 13 |
using log4net.Appender; |
|
| 14 |
using log4net.Repository.Hierarchy; |
|
| 15 |
|
|
| 16 |
using ProcessManagement.Common; |
|
| 17 |
using ProcessManagement.DB.IOAccess; |
|
| 18 |
using ProcessManagement.DataModel; |
|
| 19 |
using ProcessManagement.Forms.DataEntry; |
|
| 20 |
|
|
| 21 |
//*----------------------- 工事詳細台帳データ変更クラス -----------------------* |
|
| 22 |
// 2016/05/31 Ver1.0.0.0 Create Source |
|
| 23 |
// |
|
| 24 |
// |
|
| 25 |
// |
|
| 26 |
//*----------------------------------------------------------------------------* |
|
| 27 |
namespace ProcessManagement.Common |
|
| 28 |
{
|
|
| 29 |
/// <summary> |
|
| 30 |
/// 工事詳細台帳データ変更クラス |
|
| 31 |
/// </summary> |
|
| 32 |
public static class ClsChangeLedgerData |
|
| 33 |
{
|
|
| 34 |
#region ログ定義 |
|
| 35 |
/// <summary> |
|
| 36 |
/// log4netログを使用する |
|
| 37 |
/// </summary> |
|
| 38 |
private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
|
| 39 |
#endregion |
|
| 40 |
|
|
| 41 |
#region 定数 |
|
| 42 |
|
|
| 43 |
#endregion |
|
| 44 |
|
|
| 45 |
#region 変数 |
|
| 46 |
|
|
| 47 |
#endregion |
|
| 48 |
|
|
| 49 |
#region 工事詳細台帳再計算処理(総支払額・粗利・給与・純利益が対象) |
|
| 50 |
/// <summary> |
|
| 51 |
/// 工事詳細台帳再計算処理(総支払額・粗利・給与・純利益が対象) |
|
| 52 |
/// </summary> |
|
| 53 |
/// <param name="ConstrCode"></param> |
|
| 54 |
private static bool LedgerRecalculate(IOConstructionLedgerExcute LedgerExcuteDB, List<int> ConstrCodeList) |
|
| 55 |
{
|
|
| 56 |
try |
|
| 57 |
{
|
|
| 58 |
StringBuilder strSQL = new StringBuilder(); |
|
| 59 |
bool bRet = true; |
|
| 60 |
|
|
| 61 |
// 対象データ取得 |
|
| 62 |
List<int> GroupCodeList1 = new List<int>(); |
|
| 63 |
List<int> GroupCodeList2 = new List<int>(); |
|
| 64 |
List<int> GroupCodeList3 = new List<int>(); |
|
| 65 |
List<int> GroupCodeList4 = new List<int>(); |
|
| 66 |
// 集計コード一覧作成 |
|
| 67 |
SetGroupCodeList(ref GroupCodeList1, ref GroupCodeList2, ref GroupCodeList3, ref GroupCodeList4); |
|
| 68 |
|
|
| 69 |
foreach (int ConstrCode in ConstrCodeList) |
|
| 70 |
{
|
|
| 71 |
// 工事台帳実行データよりグループごとの合計金額を取得する |
|
| 72 |
strSQL.Clear(); |
|
| 73 |
strSQL.Append("SELECT GROUPCOUNT, SUM(PAYMENTAMOUNT)");
|
|
| 74 |
strSQL.Append(" FROM CONSTRUCTIONLEDGEREXCUTE");
|
|
| 75 |
strSQL.AppendFormat(" WHERE CONSTRUCTIONCODE = {0}", ConstrCode);
|
|
| 76 |
strSQL.Append(" GROUP BY GROUPCOUNT");
|
|
| 77 |
strSQL.Append(" ORDER BY GROUPCOUNT");
|
|
| 78 |
|
|
| 79 |
ArrayList InData = new ArrayList(); |
|
| 80 |
if (!LedgerExcuteDB.ExecuteReader(strSQL.ToString(), ref InData, false)) continue; |
|
| 81 |
|
|
| 82 |
// データ無は次のデータ |
|
| 83 |
if (InData.Count == 0) continue; |
|
| 84 |
|
|
| 85 |
// 対象データ取得 |
|
| 86 |
int Payment = CalcGetTotal(InData, GroupCodeList1); // ----- 支払額 |
|
| 87 |
|
|
| 88 |
int PExpenses = CalcGetTotal(InData, GroupCodeList2); // ----- 人件費 |
|
| 89 |
|
|
| 90 |
int Allowance = CalcGetTotal(InData, GroupCodeList3); // ----- 給与 |
|
| 91 |
|
|
| 92 |
int Billing = CalcGetTotal(InData, GroupCodeList4); // ----- 請求額 |
|
| 93 |
|
|
| 94 |
// ----- 工事詳細台帳更新 |
|
| 95 |
strSQL.Clear(); |
|
| 96 |
strSQL.Append("UPDATE CONSTRUCTIONLEDGER SET");
|
|
| 97 |
strSQL.AppendFormat(" TOTALPAYMENT = {0}", Payment);
|
|
| 98 |
strSQL.AppendFormat(", GROSSPROFIT = {0}", (Billing - Payment));
|
|
| 99 |
strSQL.AppendFormat(", Allowance = {0}", Allowance);
|
|
| 100 |
strSQL.AppendFormat(", NETPROFIT = {0}", (Billing - (Payment + Allowance + PExpenses)));
|
|
| 101 |
strSQL.AppendFormat(" WHERE CONSTRUCTIONCODE = {0}", ConstrCode);
|
|
| 102 |
if (!LedgerExcuteDB.ExecuteNonQuery(strSQL.ToString(), false)) |
|
| 103 |
{
|
|
| 104 |
bRet = false; |
|
| 105 |
break; |
|
| 106 |
} |
|
| 107 |
} |
|
| 108 |
return bRet; |
|
| 109 |
} |
|
| 110 |
catch (System.Exception ex) |
|
| 111 |
{
|
|
| 112 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 113 |
return false; |
|
| 114 |
} |
|
| 115 |
} |
|
| 116 |
#endregion |
|
| 117 |
|
|
| 118 |
#region 集計用コードセット |
|
| 119 |
/// <summary> |
|
| 120 |
/// 集計用コードセット |
|
| 121 |
/// </summary> |
|
| 122 |
private static void SetGroupCodeList(ref List<int> GroupCodeList1, ref List<int> GroupCodeList2, |
|
| 123 |
ref List<int> GroupCodeList3, ref List<int> GroupCodeList4) |
|
| 124 |
{
|
|
| 125 |
try |
|
| 126 |
{
|
|
| 127 |
// 対象データ取得 |
|
| 128 |
// ----- 支払額コードセット |
|
| 129 |
GroupCodeList1.Add((int)FrmConstructionLedger.DataGroup.Expenses); // 1:経費 |
|
| 130 |
GroupCodeList1.Add((int)FrmConstructionLedger.DataGroup.ConstructionCosts); // 2:施工費 |
|
| 131 |
GroupCodeList1.Add((int)FrmConstructionLedger.DataGroup.TransportationCosts); // 3:交通費(通行料・電車代) |
|
| 132 |
GroupCodeList1.Add((int)FrmConstructionLedger.DataGroup.PurchaseCosts); // 4:購入品 |
|
| 133 |
GroupCodeList1.Add((int)FrmConstructionLedger.DataGroup.VehicleLeaseFee); // 5:車両リース代 |
|
| 134 |
GroupCodeList1.Add((int)FrmConstructionLedger.DataGroup.ParkingCosts); // 6:駐車場・資材置き場 |
|
| 135 |
GroupCodeList1.Add((int)FrmConstructionLedger.DataGroup.RoomChargeCosts); // 7:宿泊費 |
|
| 136 |
GroupCodeList1.Add((int)FrmConstructionLedger.DataGroup.DisposeCosts); // 8:処分費等 |
|
| 137 |
|
|
| 138 |
// ----- 人件費コードセット |
|
| 139 |
GroupCodeList2.Add((int)FrmConstructionLedger.DataGroup.Instructor); // 9:指導員給料行 |
|
| 140 |
GroupCodeList2.Add((int)FrmConstructionLedger.DataGroup.Assistant); // 10:副担当者給料行 |
|
| 141 |
|
|
| 142 |
// ----- 給与コードセット |
|
| 143 |
GroupCodeList3.Add((int)FrmConstructionLedger.DataGroup.Payroll); // 11:担当者給料行 |
|
| 144 |
|
|
| 145 |
// ----- 請求額コードセット |
|
| 146 |
GroupCodeList4.Add((int)FrmConstructionLedger.DataGroup.BillingAmount); // 14:請求金額 |
|
| 147 |
} |
|
| 148 |
catch (System.Exception ex) |
|
| 149 |
{
|
|
| 150 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 151 |
} |
|
| 152 |
} |
|
| 153 |
#endregion |
|
| 154 |
|
|
| 155 |
#region 配列リストより指定された合計を取得する |
|
| 156 |
/// <summary> |
|
| 157 |
/// 配列リストより指定された合計を取得する |
|
| 158 |
/// </summary> |
|
| 159 |
private static int CalcGetTotal(ArrayList InData, List<int> GroupCodeList) |
|
| 160 |
{
|
|
| 161 |
try |
|
| 162 |
{
|
|
| 163 |
int iRetVal = 0; |
|
| 164 |
|
|
| 165 |
int GrpNo = -1; |
|
| 166 |
foreach (int GroupCode in GroupCodeList) |
|
| 167 |
{
|
|
| 168 |
foreach (object[] CurRec in InData) |
|
| 169 |
{
|
|
| 170 |
GrpNo = CommonMotions.cnvInt(CurRec[0]); |
|
| 171 |
|
|
| 172 |
if (GroupCode != GrpNo) continue; |
|
| 173 |
|
|
| 174 |
iRetVal += CommonMotions.cnvInt(CurRec[1]); |
|
| 175 |
} |
|
| 176 |
} |
|
| 177 |
|
|
| 178 |
return iRetVal; |
|
| 179 |
} |
|
| 180 |
catch (System.Exception ex) |
|
| 181 |
{
|
|
| 182 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 183 |
return 0; |
|
| 184 |
} |
|
| 185 |
} |
|
| 186 |
#endregion |
|
| 187 |
|
|
| 188 |
#region 工事詳細台帳のグループ番号を取得する |
|
| 189 |
/// <summary> |
|
| 190 |
/// 工事詳細台帳のグループ番号を取得する |
|
| 191 |
/// </summary> |
|
| 192 |
/// <param name="TargetData"></param> |
|
| 193 |
/// <returns></returns> |
|
| 194 |
public static int GetConstructionLedgerGroupNo(int TargetData) |
|
| 195 |
{
|
|
| 196 |
int GroupNo = 0; |
|
| 197 |
// 工事台帳のグループ番号を取得する |
|
| 198 |
switch (TargetData) |
|
| 199 |
{
|
|
| 200 |
case (int)CostDataOfPerson.DataNoDef.Transport: |
|
| 201 |
// 交通費(通行料・電車代) |
|
| 202 |
GroupNo = (int)FrmConstructionLedger.DataGroup.TransportationCosts; |
|
| 203 |
break; |
|
| 204 |
case (int)CostDataOfPerson.DataNoDef.Purchase: |
|
| 205 |
// 購入品 |
|
| 206 |
GroupNo = (int)FrmConstructionLedger.DataGroup.PurchaseCosts; |
|
| 207 |
break; |
|
| 208 |
case (int)CostDataOfPerson.DataNoDef.Lease: |
|
| 209 |
// 車両リース代 |
|
| 210 |
GroupNo = (int)FrmConstructionLedger.DataGroup.VehicleLeaseFee; |
|
| 211 |
break; |
|
| 212 |
case (int)CostDataOfPerson.DataNoDef.StoragePlace: |
|
| 213 |
// 駐車場・資材置き場 |
|
| 214 |
GroupNo = (int)FrmConstructionLedger.DataGroup.ParkingCosts; |
|
| 215 |
break; |
|
| 216 |
case (int)CostDataOfPerson.DataNoDef.Lodging: |
|
| 217 |
// 宿泊費 |
|
| 218 |
GroupNo = (int)FrmConstructionLedger.DataGroup.RoomChargeCosts; |
|
| 219 |
break; |
|
| 220 |
case (int)CostDataOfPerson.DataNoDef.DisposalCost: |
|
| 221 |
// 処分費 |
|
| 222 |
GroupNo = (int)FrmConstructionLedger.DataGroup.DisposeCosts; |
|
| 223 |
break; |
|
| 224 |
} |
|
| 225 |
return GroupNo; |
|
| 226 |
} |
|
| 227 |
#endregion |
|
| 228 |
|
|
| 229 |
#region 工事詳細台帳より支払金額グリッドの先頭カラム数を取得する |
|
| 230 |
/// <summary> |
|
| 231 |
/// 工事詳細台帳より支払金額グリッドの先頭カラム数を取得する |
|
| 232 |
/// </summary> |
|
| 233 |
public static int GetLedgerColumnCount() |
|
| 234 |
{
|
|
| 235 |
try |
|
| 236 |
{
|
|
| 237 |
return (Enum.GetNames(typeof(FrmConstructionLedger.GridColumn)).Length - 1); |
|
| 238 |
} |
|
| 239 |
catch (System.Exception ex) |
|
| 240 |
{
|
|
| 241 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 242 |
return 0; |
|
| 243 |
} |
|
| 244 |
} |
|
| 245 |
#endregion |
|
| 246 |
|
|
| 247 |
#region 対象年月から工事詳細台帳のグリッドカラム位置を算出する |
|
| 248 |
/// <summary> |
|
| 249 |
/// 対象年月から工事詳細台帳のグリッドカラム位置を算出する |
|
| 250 |
/// </summary> |
|
| 251 |
/// <returns></returns> |
|
| 252 |
public static int CalcTargetMonthToColumn(IOConstructionLedgerExcute execDB, bool bConnect, int ConstrCode, DateTime TargetMonth) |
|
| 253 |
{
|
|
| 254 |
try |
|
| 255 |
{
|
|
| 256 |
StringBuilder strSQL = new StringBuilder(); |
|
| 257 |
strSQL.Append("SELECT MIN(A.TargetMonth), MIN(A.ColumnCount) FROM ConstructionLedgerExcute AS A");
|
|
| 258 |
strSQL.AppendFormat(" WHERE A.ConstructionCode = {0}", ConstrCode);
|
|
| 259 |
strSQL.Append(" GROUP BY A.ConstructionCode");
|
|
| 260 |
|
|
| 261 |
ArrayList arList = new ArrayList(); |
|
| 262 |
if (!execDB.ExecuteReader(strSQL.ToString(), ref arList, bConnect)) return 0; |
|
| 263 |
if (arList.Count < 1) return 0; |
|
| 264 |
|
|
| 265 |
object[] objRec = (object[])arList[0]; |
|
| 266 |
DateTime dtADate = CommonMotions.cnvDate(objRec[0]); |
|
| 267 |
int nAPoint = CommonMotions.cnvInt(objRec[1]); |
|
| 268 |
|
|
| 269 |
int Columncnt = 0; |
|
| 270 |
DateTime dtBDate = new DateTime(TargetMonth.Year, TargetMonth.Month, 1); |
|
| 271 |
Columncnt = nAPoint + DateTimeUtil.GetElapsedMonths(dtADate, dtBDate); |
|
| 272 |
|
|
| 273 |
return Columncnt; |
|
| 274 |
} |
|
| 275 |
catch (Exception ex) |
|
| 276 |
{
|
|
| 277 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 278 |
return 0; |
|
| 279 |
} |
|
| 280 |
} |
|
| 281 |
#endregion |
|
| 282 |
|
|
| 283 |
#region 工事詳細台帳データに対象行の支払い給与を計算する |
|
| 284 |
/// <summary> |
|
| 285 |
/// 工事詳細台帳データに対象行の支払い給与を計算する |
|
| 286 |
/// </summary> |
|
| 287 |
/// <returns></returns> |
|
| 288 |
public static bool CalculatePayment(List<ConstructionLedger> LedgerList) |
|
| 289 |
{
|
|
| 290 |
IOConstructionLedgerDetail LedgerDeDB = new IOConstructionLedgerDetail(); |
|
| 291 |
IOConstructionLedgerExcute LedgerExDB = new IOConstructionLedgerExcute(); |
|
| 292 |
IOMPersonInCharge PersonDB = new IOMPersonInCharge(); |
|
| 293 |
try |
|
| 294 |
{
|
|
| 295 |
bool bret = true; |
|
| 296 |
List<int> ConstrCodeList = new List<int>(); |
|
| 297 |
|
|
| 298 |
LedgerDeDB.connect(); LedgerDeDB.beginTran(); |
|
| 299 |
LedgerExDB.connect(); LedgerExDB.beginTran(); |
|
| 300 |
PersonDB.connect(); PersonDB.beginTran(); |
|
| 301 |
|
|
| 302 |
StringBuilder DetailSQL = new StringBuilder(); |
|
| 303 |
foreach (ConstructionLedger LedgerRec in LedgerList) |
|
| 304 |
{
|
|
| 305 |
|
|
| 306 |
// 工事詳細台帳明細データ取得 |
|
| 307 |
List<ConstructionLedgerDetail> DetailList = new List<ConstructionLedgerDetail>(); |
|
| 308 |
DetailSQL.Clear(); |
|
| 309 |
DetailSQL.Append(LedgerDeDB.CreatePrimarykeyString(LedgerRec.ConstructionCode)); |
|
| 310 |
DetailSQL.AppendFormat(" AND OperatingFlg = {0}", (int)ConstructionLedgerDetail.SalOpeKindDef.Oparateing); // 対応中フラグ
|
|
| 311 |
DetailSQL.AppendFormat(" AND SALARYFLG != {0}", (int)CommonDefine.SalaryDevision.Noting); // 給与振分区分
|
|
| 312 |
DetailSQL.AppendFormat(" AND GROUPCOUNT IN ({0},{1},{2})",
|
|
| 313 |
(int)FrmConstructionLedger.DataGroup.Instructor, // 指導員給料 |
|
| 314 |
(int)FrmConstructionLedger.DataGroup.Assistant, // 副担当者給料 |
|
| 315 |
(int)FrmConstructionLedger.DataGroup.Payroll); // 担当者給料行 |
|
| 316 |
|
|
| 317 |
if (!LedgerDeDB.SelectAction(DetailSQL.ToString(), ref DetailList, false) || DetailList.Count == 0) continue; |
|
| 318 |
|
|
| 319 |
DateTime TargetDate = DateTime.Now.Date; |
|
| 320 |
// 対象月より書込みカラム位置を取得する |
|
| 321 |
int ColPoint = CalcTargetMonthToColumn(LedgerExDB, false, LedgerRec.ConstructionCode, TargetDate); |
|
| 322 |
|
|
| 323 |
foreach (ConstructionLedgerDetail CurRec in DetailList) |
|
| 324 |
{
|
|
| 325 |
// コードが担当者ではない場合は処理しない |
|
| 326 |
if (CurRec.CompanyType != (int)CommonDefine.CodeDataType.Person) continue; |
|
| 327 |
// コードがない場合は処理しない |
|
| 328 |
if (CurRec.CompanyCode == 0) continue; |
|
| 329 |
// 施工管理中担当者ではない場合は処理しない |
|
| 330 |
if (CurRec.OperatingFlg == (int)ConstructionLedgerDetail.SalOpeKindDef.Complate) continue; |
|
| 331 |
|
|
| 332 |
// セットする金額を計算する |
|
| 333 |
switch (CurRec.SalaryFlg) |
|
| 334 |
{
|
|
| 335 |
case (int)CommonDefine.SalaryDevision.All: // 全日振分 |
|
| 336 |
bret = CalcSalaryDevisionAll(LedgerExDB, PersonDB, LedgerRec, CurRec, TargetDate.Date, ColPoint); |
|
| 337 |
break; |
|
| 338 |
case (int)CommonDefine.SalaryDevision.Noting: // 振分無 |
|
| 339 |
//bret = CalcSalaryDevisionNoting(LedgerExDB, CurRec, TargetDate.Date, ColPoint); |
|
| 340 |
break; |
|
| 341 |
case (int)CommonDefine.SalaryDevision.DaysInput: // 日数入力 |
|
| 342 |
bret = CalcSalaryDevisionDaysInput(LedgerExDB, PersonDB, LedgerRec, CurRec); |
|
| 343 |
break; |
|
| 344 |
default: |
|
| 345 |
break; |
|
| 346 |
} |
|
| 347 |
} |
|
| 348 |
ConstrCodeList.Add(LedgerRec.ConstructionCode); |
|
| 349 |
} |
|
| 350 |
|
|
| 351 |
if (bret) |
|
| 352 |
{
|
|
| 353 |
// 工事台帳更新 |
|
| 354 |
bret = LedgerRecalculate(LedgerExDB, ConstrCodeList); |
|
| 355 |
} |
|
| 356 |
|
|
| 357 |
// エラー時ロールバック |
|
| 358 |
if (!bret) LedgerExDB.rollback(); |
|
| 359 |
|
|
| 360 |
// DB Commit |
|
| 361 |
LedgerExDB.commit(); |
|
| 362 |
|
|
| 363 |
return bret; |
|
| 364 |
} |
|
| 365 |
catch (Exception ex) |
|
| 366 |
{
|
|
| 367 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 368 |
return false; |
|
| 369 |
} |
|
| 370 |
finally |
|
| 371 |
{
|
|
| 372 |
LedgerDeDB.close(); LedgerDeDB = null; |
|
| 373 |
LedgerExDB.close(); LedgerExDB = null; |
|
| 374 |
PersonDB.close(); PersonDB = null; |
|
| 375 |
} |
|
| 376 |
} |
|
| 377 |
#endregion |
|
| 378 |
|
|
| 379 |
#region 全日振分時の給与書込み |
|
| 380 |
/// <summary> |
|
| 381 |
/// 全日振分時の給与書込み |
|
| 382 |
/// </summary> |
|
| 383 |
private static bool CalcSalaryDevisionAll(IOConstructionLedgerExcute LedgerExDB, |
|
| 384 |
IOMPersonInCharge PersonDB, |
|
| 385 |
ConstructionLedger LedgerRec, |
|
| 386 |
ConstructionLedgerDetail CurRec, |
|
| 387 |
DateTime CalcEndtDate, |
|
| 388 |
int ColPoint) |
|
| 389 |
{
|
|
| 390 |
try |
|
| 391 |
{
|
|
| 392 |
DateTime StartDate = DateTime.Now; |
|
| 393 |
DateTime CompDate = DateTime.Now; |
|
| 394 |
|
|
| 395 |
// ----- 計算開始日取得 |
|
| 396 |
if (LedgerRec.ConstructionStart.Year == CalcEndtDate.Year |
|
| 397 |
&& LedgerRec.ConstructionStart.Month == CalcEndtDate.Month) |
|
| 398 |
{ // 対象期間の開始が当月の場合は工事開始日を開始にする
|
|
| 399 |
StartDate = LedgerRec.ConstructionStart; |
|
| 400 |
} |
|
| 401 |
else |
|
| 402 |
{ // 違う場合は月初
|
|
| 403 |
StartDate = DateTime.Parse(string.Format("{0}/{1}/{2}", CalcEndtDate.Year, CalcEndtDate.Month, 1));
|
|
| 404 |
} |
|
| 405 |
// ----- 計算終了日取得 |
|
| 406 |
if (LedgerRec.ConstructionEnd.Year == CalcEndtDate.Year |
|
| 407 |
&& LedgerRec.ConstructionEnd.Month == CalcEndtDate.Month) |
|
| 408 |
{ // 対象期間の終了が当月の場合は当日より前は工事終了日を終了にする
|
|
| 409 |
if (LedgerRec.ConstructionEnd.Date < DateTime.Today.Date) |
|
| 410 |
CompDate = LedgerRec.ConstructionEnd; |
|
| 411 |
else |
|
| 412 |
CompDate = CalcEndtDate; |
|
| 413 |
} |
|
| 414 |
else |
|
| 415 |
{ // 違う場合は終了日
|
|
| 416 |
CompDate = CalcEndtDate; |
|
| 417 |
} |
|
| 418 |
|
|
| 419 |
int SumSaraly = 0; |
|
| 420 |
|
|
| 421 |
// 月末日より月日数を取得する |
|
| 422 |
int MonthDayCnt = DateTimeUtil.EndOfMonth(CalcEndtDate).Day; |
|
| 423 |
// 経過日数を取得する |
|
| 424 |
TimeSpan ts = CompDate - StartDate; |
|
| 425 |
// 支払給与計算 |
|
| 426 |
switch (CurRec.GroupCount) |
|
| 427 |
{
|
|
| 428 |
case (int)FrmConstructionLedger.DataGroup.Instructor: // 指導員給料 |
|
| 429 |
SumSaraly = CommonMotions.cnvRound((double)CommonDefine.InstructorMonthryCost / MonthDayCnt); |
|
| 430 |
SumSaraly *= (ts.Days + 1); |
|
| 431 |
break; |
|
| 432 |
case (int)FrmConstructionLedger.DataGroup.Assistant: // 副担当者給料 |
|
| 433 |
SumSaraly = CommonMotions.cnvRound((double)CommonDefine.AssistantMonthryCost / MonthDayCnt); |
|
| 434 |
SumSaraly *= (ts.Days + 1); |
|
| 435 |
break; |
|
| 436 |
case (int)FrmConstructionLedger.DataGroup.Payroll: // 担当者給料行 |
|
| 437 |
// 範囲給与取得 |
|
| 438 |
SumSaraly = CommonMotions.CalcElapsedSalary(PersonDB, StartDate, CompDate, CurRec.CompanyCode, false); |
|
| 439 |
break; |
|
| 440 |
} |
|
| 441 |
|
|
| 442 |
// 実行データのキー部年月日は対象月の1日 |
|
| 443 |
DateTime ParaDate = new DateTime(CalcEndtDate.Year, CalcEndtDate.Month, 1); |
|
| 444 |
// 支払いデータ書込み |
|
| 445 |
if (!AddOrSetSalary(LedgerExDB |
|
| 446 |
, CurRec.ConstructionCode, CurRec.GroupCount, CurRec.LineCount, ColPoint, SumSaraly, ParaDate)) |
|
| 447 |
{
|
|
| 448 |
return false; |
|
| 449 |
} |
|
| 450 |
|
|
| 451 |
return true; |
|
| 452 |
} |
|
| 453 |
catch (Exception ex) |
|
| 454 |
{
|
|
| 455 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 456 |
return false; |
|
| 457 |
} |
|
| 458 |
} |
|
| 459 |
#endregion |
|
| 460 |
|
|
| 461 |
#region 振分無時の給与書込み |
|
| 462 |
/// <summary> |
|
| 463 |
/// 振分無時の給与書込み |
|
| 464 |
/// </summary> |
|
| 465 |
private static bool CalcSalaryDevisionNoting(IOConstructionLedgerExcute LedgerExDB, |
|
| 466 |
ConstructionLedgerDetail CurRec, |
|
| 467 |
DateTime CalcEndtDate, |
|
| 468 |
int ColPoint) |
|
| 469 |
{
|
|
| 470 |
try |
|
| 471 |
{
|
|
| 472 |
// 実行データのキー部年月日は対象月の1日 |
|
| 473 |
DateTime ParaDate = new DateTime(CalcEndtDate.Year, CalcEndtDate.Month, 1); |
|
| 474 |
// 支払いデータ書込み |
|
| 475 |
if (!AddOrSetSalary(LedgerExDB |
|
| 476 |
, CurRec.ConstructionCode, CurRec.GroupCount, CurRec.LineCount, ColPoint, 0, ParaDate)) |
|
| 477 |
{
|
|
| 478 |
return false; |
|
| 479 |
} |
|
| 480 |
|
|
| 481 |
return true; |
|
| 482 |
} |
|
| 483 |
catch (Exception ex) |
|
| 484 |
{
|
|
| 485 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 486 |
return false; |
|
| 487 |
} |
|
| 488 |
} |
|
| 489 |
#endregion |
|
| 490 |
|
|
| 491 |
#region 日付指定時の給与書込み |
|
| 492 |
/// <summary> |
|
| 493 |
/// 日付指定時の給与書込み |
|
| 494 |
/// </summary> |
|
| 495 |
private static bool CalcSalaryDevisionDaysInput(IOConstructionLedgerExcute LedgerExDB, |
|
| 496 |
IOMPersonInCharge PersonDB, |
|
| 497 |
ConstructionLedger LedgerRec, |
|
| 498 |
ConstructionLedgerDetail CurRec) |
|
| 499 |
{
|
|
| 500 |
IOProcessApproval AppDB = new IOProcessApproval(); |
|
| 501 |
try |
|
| 502 |
{
|
|
| 503 |
int OneDaySalary = 0; |
|
| 504 |
|
|
| 505 |
// 月末日より月日数を取得する |
|
| 506 |
int MonthDayCnt = DateTimeUtil.EndOfMonth(LedgerRec.ConstructionStart).Day; |
|
| 507 |
// 支払給与計算 |
|
| 508 |
switch (CurRec.GroupCount) |
|
| 509 |
{
|
|
| 510 |
case (int)FrmConstructionLedger.DataGroup.Instructor: // 指導員給料 |
|
| 511 |
OneDaySalary = CommonMotions.cnvRound((double)CommonDefine.InstructorMonthryCost / MonthDayCnt); |
|
| 512 |
OneDaySalary *= CurRec.SalaryDays; |
|
| 513 |
break; |
|
| 514 |
case (int)FrmConstructionLedger.DataGroup.Assistant: // 副担当者給料 |
|
| 515 |
OneDaySalary = CommonMotions.cnvRound((double)CommonDefine.AssistantMonthryCost / MonthDayCnt); |
|
| 516 |
OneDaySalary *= CurRec.SalaryDays; |
|
| 517 |
break; |
|
| 518 |
case (int)FrmConstructionLedger.DataGroup.Payroll: // 担当者給料行 |
|
| 519 |
// 給与取得 |
|
| 520 |
OneDaySalary = CommonMotions.CalcElapsedSalary(PersonDB |
|
| 521 |
, LedgerRec.ConstructionStart |
|
| 522 |
, LedgerRec.ConstructionStart |
|
| 523 |
, CurRec.CompanyCode |
|
| 524 |
, false); |
|
| 525 |
OneDaySalary *= CurRec.SalaryDays; |
|
| 526 |
break; |
|
| 527 |
} |
|
| 528 |
|
|
| 529 |
// 工事予算が承認された月の位置に書く |
|
| 530 |
StringBuilder strSQL = new StringBuilder(); |
|
| 531 |
strSQL.Append(AppDB.CreatePrimarykeyString(CurRec.SourceCode, |
|
| 532 |
3, // 工事予算承認番号(ClExecuteが無いため) |
|
| 533 |
(int)CommonDefine.s_Default_OrderNo, |
|
| 534 |
1)); // 先頭レコード |
|
| 535 |
ProcessApproval AppRec = new ProcessApproval(); |
|
| 536 |
if (!AppDB.SelectAction(strSQL.ToString(), ref AppRec)) return false; |
|
| 537 |
|
|
| 538 |
// 実行データのキー部年月日は開始月の1日 |
|
| 539 |
DateTime ParaDate = new DateTime(LedgerRec.ConstructionStart.Year |
|
| 540 |
, LedgerRec.ConstructionStart.Month, 1); |
|
| 541 |
// 台帳カラム位置 |
|
| 542 |
int Columncnt = Enum.GetNames(typeof(FrmConstructionLedger.GridColumn)).Length - 1; |
|
| 543 |
|
|
| 544 |
// 増減データは承認データを日付として使用する |
|
| 545 |
if ((CurRec.SourceCode % 10) > 1) |
|
| 546 |
{
|
|
| 547 |
DateTime dtStart = LedgerRec.ConstructionStart; |
|
| 548 |
// 工事詳細台帳実行データよりカラム対象の年月を取得する |
|
| 549 |
DateTime wrkDate = GetConstructionLedgerStartDate(LedgerExDB, CurRec.ConstructionCode, false); |
|
| 550 |
if (wrkDate.Date != DateTime.MinValue.Date) dtStart = wrkDate; |
|
| 551 |
|
|
| 552 |
// 承認日付より持ってくる |
|
| 553 |
Columncnt = CalcTargetMonthToColumn(LedgerExDB, false, LedgerRec.ConstructionCode, AppRec.PetitionApprovalDate); |
|
| 554 |
ParaDate = new DateTime(AppRec.PetitionApprovalDate.Year |
|
| 555 |
, AppRec.PetitionApprovalDate.Month, 1); |
|
| 556 |
} |
|
| 557 |
|
|
| 558 |
// 支払いデータ書込み |
|
| 559 |
if (!AddOrSetSalary(LedgerExDB |
|
| 560 |
, CurRec.ConstructionCode, CurRec.GroupCount, CurRec.LineCount, Columncnt, OneDaySalary, ParaDate)) |
|
| 561 |
{
|
|
| 562 |
return false; |
|
| 563 |
} |
|
| 564 |
|
|
| 565 |
return true; |
|
| 566 |
} |
|
| 567 |
catch (Exception ex) |
|
| 568 |
{
|
|
| 569 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 570 |
return false; |
|
| 571 |
} |
|
| 572 |
finally |
|
| 573 |
{
|
|
| 574 |
AppDB.close(); AppDB = null; |
|
| 575 |
} |
|
| 576 |
} |
|
| 577 |
#endregion |
|
| 578 |
|
|
| 579 |
#region 日次処理での日当の加算を判定する |
|
| 580 |
/// <summary> |
|
| 581 |
/// 日次処理での日当の加算を判定する |
|
| 582 |
/// </summary> |
|
| 583 |
/// <param name="CurRec"></param> |
|
| 584 |
/// <returns></returns> |
|
| 585 |
private static bool CheckPaymentValue(ConstructionLedgerDetail CurRec) |
|
| 586 |
{
|
|
| 587 |
IOConstructionLedgerExcute ExcuteDB = new IOConstructionLedgerExcute(); |
|
| 588 |
try |
|
| 589 |
{
|
|
| 590 |
// 支払いデータより合計金額を取得する |
|
| 591 |
ArrayList arList = new ArrayList(); |
|
| 592 |
string ExcuteSQL = "SELECT SUM(PAYMENTAMOUNT) FROM CONSTRUCTIONLEDGEREXCUTE"; |
|
| 593 |
ExcuteSQL += string.Format(" WHERE CONSTRUCTIONCODE = {0}", CurRec.ConstructionCode);
|
|
| 594 |
ExcuteSQL += string.Format(" AND GROUPCOUNT = {0}", CurRec.GroupCount);
|
|
| 595 |
ExcuteSQL += string.Format(" AND LINECOUNT = {0}", CurRec.LineCount);
|
|
| 596 |
if (!ExcuteDB.ExecuteReader(ExcuteSQL, ref arList) || arList.Count == 0) return false; |
|
| 597 |
|
|
| 598 |
object[] wrkobj = (object[])arList[0]; |
|
| 599 |
int TotalVal = CommonMotions.cnvInt(wrkobj[0]); |
|
| 600 |
|
|
| 601 |
bool bRet = false; |
|
| 602 |
if (TotalVal < CurRec.ExecutionAmount) bRet = true; |
|
| 603 |
|
|
| 604 |
return bRet; |
|
| 605 |
} |
|
| 606 |
catch (Exception ex) |
|
| 607 |
{
|
|
| 608 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 609 |
return false; |
|
| 610 |
} |
|
| 611 |
} |
|
| 612 |
#endregion |
|
| 613 |
|
|
| 614 |
#region 詳細台帳に指定金額を設定するか足しこむ |
|
| 615 |
/// <summary> |
|
| 616 |
/// 詳細台帳に指定金額を設定するか足しこむ |
|
| 617 |
/// </summary> |
|
| 618 |
private static bool AddOrSetSalary(IOConstructionLedgerExcute LedgerExDB |
|
| 619 |
, int ConstrCode, int GroupCount, int LineCount, int ColumnCount |
|
| 620 |
, int DaySalary, DateTime ColumnDate) |
|
| 621 |
{
|
|
| 622 |
try |
|
| 623 |
{
|
|
| 624 |
// キー作成 |
|
| 625 |
StringBuilder strSQL = new StringBuilder(); |
|
| 626 |
strSQL.Append(LedgerExDB.CreatePrimarykeyString(ConstrCode, GroupCount, LineCount, ColumnCount)); |
|
| 627 |
|
|
| 628 |
// データ読込み |
|
| 629 |
List<ConstructionLedgerExcute> LedgerExList = new List<ConstructionLedgerExcute>(); |
|
| 630 |
if (LedgerExDB.SelectAction(strSQL.ToString(), ref LedgerExList, false) && LedgerExList.Count > 0) |
|
| 631 |
{
|
|
| 632 |
// データ更新 |
|
| 633 |
if (!LedgerExDB.UpdateFeild(ConstrCode, GroupCount, LineCount, ColumnCount |
|
| 634 |
, (int)IOConstructionLedgerExcute.TableColumn.PaymentAmount |
|
| 635 |
, (double)DaySalary |
|
| 636 |
, false)) return false; |
|
| 637 |
if(LedgerExList[0].TargetMonth.Date != ColumnDate.Date) |
|
| 638 |
{
|
|
| 639 |
if (!LedgerExDB.UpdateFeild(ConstrCode, GroupCount, LineCount, ColumnCount |
|
| 640 |
, (int)IOConstructionLedgerExcute.TableColumn.TargetMonth |
|
| 641 |
, ColumnDate |
|
| 642 |
, false)) return false; |
|
| 643 |
} |
|
| 644 |
|
|
| 645 |
return true; |
|
| 646 |
} |
|
| 647 |
|
|
| 648 |
ConstructionLedgerExcute LedgerExDBRec = new ConstructionLedgerExcute(); |
|
| 649 |
LedgerExDBRec.ConstructionCode = ConstrCode; // 工事コード |
|
| 650 |
LedgerExDBRec.GroupCount = GroupCount; // グループ番号 |
|
| 651 |
LedgerExDBRec.LineCount = LineCount; // 行番号 |
|
| 652 |
LedgerExDBRec.ColumnCount = ColumnCount; // 列番号 |
|
| 653 |
LedgerExDBRec.PaymentAmount = DaySalary; // 支払金額 |
|
| 654 |
LedgerExDBRec.TargetMonth = ColumnDate; // 対象年月 |
|
| 655 |
|
|
| 656 |
// データ作成 |
|
| 657 |
if (!LedgerExDB.InsertAction(LedgerExDBRec, false)) return false; |
|
| 658 |
|
|
| 659 |
return true; |
|
| 660 |
} |
|
| 661 |
catch (Exception ex) |
|
| 662 |
{
|
|
| 663 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 664 |
return false; |
|
| 665 |
} |
|
| 666 |
} |
|
| 667 |
#endregion |
|
| 668 |
|
|
| 669 |
#region 工事詳細台帳実行データより最小カラムの対象年月日を取得する |
|
| 670 |
/// <summary> |
|
| 671 |
/// 工事詳細台帳実行データより最小カラムの対象年月日を取得する |
|
| 672 |
/// </summary> |
|
| 673 |
public static DateTime GetConstructionLedgerStartDate(IOConstructionLedgerExcute LedgerExcuteDB, int ConstrCode, bool bTableConnect = true) |
|
| 674 |
{
|
|
| 675 |
try |
|
| 676 |
{
|
|
| 677 |
// 工事詳細台帳実行データよりカラム対象の年月を取得する |
|
| 678 |
StringBuilder strCol = new StringBuilder(); |
|
| 679 |
strCol.Append("SELECT MIN(ColumnCount), TargetMonth From constructionledgerexcute");
|
|
| 680 |
strCol.AppendFormat(" Where ConstructionCode = {0}", ConstrCode);
|
|
| 681 |
ArrayList arrCol = new ArrayList(); |
|
| 682 |
if (!LedgerExcuteDB.ExecuteReader(strCol.ToString(), ref arrCol, bTableConnect)) return DateTime.MinValue; |
|
| 683 |
|
|
| 684 |
if (arrCol.Count < 1) return DateTime.MinValue; |
|
| 685 |
|
|
| 686 |
// 実行データが存在した場合は最小のカラムの年月スタートにする |
|
| 687 |
object[] wrkCol = (object[])arrCol[0]; |
|
| 688 |
return CommonMotions.cnvDate(wrkCol[1]); |
|
| 689 |
} |
|
| 690 |
catch (Exception ex) |
|
| 691 |
{
|
|
| 692 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 693 |
return DateTime.MinValue; |
|
| 694 |
} |
|
| 695 |
} |
|
| 696 |
#endregion |
|
| 697 |
} |
|
| 698 |
} |
|
| trunk/src/DataCheckExcute/DataCheckExcute/Common/Process/ClsSystemOnceExecute.cs | ||
|---|---|---|
| 1 |
using System; |
|
| 2 |
using System.Collections.Generic; |
|
| 3 |
using System.Diagnostics; |
|
| 4 |
using System.IO; |
|
| 5 |
using System.Linq; |
|
| 6 |
using System.Security.Cryptography; |
|
| 7 |
using System.Text; |
|
| 8 |
using System.Threading.Tasks; |
|
| 9 |
using System.Collections; |
|
| 10 |
|
|
| 11 |
using log4net; |
|
| 12 |
using log4net.Appender; |
|
| 13 |
using log4net.Repository.Hierarchy; |
|
| 14 |
|
|
| 15 |
using ProcessManagement.Common; |
|
| 16 |
using ProcessManagement.DB.IOAccess; |
|
| 17 |
using ProcessManagement.DataModel; |
|
| 18 |
|
|
| 19 |
namespace ProcessManagement.Common |
|
| 20 |
{
|
|
| 21 |
/// <summary> |
|
| 22 |
/// システム初回起動時処理クラス |
|
| 23 |
/// </summary> |
|
| 24 |
public class ClsSystemOnceExecute |
|
| 25 |
{
|
|
| 26 |
#region 使用定義 |
|
| 27 |
//log4netログを使用する |
|
| 28 |
private static readonly log4net.ILog logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
|
| 29 |
#endregion |
|
| 30 |
|
|
| 31 |
#region 定数 |
|
| 32 |
|
|
| 33 |
/// <summary> |
|
| 34 |
/// 非受注へ移す期間(受注できずに見積提出日より以下の日数を過ぎれば非受注へ移動) |
|
| 35 |
/// </summary> |
|
| 36 |
private const int s_NonOrderDay = 93; |
|
| 37 |
|
|
| 38 |
/// <summary> |
|
| 39 |
/// 非受注時メッセージ |
|
| 40 |
/// </summary> |
|
| 41 |
private const string s_NonOrderComment = "受注できずに見積提出日より{0}日を過ぎましたので非受注とします。";
|
|
| 42 |
#endregion |
|
| 43 |
|
|
| 44 |
#region 変数 |
|
| 45 |
|
|
| 46 |
/// <summary> |
|
| 47 |
/// 状態毎期限チェックコードリスト |
|
| 48 |
/// </summary> |
|
| 49 |
private ArrayList m_TermCodeArray = new ArrayList(); |
|
| 50 |
|
|
| 51 |
/// <summary> |
|
| 52 |
/// 状態毎期限マスタリスト |
|
| 53 |
/// </summary> |
|
| 54 |
private List<TermMaster> m_TermMstList = new List<TermMaster>(); |
|
| 55 |
|
|
| 56 |
/// <summary> |
|
| 57 |
/// 最終起動日 |
|
| 58 |
/// </summary> |
|
| 59 |
DateTime m_lastsessionDate = DateTime.MinValue; |
|
| 60 |
#endregion |
|
| 61 |
|
|
| 62 |
#region コンストラクタ |
|
| 63 |
public ClsSystemOnceExecute() |
|
| 64 |
{
|
|
| 65 |
} |
|
| 66 |
#endregion |
|
| 67 |
|
|
| 68 |
#region チェックプロセス |
|
| 69 |
/// <summary> |
|
| 70 |
/// 初期起動チェックプロセス |
|
| 71 |
/// </summary> |
|
| 72 |
/// <returns></returns> |
|
| 73 |
public void FirstExecute() |
|
| 74 |
{
|
|
| 75 |
bool ProcessFlg = true; |
|
| 76 |
try |
|
| 77 |
{
|
|
| 78 |
// 本日の初回起動がされている場合は処理しない |
|
| 79 |
if (!ExecuteCheck(ref m_lastsessionDate)) return; |
|
| 80 |
|
|
| 81 |
// 更新済みにするために日付の更新 |
|
| 82 |
if (!(ProcessFlg = UpDateTargetDate(DateTime.Now))) return; |
|
| 83 |
|
|
| 84 |
// 業者請求締日データを作成する |
|
| 85 |
CreateClosingDateofMonth(); |
|
| 86 |
|
|
| 87 |
// 管理マスタの期・年更新 |
|
| 88 |
if (!UpDateSystemMaster()) return; |
|
| 89 |
|
|
| 90 |
// ----- データチェック |
|
| 91 |
// 資材返却期限のチェックを行う |
|
| 92 |
if (!(ProcessFlg = MaterialLimitCheck(m_lastsessionDate))) return; |
|
| 93 |
|
|
| 94 |
// 日付の期限チェックを行う |
|
| 95 |
if (!(ProcessFlg = SubmittedDateCheck(m_lastsessionDate))) return; |
|
| 96 |
|
|
| 97 |
// 見積有効期限切れを非受注へ移行する |
|
| 98 |
if (!(ProcessFlg = ChangeNonOrdersData())) return; |
|
| 99 |
|
|
| 100 |
// 開始期日がきた給与を適用する |
|
| 101 |
if (!(ProcessFlg = SetNewPayrollCheck())) return; |
|
| 102 |
|
|
| 103 |
// 退職者を削除にする |
|
| 104 |
if (!SetRetireeFlg()) return; |
|
| 105 |
|
|
| 106 |
// 部署移動者があれば移動する |
|
| 107 |
if (!MoveDepartment()) return; |
|
| 108 |
|
|
| 109 |
// 工事詳細台帳の給与を加算する |
|
| 110 |
if (!(ProcessFlg = CalculateDaysSalary(m_lastsessionDate))) return; |
|
| 111 |
|
|
| 112 |
// 有給日数のセット |
|
| 113 |
if (!SetPaidHoliday()) return; |
|
| 114 |
|
|
| 115 |
// 対象消費税をセットする |
|
| 116 |
if (!SetConsumptionTax()) return; |
|
| 117 |
} |
|
| 118 |
catch (Exception ex) |
|
| 119 |
{
|
|
| 120 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 121 |
} |
|
| 122 |
finally |
|
| 123 |
{
|
|
| 124 |
// エラー時は元の日付に更新 |
|
| 125 |
if (!ProcessFlg) UpDateTargetDate(m_lastsessionDate); |
|
| 126 |
} |
|
| 127 |
} |
|
| 128 |
#endregion |
|
| 129 |
|
|
| 130 |
#region 日付チェック |
|
| 131 |
/// <summary> |
|
| 132 |
/// 初回起動チェック |
|
| 133 |
/// </summary> |
|
| 134 |
/// <returns></returns> |
|
| 135 |
private bool ExecuteCheck(ref DateTime lastsessionDate) |
|
| 136 |
{
|
|
| 137 |
IOSystemExecute seDB = new IOSystemExecute(); |
|
| 138 |
try |
|
| 139 |
{
|
|
| 140 |
// キーを取得する |
|
| 141 |
int PCode = CommonDefine.ExePrimaryCode.First(x => x.Value.Equals("初回起動日付")).Key;
|
|
| 142 |
// 日付読込 |
|
| 143 |
string strSQL = seDB.CreatePrimarykeyString(PCode); |
|
| 144 |
SystemExecute recordRec = new SystemExecute(); |
|
| 145 |
if (!seDB.SelectAction(strSQL, ref recordRec)) |
|
| 146 |
{
|
|
| 147 |
// キーセット |
|
| 148 |
recordRec.PrimaryCode = PCode; |
|
| 149 |
// 起動日付 |
|
| 150 |
recordRec.TargetDate = DateTime.Now; |
|
| 151 |
// データがないもしくはエラー時はデータ作成 |
|
| 152 |
if (!seDB.InsertAction(recordRec)) return false; |
|
| 153 |
// 日付を1日前にする |
|
| 154 |
recordRec.TargetDate = DateTime.Now.AddDays(-1); |
|
| 155 |
} |
|
| 156 |
|
|
| 157 |
// 前回起動日を取得する |
|
| 158 |
lastsessionDate = recordRec.TargetDate; |
|
| 159 |
|
|
| 160 |
// 日付比較 |
|
| 161 |
if (DateTime.Today == recordRec.TargetDate.Date) return false; |
|
| 162 |
|
|
| 163 |
return true; |
|
| 164 |
} |
|
| 165 |
catch (Exception ex) |
|
| 166 |
{
|
|
| 167 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 168 |
return false; |
|
| 169 |
} |
|
| 170 |
finally |
|
| 171 |
{
|
|
| 172 |
seDB.close(); seDB = null; |
|
| 173 |
} |
|
| 174 |
} |
|
| 175 |
#endregion |
|
| 176 |
|
|
| 177 |
#region 日付変更 |
|
| 178 |
/// <summary> |
|
| 179 |
/// 日付変更 |
|
| 180 |
/// </summary> |
|
| 181 |
/// <returns></returns> |
|
| 182 |
private bool UpDateTargetDate(DateTime TargetDate) |
|
| 183 |
{
|
|
| 184 |
IOSystemExecute seDB = new IOSystemExecute(); |
|
| 185 |
try |
|
| 186 |
{
|
|
| 187 |
// キーを取得する |
|
| 188 |
int PCode = CommonDefine.ExePrimaryCode.First(x => x.Value.Equals("初回起動日付")).Key;
|
|
| 189 |
|
|
| 190 |
// 日付更新 |
|
| 191 |
if (!seDB.UpdateFeild(PCode, (int)IOSystemExecute.TableColumn.TargetDate, TargetDate)) return false; |
|
| 192 |
|
|
| 193 |
return true; |
|
| 194 |
} |
|
| 195 |
catch (Exception ex) |
|
| 196 |
{
|
|
| 197 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 198 |
return false; |
|
| 199 |
} |
|
| 200 |
finally |
|
| 201 |
{
|
|
| 202 |
seDB.close(); seDB = null; |
|
| 203 |
} |
|
| 204 |
} |
|
| 205 |
#endregion |
|
| 206 |
|
|
| 207 |
#region 期限マスタ読込 |
|
| 208 |
/// <summary> |
|
| 209 |
/// 期限マスタ読込 |
|
| 210 |
/// </summary> |
|
| 211 |
/// <returns></returns> |
|
| 212 |
private bool GetTermList() |
|
| 213 |
{
|
|
| 214 |
IOMTerm tmDB = new IOMTerm(); |
|
| 215 |
try |
|
| 216 |
{
|
|
| 217 |
// 期限マスタ読込 |
|
| 218 |
StringBuilder strSQL = new StringBuilder(); |
|
| 219 |
strSQL.Append(" Order By");
|
|
| 220 |
strSQL.Append(" ConstructionStatusFlg ASC");
|
|
| 221 |
strSQL.Append(", FieldNo ASC");
|
|
| 222 |
strSQL.Append(", CheckSchdule DESC");
|
|
| 223 |
strSQL.Append(", TermDays DESC");
|
|
| 224 |
|
|
| 225 |
if (!tmDB.SelectAction(strSQL.ToString(), ref m_TermMstList)) return false; |
|
| 226 |
if (m_TermMstList.Count == 0) return false; |
|
| 227 |
|
|
| 228 |
// チェックコードリスト取得 |
|
| 229 |
strSQL.Clear(); |
|
| 230 |
strSQL.Append("Select");
|
|
| 231 |
strSQL.Append(" ConstructionStatusFlg");
|
|
| 232 |
strSQL.Append(", FieldNo");
|
|
| 233 |
strSQL.Append(", CheckSchdule");
|
|
| 234 |
strSQL.Append(" From");
|
|
| 235 |
strSQL.Append(" TermMaster");
|
|
| 236 |
strSQL.Append(" Group by");
|
|
| 237 |
strSQL.Append(" ConstructionStatusFlg");
|
|
| 238 |
strSQL.Append(", FieldNo");
|
|
| 239 |
strSQL.Append(", CheckSchdule");
|
|
| 240 |
|
|
| 241 |
if (!tmDB.ExecuteReader(strSQL.ToString(), ref m_TermCodeArray)) return false; |
|
| 242 |
if (m_TermCodeArray.Count == 0) return false; |
|
| 243 |
|
|
| 244 |
return true; |
|
| 245 |
} |
|
| 246 |
catch (Exception ex) |
|
| 247 |
{
|
|
| 248 |
logger.ErrorFormat("システムエラー:{0}:{1}", CommonMotions.GetMethodName(), ex.Message);
|
|
| 249 |
return false; |
|
| 250 |
} |
|
| 251 |
finally |
|
| 252 |
{
|
|
| 253 |
tmDB.close(); tmDB = null; |
|
| 254 |
} |
|
| 255 |
} |
|
| 256 |
#endregion |
|
| 257 |
|
|
| 258 |
#region 資材返却ステータス取得処理 |
|
| 259 |
/// <summary> |
|
| 260 |
/// 資材返却ステータス取得処理 |
|
| 261 |
/// </summary> |
|
| 262 |
/// <returns></returns> |
|
| 263 |
public void MaterualStatusCheck(MaterialRecordInfo checkRec, ref TermMaster TermRec) |
|
| 264 |
{
|
|
| 265 |
try |
|
| 266 |
{
|
|
| 267 |
// 対象日セット |
|
| 268 |
DateTime CriteriaDate = DateTime.Now; |
|
| 269 |
// 対象日付を設定 |
|
| 270 |
DateTime Target = checkRec.RepayPlanDate; |
|
| 271 |
|
|
| 272 |
TermMaster TermMasterData = new TermMaster(); |
|
| 273 |
|
|
| 274 |
// 当日のチェック 今日を基準に対象日と比較する |
|
| 275 |
if (Target.Date == CriteriaDate.Date) |
|
| 276 |
{
|
|
| 277 |
TermMasterData.CheckSchdule = (int)TermMaster.TermDateCheckTimingDef.CheckSchdule1; |
|
| 278 |
TermMasterData.TermDays = CommonDefine.MaterualStatusCheckList[0].Value; |
|
| 279 |
TermMasterData.SendTitle = CommonDefine.MaterualLimitItem[0, 0]; |
|
| 280 |
TermMasterData.SendMessage = CommonDefine.MaterualLimitItem[0, 1]; |
|
| 281 |
TermMasterData.BackColor = CommonDefine.MaterualLimitItem[0, 2]; |
|
| 282 |
TermMasterData.ForeColor = CommonDefine.MaterualLimitItem[0, 3]; |
|
| 283 |
} |
|
| 284 |
// 後日以降継続のチェック 今日を基準に経過日(1日)が過ぎているか比較する |
|
| 285 |
else if (Target.AddDays(1).Date <= CriteriaDate.Date) |
|
| 286 |
{
|
|
| 287 |
TermMasterData.CheckSchdule = (int)TermMaster.TermDateCheckTimingDef.CheckSchdule3; |
|
| 288 |
TermMasterData.TermDays = CommonDefine.MaterualStatusCheckList[1].Value; |
|
| 289 |
TermMasterData.SendTitle = CommonDefine.MaterualLimitItem[1, 0]; |
|
| 290 |
TermMasterData.SendMessage = CommonDefine.MaterualLimitItem[1, 1]; |
|
| 291 |
TermMasterData.BackColor = CommonDefine.MaterualLimitItem[1, 2]; |
|
| 292 |
TermMasterData.ForeColor = CommonDefine.MaterualLimitItem[1, 3]; |
|
| 293 |
} |
|
| 294 |
|
|
| 295 |
TermRec = TermMasterData; |
|
| 296 |
} |
|
| 297 |
catch (Exception ex) |
|
| 298 |
{
|
|
| 299 |
logger.ErrorFormat("システムエラー:{0}", ex.Message);
|
|
| 300 |
} |
|
| 301 |
} |
|
| 302 |
#endregion |
|
| 303 |
|
|
| 304 |
#region 秘書からのメッセージ作成(資材管理) |
|
| 305 |
/// <summary> |
|
| 306 |
/// 秘書からのメッセージ作成(資材管理) |
|
| 307 |
/// </summary> |
|
| 308 |
private bool MakeSecretaryMassageData(IOMessageBoardData mbdDB, |
|
| 309 |
IOMessageBoardTerget mbtDB, |
|
| 310 |
IOMessageBrowsingHistory mbhDB, |
|
| 311 |
IORecordKey RecDB, |
|
| 312 |
IOConstructionBaseInfoDetail cbiDB, |
|
| 313 |
MaterialRecordInfo wrkRec, TermMaster CheckRec, DateTime CriteriaDate) |
|
| 314 |
{
|
|
| 315 |
try |
|
| 316 |
{
|
|
| 317 |
// 工事名称・担当者取得 |
|
| 318 |
string strSQL = "SELECT A.DETAILSTRING, C.PERSONCODE CCODE, C.PERSONNAME CNAME"; |
|
| 319 |
strSQL += " FROM ConstructionBaseInfo P"; |
|
| 320 |
strSQL += string.Format(" LEFT JOIN PERSONINCHARGEMASTER C ON C.PERSONCODE = {0}", wrkRec.PersonCode);
|
|
| 321 |
strSQL += ", CONSTRUCTIONBASEINFODETAIL A"; |
|
| 322 |
strSQL += string.Format(" WHERE P.CONSTRUCTIONCODE = {0}", wrkRec.ConstructionCode);
|
|
| 323 |
strSQL += string.Format(" AND A.CONSTRUCTIONCODE = P.CONSTRUCTIONCODE AND A.DETAILNO = {0}", (int)ConstructionBaseInfoDetail.DataNoDef.ConstructionName);
|
|
| 324 |
ArrayList arList = new ArrayList(); |
|
| 325 |
if (!cbiDB.ExecuteReader(strSQL, ref arList)) return false; |
|
| 326 |
|
|
| 327 |
string DetailString = string.Empty; |
|
| 328 |
//int SalesPersonCode = 0; |
|
| 329 |
string SalesPersonName = string.Empty; |
|
| 330 |
int ConstructionPersonCode = 0; |
|
| 331 |
string ConstructionPersonName = string.Empty; |
|
| 332 |
foreach (object[] onjwrk in arList) |
|
| 333 |
{
|
|
| 334 |
DetailString = CommonMotions.cnvString(onjwrk[0]); |
|
| 335 |
ConstructionPersonCode = CommonMotions.cnvInt(onjwrk[1]); |
|
| 336 |
ConstructionPersonName = CommonMotions.cnvString(onjwrk[2]); |
|
| 337 |
break; |
|
| 338 |
} |
|
| 339 |
|
|
| 340 |
// 新規メッセージ作成 |
|
| 341 |
MessageBoardData WriteData = new MessageBoardData(); |
|
| 342 |
List<MessageBoardTerget> WriteDetail = new List<MessageBoardTerget>(); |
|
| 343 |
|
|
| 344 |
// 掲示板メッセージ |
|
| 345 |
WriteData.FromCode = CommonDefine.s_MsgBoardSystemCode; // 書込み者コード |
|
| 346 |
WriteData.FromName = string.Format(CommonDefine.s_MsgBoardSystemNameFormat, "秘書"); // 書込み者名 |
|
| 347 |
|
|
| 348 |
WriteData.MessageTitle = CheckRec.SendTitle; // 伝言タイトル |
|
| 349 |
|
|
| 350 |
// リンク情報 |
|
| 351 |
WriteData.LinkType = (int)MessageBoardData.LinkTypeDef.MaterialInfo; |
|
| 352 |
WriteData.LinkMessage = string.Format("工事番号:{0} 工事名称:{1}"
|
|
| 353 |
, CommonMotions.cnvStringCodeFromInt(wrkRec.ConstructionCode, "-", 8) |
|
| 354 |
, DetailString); |
|
| 355 |
WriteData.LinkCode = string.Format("{0}", CommonMotions.cnvStringCodeFromInt(wrkRec.ConstructionCode, "-", 8));
|
|
| 356 |
|
|
| 357 |
// 伝言内容 |
|
| 358 |
WriteData.MessageContent = CheckRec.SendMessage; |
|
| 359 |
|
|
| 360 |
|
|
| 361 |
//WriteData.WritingDate = DateTime.Now; // 書込み日付 |
|
| 362 |
WriteData.WritingDate = CriteriaDate.Date + DateTime.Now.TimeOfDay; // 書込み日付 |
|
| 363 |
WriteData.PersonCode = CommonDefine.s_MsgBoardSystemCode; // 書込み担当者コード |
|
| 364 |
WriteData.ShareFlag = 1; // 管理者対象フラグ |
|
| 365 |
|
|
| 366 |
WriteData.BackColor = CheckRec.BackColor; // 背景色セット |
|
| 367 |
WriteData.MessageColor = CheckRec.ForeColor; // 背景色セット |
|
| 368 |
|
|
| 369 |
// 掲示板対象者テーブル |
|
| 370 |
MessageBoardTerget DetailTbl = new MessageBoardTerget |
|
| 371 |
{
|
|
| 372 |
ToCode = ConstructionPersonCode, // 対象者コード |
|
| 373 |
ToName = ConstructionPersonName // 対象者 |
|
| 374 |
}; |
|
| 375 |
WriteDetail.Add(DetailTbl); |
|
| 376 |
|
|
| 377 |
// メッセージフラグを自動に設定する |
|
| 378 |
WriteData.MessageFlag = (int)MessageBoardData.MessageFlgDef.Secretary; |
|
| 379 |
|
|
| 380 |
// 掲示板へメッセージを載せる |
|
| 381 |
if (!ClsMessageBoradAccess.CreateMessage(mbdDB, mbtDB, mbhDB, RecDB, WriteData, WriteDetail)) return false; |
|
| 382 |
|
|
| 383 |
return true; |
|
| 384 |
} |
|
| 385 |
catch (Exception ex) |
|
| 386 |
{
|
|
| 387 |
logger.ErrorFormat("システムエラー:{0}", ex.Message);
|
|
| 388 |
return false; |
|
| 389 |
} |
|
| 390 |
} |
|
| 391 |
#endregion |
|
| 392 |
|
|
| 393 |
#region 資材返却期限チェック処理 |
|
| 394 |
/// <summary> |
|
| 395 |
/// チェック処理 |
|
| 396 |
/// </summary> |
|
| 397 |
/// <returns></returns> |
|
| 398 |
public bool MaterialLimitCheck(DateTime StartDate) |
|
| 399 |
{
|
|
| 400 |
IOConstructionBaseInfo cbiDB = new IOConstructionBaseInfo(); |
|
| 401 |
IOConstructionBaseInfoDetail cbiDDB = new IOConstructionBaseInfoDetail(); |
|
| 402 |
IOMessageBoardData mbdDB = new IOMessageBoardData(); |
|
| 403 |
IOMessageBoardTerget mbtDB = new IOMessageBoardTerget(); |
|
| 404 |
IOMessageBrowsingHistory mbhDB = new IOMessageBrowsingHistory(); |
|
| 405 |
IORecordKey RecDB = new IORecordKey(); |
|
| 406 |
|
|
| 407 |
StringBuilder strSQL = new StringBuilder(); |
|
| 408 |
|
|
| 409 |
try |
|
| 410 |
{
|
|
| 411 |
cbiDB.connect(); cbiDB.beginTran(); |
|
| 412 |
cbiDDB.connect(); cbiDDB.beginTran(); |
|
| 413 |
mbdDB.connect(); mbdDB.beginTran(); |
|
| 414 |
mbtDB.connect(); mbtDB.beginTran(); |
|
| 415 |
mbhDB.connect(); mbhDB.beginTran(); |
|
| 416 |
RecDB.connect(); RecDB.beginTran(); |
|
| 417 |
|
|
| 418 |
bool procflg = true; |
|
| 419 |
|
|
| 420 |
CreateGetMaterialDataSQL(ref strSQL); |
|
| 421 |
|
|
| 422 |
// 資材履歴情報の返却未完了の貸出データを取得する |
|
| 423 |
IOMaterialRecordInfo mrDB = new IOMaterialRecordInfo(); |
|
| 424 |
ArrayList mrData = new ArrayList(); |
|
| 425 |
List<MaterialRecordInfo> data = new List<MaterialRecordInfo>(); |
|
| 426 |
|
|
| 427 |
if (mrDB.ExecuteReader(strSQL.ToString(), ref mrData)) |
|
| 428 |
{
|
|
| 429 |
foreach (object[] objwrk in mrData) |
|
| 430 |
{
|
|
| 431 |
MaterialRecordInfo wrkRec = new MaterialRecordInfo(); |
|
| 432 |
mrDB.Reader2Struct(objwrk, ref wrkRec); |
|
| 433 |
|
|
| 434 |
// チェック |
|
| 435 |
TermMaster term = new TermMaster(); |
|
| 436 |
MaterualStatusCheck(wrkRec, ref term); |
|
| 437 |
|
|
| 438 |
// メッセージ作成 掲示板にメッセージを載せる処理 |
|
| 439 |
if (!MakeSecretaryMassageData(mbdDB, mbtDB, mbhDB, RecDB, cbiDDB, wrkRec, term, StartDate)) |
|
| 440 |
{
|
|
| 441 |
procflg = false; |
|
| 442 |
break; |
|
| 443 |
} |
|
| 444 |
} |
|
| 445 |
|
|
| 446 |
if (procflg) |
|
| 447 |
{
|
|
| 448 |
cbiDB.commit(); |
|
| 449 |
cbiDDB.commit(); |
|
| 450 |
mbdDB.commit(); |
|
| 451 |
mbtDB.commit(); |
|
| 452 |
mbhDB.commit(); |
|
| 453 |
RecDB.commit(); |
|
| 454 |
} |
|
| 455 |
else |
|
| 456 |
{
|
|
| 457 |
cbiDB.rollback(); |
|
| 458 |
cbiDDB.rollback(); |
|
| 459 |
mbdDB.rollback(); |
|
| 460 |
mbtDB.rollback(); |
|
| 461 |
mbhDB.rollback(); |
|
| 462 |
RecDB.rollback(); |
|
| 463 |
} |
|
| 464 |
|
|
| 465 |
return procflg; |
|
| 466 |
} |
|
| 467 |
} |
|
| 468 |
catch (Exception ex) |
|
| 469 |
{
|
|
| 470 |
logger.ErrorFormat("システムエラー:{0}", ex.Message);
|
|
| 471 |
return false; |
|
| 472 |
} |
|
| 473 |
finally |
|
| 474 |
{
|
|
| 475 |
cbiDB.close(); cbiDB = null; |
|
| 476 |
cbiDDB.close(); cbiDDB = null; |
|
| 477 |
mbdDB.close(); mbdDB = null; |
|
| 478 |
mbtDB.close(); mbtDB = null; |
|
| 479 |
mbhDB.close(); mbhDB = null; |
|
| 480 |
RecDB.close(); RecDB = null; |
|
| 481 |
} |
|
| 482 |
return true; |
|
| 483 |
} |
|
| 484 |
#endregion |
|
| 485 |
|
|
| 486 |
#region 資材返却チェックデータ取得SQL作成 |
|
| 487 |
/// <summary> |
|
| 488 |
/// 資材返却チェックデータ取得SQL作成 |
|
| 489 |
/// </summary> |
|
| 490 |
/// <param name="strSQL"></param> |
|
| 491 |
private void CreateGetMaterialDataSQL(ref StringBuilder strSQL) |
|
| 492 |
{
|
|
| 493 |
try |
|
| 494 |
{
|
|
| 495 |
strSQL.Append("SELECT");
|
|
| 496 |
strSQL.Append(" t1.MaterialItemCode");
|
|
| 497 |
strSQL.Append(", t1.ProcessDate");
|
|
| 498 |
strSQL.Append(", t1.SeqNo");
|
|
| 499 |
strSQL.Append(", t1.RecKind");
|
|
| 500 |
strSQL.Append(", t1.ConstructionCode");
|
|
| 501 |
strSQL.Append(", t1.PersonCode");
|
|
| 502 |
strSQL.Append(", t1.MaterialCount");
|
|
| 503 |
strSQL.Append(", MAX(t1.REPAYPLANDATE) AS RepayPlanDate");
|
|
| 504 |
strSQL.Append(", t1.CommentText");
|
|
| 505 |
strSQL.Append(", t1.EntryDate");
|
|
| 506 |
strSQL.Append(", t1.UpdateDate");
|
|
| 507 |
strSQL.Append(" FROM");
|
|
| 508 |
strSQL.Append(" MATERIALRECORDINFO AS t1");
|
|
| 509 |
strSQL.Append(" INNER JOIN CONSTRUCTIONMATERIALINFO AS t2");
|
|
| 510 |
strSQL.Append(" ON t1.CONSTRUCTIONCODE = t2.CONSTRUCTIONCODE");
|
|
| 511 |
strSQL.Append(" AND t1.MATERIALITEMCODE = t2.MATERIALITEMCODE");
|
|
| 512 |
strSQL.Append(" AND DATE(t1.ENTRYDATE) = DATE(t2.PROCESSDATE)");
|
|
| 513 |
strSQL.Append(" AND t2.COMPLETEFLG = 0");
|
|
| 514 |
strSQL.Append(" WHERE");
|
|
| 515 |
strSQL.Append(" t1.CONSTRUCTIONCODE > 0");
|
|
| 516 |
strSQL.Append(" AND t1.CONSTRUCTIONCODE IS NOT NULL");
|
|
| 517 |
strSQL.Append(" AND t1.RECKIND = 0");
|
|
| 518 |
strSQL.Append(" AND t1.REPAYPLANDATE <= DATE_FORMAT(NOW(), '%Y/%m/%d')");
|
|
| 519 |
strSQL.Append(" GROUP BY");
|
|
| 520 |
strSQL.Append(" t1.CONSTRUCTIONCODE");
|
|
| 521 |
strSQL.Append(", t1.PERSONCODE");
|
|
| 522 |
strSQL.Append(" ORDER BY");
|
|
| 523 |
strSQL.Append(" t1.CONSTRUCTIONCODE");
|
|
| 524 |
strSQL.Append(", t1.REPAYPLANDATE");
|
|
| 525 |
} |
|
| 526 |
catch (Exception ex) |
|
| 527 |
{
|
|
| 528 |
logger.ErrorFormat("システムエラー:{0}", ex.Message);
|
|
| 529 |
} |
|
| 530 |
} |
|
| 531 |
#endregion |
|
| 532 |
|
|
| 533 |
#region 工事情報チェック処理 |
|
| 534 |
/// <summary> |
|
| 535 |
/// 日付の期限チェックを行う |
|
| 536 |
/// </summary> |
|
| 537 |
private bool SubmittedDateCheck(DateTime StartDate) |
|
| 538 |
{
|
|
| 539 |
IOConstructionBaseInfo cbiDB = new IOConstructionBaseInfo(); |
|
| 540 |
IOConstructionBaseInfoDetail cbiDDB = new IOConstructionBaseInfoDetail(); |
|
| 541 |
IOMessageBoardData mbdDB = new IOMessageBoardData(); |
|
| 542 |
IOMessageBoardTerget mbtDB = new IOMessageBoardTerget(); |
|
| 543 |
IOMessageBrowsingHistory mbhDB = new IOMessageBrowsingHistory(); |
|
| 544 |
IORecordKey RecDB = new IORecordKey(); |
|
| 545 |
try |
|
| 546 |
{
|
|
| 547 |
// チェック項目取得 |
|
| 548 |
if (!GetTermList()) return false; |
|
| 549 |
|
|
| 550 |
// 工事基本情報を期限テーブルに設定している状態分取得する |
|
| 551 |
StringBuilder strSQL = new StringBuilder(); |
|
| 552 |
|
|
| 553 |
strSQL.Append("Select * From constructionbaseinfo As Atbl");
|
|
| 554 |
strSQL.Append(" Left Join PeriodAvoidance As Ctbl");
|
|
| 555 |
strSQL.Append(" On Ctbl.ConstructionCode = Atbl.ConstructionCode");
|
|
| 556 |
strSQL.Append(" And Ctbl.ConstructionStatusFlg = Atbl.ConstructionStatusFlg");
|
|
| 557 |
strSQL.Append(" WHERE Atbl.CONSTRUCTIONSTATUSFLG IN (SELECT DISTINCT A1.CONSTRUCTIONSTATUSFLG FROM TERMMASTER A1)");
|
|
| 558 |
strSQL.Append(" AND NOT EXISTS (SELECT * From PeriodAvoidance As Btbl");
|
|
| 559 |
strSQL.Append(" Where Btbl.ConstructionCode = Atbl.ConstructionCode");
|
|
| 560 |
strSQL.Append(" And Btbl.ConstructionStatusFlg = Atbl.ConstructionStatusFlg)");
|
|
| 561 |
strSQL.Append(" ORDER BY Atbl.CONSTRUCTIONSTATUSFLG ASC, Atbl.CONSTRUCTIONCODE ASC");
|
|
| 562 |
|
|
| 563 |
ArrayList cbiList = new ArrayList(); |
|
| 564 |
if (!cbiDB.ExecuteReader(strSQL.ToString(), ref cbiList)) return true; |
|
| 565 |
|
|
| 566 |
// 経過日数を取得する |
|
| 567 |
TimeSpan ts = DateTime.Now - StartDate; |
|
| 568 |
int diffDays = ts.Days; |
|
| 569 |
// チェック範囲が10日を超えたら当日だけチェックする |
|
| 570 |
if (diffDays > 10) |
|
| 571 |
{
|
|
| 572 |
diffDays = 1; |
|
| 573 |
StartDate = DateTime.Now.AddDays(-1); |
|
| 574 |
} |
|
| 575 |
|
|
| 576 |
cbiDB.connect(); cbiDB.beginTran(); |
|
| 577 |
cbiDDB.connect(); cbiDDB.beginTran(); |
|
| 578 |
mbdDB.connect(); mbdDB.beginTran(); |
|
| 579 |
mbtDB.connect(); mbtDB.beginTran(); |
|
| 580 |
mbhDB.connect(); mbhDB.beginTran(); |
|
| 581 |
RecDB.connect(); RecDB.beginTran(); |
|
| 582 |
|
|
| 583 |
bool procflg = true; |
|
| 584 |
ConstructionBaseInfo wrkBaseRec = new ConstructionBaseInfo(); |
|
| 585 |
PeriodAvoidance wrkAvoRec = new PeriodAvoidance(); |
|
| 586 |
int offset = Enum.GetNames(typeof(IOConstructionBaseInfo.TableColumn)).Length + 1; |
|
| 587 |
// 経過日数分処理を行う |
|
| 588 |
for (int ix = 0; ix < diffDays; ix++) |
|
| 589 |
{
|
|
| 590 |
DateTime CriteriaDate = StartDate.AddDays((ix + 1)); |
|
| 591 |
foreach (object[] objRec in cbiList) |
|
| 592 |
{
|
|
| 593 |
// 工事情報データセット |
|
| 594 |
cbiDB.Reader2Struct(objRec, ref wrkBaseRec); |
|
| 595 |
|
|
| 596 |
// ----- 工事期限回避データ |
|
| 597 |
// 工事コード |
|
| 598 |
wrkAvoRec.ConstructionCode = CommonMotions.cnvInt(objRec[offset + (int)IOPeriodAvoidance.NameColumn.ConstructionCode]); |
|
| 599 |
// 工事状態フラグ |
|
| 600 |
wrkAvoRec.ConstructionStatusFlg = CommonMotions.cnvInt(objRec[offset + (int)IOPeriodAvoidance.NameColumn.ConstructionStatusFlg]); |
|
| 601 |
// チェック対象フィールド番号 |
|
| 602 |
wrkAvoRec.FieldNo = CommonMotions.cnvInt(objRec[offset + (int)IOPeriodAvoidance.NameColumn.ConstructionStatusFlg]); |
|
| 603 |
|
|
| 604 |
List<TermMaster> term = new List<TermMaster>(); |
|
| 605 |
// 増減工事の子 |
|
| 606 |
if (wrkBaseRec.TyingFlg == (int)ConstructionBaseInfo.TyingFlgDef.Tying) |
|
| 607 |
{
|
|
| 608 |
// 工事予算承認が承認されている場合は処理しない |
|
| 609 |
if (SubmittedDateCheckApproval3(cbiDB, wrkBaseRec.ConstructionCode)) continue; |
|
| 610 |
} |
|
| 611 |
// 結合工事の親は処理しない |
|
| 612 |
if (wrkBaseRec.JoinFlg == (int)ConstructionBaseInfo.JoinFlgDef.JoinParent) continue; |
|
| 613 |
// 結合工事の子は処理しない |
|
| 614 |
if (wrkBaseRec.JoinFlg == (int)ConstructionBaseInfo.JoinFlgDef.JoinChildren) continue; |
|
| 615 |
// チェックOKならば次のデータ |
|
| 616 |
if (ConstructionStatusCheck(wrkBaseRec, wrkAvoRec, CriteriaDate, ref term)) continue; |
|
| 617 |
|
|
| 618 |
// 掲示板にメッセージを載せるためにループ処理 |
|
| 619 |
foreach (TermMaster CurTerm in term) |
|
| 620 |
{
|
|
| 621 |
// メッセージ作成 |
|
| 622 |
if (!MakeMassageData(mbdDB, mbtDB, mbhDB, RecDB, cbiDDB, wrkBaseRec, CurTerm, CriteriaDate)) |
|
| 623 |
{ // エラー時に抜ける
|
|
| 624 |
procflg = false; |
|
| 625 |
break; |
|
| 626 |
} |
|
| 627 |
} |
|
| 628 |
if (!procflg) break; |
|
| 629 |
} |
|
| 630 |
if (!procflg) break; |
|
| 631 |
} |
|
| 632 |
|
|
| 633 |
if (!procflg) |
|
| 634 |
{
|
|
| 635 |
cbiDB.rollback(); |
|
| 636 |
cbiDDB.rollback(); |
|
| 637 |
mbdDB.rollback(); |
|
| 638 |
mbtDB.rollback(); |
|
| 639 |
mbhDB.rollback(); |
|
| 640 |
RecDB.rollback(); |
|
| 641 |
} |
|
| 642 |
|
|
| 643 |
return procflg; |
|
| 644 |
} |
|
| 645 |
catch (Exception ex) |
|
| 646 |
{
|
|
| 647 |
logger.ErrorFormat("システムエラー:{0}", ex.Message);
|
|
| 648 |
return false; |
|
| 649 |
} |
|
| 650 |
finally |
|
| 651 |
{
|
|
| 652 |
cbiDB.commit(); |
|
| 653 |
cbiDDB.commit(); |
|
| 654 |
mbdDB.commit(); |
|
| 655 |
mbtDB.commit(); |
|
| 656 |
mbhDB.commit(); |
|
| 657 |
RecDB.commit(); |
|
| 658 |
|
|
| 659 |
cbiDB.close(); cbiDB = null; |
|
| 660 |
cbiDDB.close(); cbiDDB = null; |
|
| 661 |
mbdDB.close(); mbdDB = null; |
|
| 662 |
mbtDB.close(); mbtDB = null; |
|
| 663 |
mbhDB.close(); mbhDB = null; |
|
| 664 |
RecDB.close(); RecDB = null; |
|
| 665 |
} |
|
| 666 |
} |
|
| 667 |
#endregion |
|
| 668 |
|
|
| 669 |
#region 承認の処理チェック |
|
| 670 |
/// <summary> |
|
| 671 |
/// 承認の処理チェック |
|
| 672 |
/// </summary> |
|
| 673 |
/// <returns></returns> |
|
| 674 |
private bool SubmittedDateCheckApproval3(IOConstructionBaseInfo cbiDB, int nConstrCode) |
|
| 675 |
{
|
|
| 676 |
try |
|
| 677 |
{
|
|
| 678 |
StringBuilder strSQL = new StringBuilder(); |
|
| 679 |
|
|
| 680 |
strSQL.Append("Select");
|
|
| 681 |
strSQL.Append(" B1.ConstructionCode");
|
|
| 682 |
strSQL.Append(", B1.ApprovalCode");
|
|
| 683 |
strSQL.Append(" From");
|
|
| 684 |
strSQL.Append(" processapproval As B1");
|
|
| 685 |
strSQL.Append(" Where");
|
|
| 686 |
strSQL.AppendFormat(" B1.ConstructionCode = {0}", nConstrCode);
|
|
| 687 |
|
|
| 688 |
// ----- 定義がClsExcuteクラスにあるためマジックナンバー |
|
| 689 |
// ----- 3は工事予算承認が承認されていればOK |
|
| 690 |
strSQL.Append(" And B1.ApprovalCode = 3");
|
|
| 691 |
strSQL.Append(" And B1.SeqNo = 1");
|
|
| 692 |
strSQL.AppendFormat(" And B1.ApprovalStatus = {0}", (int)CommonDefine.ApprovalStatus.Approval);
|
|
| 693 |
|
|
| 694 |
ArrayList arList = new ArrayList(); |
|
| 695 |
if (!cbiDB.ExecuteReader(strSQL.ToString(), ref arList, false)) return false; |
|
| 696 |
// 工事予算承認が承認されている場合はOK |
|
| 697 |
if (arList.Count > 0) return true; |
|
| 698 |
|
|
| 699 |
return false; |
|
| 700 |
} |
|
| 701 |
catch (Exception ex) |
|
| 702 |
{
|
|
| 703 |
logger.ErrorFormat("システムエラー:{0}", ex.Message);
|
|
| 704 |
return false; |
|
| 705 |
} |
|
| 706 |
} |
|
| 707 |
#endregion |
|
| 708 |
|
|
| 709 |
#region チェック処理 |
|
| 710 |
/// <summary> |
|
| 711 |
/// チェック処理 |
|
| 712 |
/// </summary> |
|
| 713 |
/// <returns></returns> |
|
| 714 |
public bool ConstructionStatusCheck(ConstructionBaseInfo checkRec, PeriodAvoidance AvoidanceRec, DateTime CriteriaDate, ref List<TermMaster> TermRec) |
|
| 715 |
{
|
|
| 716 |
try |
|
| 717 |
{
|
|
| 718 |
// 戻り値 |
|
| 719 |
bool bCheckNoError = true; |
|
| 720 |
|
|
| 721 |
int nStatusFlg = -1; |
|
| 722 |
int nFieldNo = -1; |
|
| 723 |
int nCheckSchdule = -1; |
|
| 724 |
bool ErrFlg = false; |
|
| 725 |
// エラーチェック |
|
| 726 |
foreach (object[] objCode in m_TermCodeArray) |
|
| 727 |
{
|
|
| 728 |
nStatusFlg = CommonMotions.cnvInt(objCode[0]); |
|
| 729 |
nFieldNo = CommonMotions.cnvInt(objCode[1]); |
|
| 730 |
nCheckSchdule = CommonMotions.cnvInt(objCode[2]); |
|
| 731 |
|
|
| 732 |
// 状態が対象外は処理しない |
|
| 733 |
if (nStatusFlg != checkRec.ConstructionStatusFlg) continue; |
|
| 734 |
|
|
| 735 |
TermMaster[] CheckTerget = m_TermMstList.Cast<TermMaster>().Where(x => x.ConstructionStatusFlg == nStatusFlg |
|
| 736 |
&& x.FieldNo == nFieldNo |
|
| 737 |
&& x.CheckSchdule == nCheckSchdule) |
|
| 738 |
.OrderByDescending(x => x.TermDays) |
|
| 739 |
.ToArray(); |
|
| 740 |
foreach (TermMaster wrkCheck in CheckTerget) |
|
| 741 |
{
|
|
| 742 |
// 解除データがあれば次レコード |
|
| 743 |
if (wrkCheck.FieldNo == AvoidanceRec.FieldNo) continue; |
|
| 744 |
|
|
他の形式にエクスポート: Unified diff