20211021045210_CalMonth.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. namespace wispro.sp.api.Migrations
  4. {
  5. public partial class CalMonth : Migration
  6. {
  7. protected override void Up(MigrationBuilder migrationBuilder)
  8. {
  9. migrationBuilder.CreateTable(
  10. name: "BasePointRules",
  11. columns: table => new
  12. {
  13. Id = table.Column<int>(type: "int", nullable: false)
  14. .Annotation("SqlServer:Identity", "1, 1"),
  15. Rule = table.Column<string>(type: "nvarchar(max)", nullable: true),
  16. Point = table.Column<double>(type: "float", nullable: false)
  17. },
  18. constraints: table =>
  19. {
  20. table.PrimaryKey("PK_BasePointRules", x => x.Id);
  21. });
  22. migrationBuilder.CreateTable(
  23. name: "CalMonth",
  24. columns: table => new
  25. {
  26. Id = table.Column<int>(type: "int", nullable: false)
  27. .Annotation("SqlServer:Identity", "1, 1"),
  28. year = table.Column<int>(type: "int", nullable: false),
  29. month = table.Column<int>(type: "int", nullable: false),
  30. status = table.Column<int>(type: "int", nullable: false)
  31. },
  32. constraints: table =>
  33. {
  34. table.PrimaryKey("PK_CalMonth", x => x.Id);
  35. });
  36. migrationBuilder.CreateTable(
  37. name: "StaffGrade",
  38. columns: table => new
  39. {
  40. Id = table.Column<int>(type: "int", nullable: false)
  41. .Annotation("SqlServer:Identity", "1, 1"),
  42. Grade = table.Column<string>(type: "nchar(5)", fixedLength: true, maxLength: 5, nullable: false),
  43. Coefficient = table.Column<double>(type: "float", nullable: false)
  44. },
  45. constraints: table =>
  46. {
  47. table.PrimaryKey("PK_StaffGrade", x => x.Id);
  48. });
  49. migrationBuilder.CreateTable(
  50. name: "Staff",
  51. columns: table => new
  52. {
  53. Id = table.Column<int>(type: "int", nullable: false)
  54. .Annotation("SqlServer:Identity", "1, 1"),
  55. Account = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
  56. Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
  57. Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
  58. Status = table.Column<string>(type: "nvarchar(25)", maxLength: 25, nullable: false),
  59. isCalPerformsnce = table.Column<bool>(type: "bit", nullable: false),
  60. StaffGradeId = table.Column<int>(type: "int", nullable: false),
  61. Department = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  62. WorkPlace = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  63. EntyDate = table.Column<DateTime>(type: "date", nullable: true),
  64. Mail = table.Column<string>(type: "nvarchar(max)", nullable: true),
  65. Memo = table.Column<string>(type: "nvarchar(max)", nullable: true)
  66. },
  67. constraints: table =>
  68. {
  69. table.PrimaryKey("PK_Staff", x => x.Id);
  70. table.ForeignKey(
  71. name: "FK_Staff_StaffGrade",
  72. column: x => x.StaffGradeId,
  73. principalTable: "StaffGrade",
  74. principalColumn: "Id",
  75. onDelete: ReferentialAction.Restrict);
  76. });
  77. migrationBuilder.CreateTable(
  78. name: "VerifyCoefficient",
  79. columns: table => new
  80. {
  81. CheckerId = table.Column<int>(type: "int", nullable: false),
  82. DoPersonId = table.Column<int>(type: "int", nullable: false),
  83. Coefficient = table.Column<double>(type: "float", nullable: false)
  84. },
  85. constraints: table =>
  86. {
  87. table.PrimaryKey("PK_VerifyCoefficient", x => new { x.CheckerId, x.DoPersonId });
  88. table.ForeignKey(
  89. name: "FK_VerifyCoefficient_StaffGrade",
  90. column: x => x.CheckerId,
  91. principalTable: "StaffGrade",
  92. principalColumn: "Id",
  93. onDelete: ReferentialAction.Restrict);
  94. table.ForeignKey(
  95. name: "FK_VerifyCoefficient_StaffGrade1",
  96. column: x => x.DoPersonId,
  97. principalTable: "StaffGrade",
  98. principalColumn: "Id",
  99. onDelete: ReferentialAction.Restrict);
  100. });
  101. migrationBuilder.CreateTable(
  102. name: "AttachFile",
  103. columns: table => new
  104. {
  105. Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
  106. Name = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
  107. SavePath = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
  108. UploadUserId = table.Column<int>(type: "int", nullable: false)
  109. },
  110. constraints: table =>
  111. {
  112. table.PrimaryKey("PK_AttachFile", x => x.Id);
  113. table.ForeignKey(
  114. name: "FK_AttachFile_UpdateUser",
  115. column: x => x.UploadUserId,
  116. principalTable: "Staff",
  117. principalColumn: "Id",
  118. onDelete: ReferentialAction.Cascade);
  119. });
  120. migrationBuilder.CreateTable(
  121. name: "Customer",
  122. columns: table => new
  123. {
  124. Id = table.Column<int>(type: "int", nullable: false)
  125. .Annotation("SqlServer:Identity", "1, 1"),
  126. Name = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
  127. ContactMan = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  128. Address = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
  129. Phone = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  130. ResponseManId = table.Column<int>(type: "int", nullable: true)
  131. },
  132. constraints: table =>
  133. {
  134. table.PrimaryKey("PK_Customer", x => x.Id);
  135. table.ForeignKey(
  136. name: "FK_Customer_Staff",
  137. column: x => x.ResponseManId,
  138. principalTable: "Staff",
  139. principalColumn: "Id",
  140. onDelete: ReferentialAction.Restrict);
  141. });
  142. migrationBuilder.CreateTable(
  143. name: "Message",
  144. columns: table => new
  145. {
  146. Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
  147. MessageInfo = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
  148. Type = table.Column<int>(type: "int", nullable: false),
  149. FromId = table.Column<int>(type: "int", nullable: false)
  150. },
  151. constraints: table =>
  152. {
  153. table.PrimaryKey("PK_Message", x => x.Id);
  154. table.ForeignKey(
  155. name: "FK_From_Staff",
  156. column: x => x.FromId,
  157. principalTable: "Staff",
  158. principalColumn: "Id",
  159. onDelete: ReferentialAction.Restrict);
  160. });
  161. migrationBuilder.CreateTable(
  162. name: "PerformanceItem",
  163. columns: table => new
  164. {
  165. Id = table.Column<int>(type: "int", nullable: false)
  166. .Annotation("SqlServer:Identity", "1, 1"),
  167. CaseNo = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  168. ApplicationType = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  169. BusinessType = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  170. AgentFeedbackMemo = table.Column<string>(type: "nvarchar(max)", nullable: true),
  171. DoItem = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  172. CaseStage = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  173. CaseCoefficient = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: true),
  174. DoItemCoefficient = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  175. PreOAStaffId = table.Column<int>(type: "int", nullable: true),
  176. ReviewerId = table.Column<int>(type: "int", nullable: true),
  177. CustomerId = table.Column<int>(type: "int", nullable: true),
  178. ApplicationName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
  179. FinishedDate = table.Column<DateTime>(type: "date", nullable: true),
  180. FinalizationDate = table.Column<DateTime>(type: "date", nullable: true),
  181. ReturnDate = table.Column<DateTime>(type: "date", nullable: true),
  182. CaseType = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  183. CaseState = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  184. DoItemMemo = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
  185. DoItemState = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
  186. CaseName = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
  187. CustomerLimitDate = table.Column<DateTime>(type: "date", nullable: true),
  188. EntrustingDate = table.Column<DateTime>(type: "date", nullable: true),
  189. InternalDate = table.Column<DateTime>(type: "date", nullable: true),
  190. FirstDraftDate = table.Column<DateTime>(type: "date", nullable: true),
  191. OverDueMemo = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
  192. BasePoint = table.Column<decimal>(type: "numeric(18,2)", nullable: true),
  193. Status = table.Column<int>(type: "int", nullable: true),
  194. CaseMemo = table.Column<string>(type: "nvarchar(max)", nullable: true),
  195. CalMonthId = table.Column<int>(type: "int", nullable: false)
  196. },
  197. constraints: table =>
  198. {
  199. table.PrimaryKey("PK_PerformanceItem", x => x.Id);
  200. table.ForeignKey(
  201. name: "FK_PerformanceItem_CalMonth",
  202. column: x => x.CalMonthId,
  203. principalTable: "CalMonth",
  204. principalColumn: "Id",
  205. onDelete: ReferentialAction.Cascade);
  206. table.ForeignKey(
  207. name: "FK_PerformanceItem_Customer",
  208. column: x => x.CustomerId,
  209. principalTable: "Customer",
  210. principalColumn: "Id",
  211. onDelete: ReferentialAction.Restrict);
  212. table.ForeignKey(
  213. name: "FK_PerformanceItem_Reviewer",
  214. column: x => x.ReviewerId,
  215. principalTable: "Staff",
  216. principalColumn: "Id",
  217. onDelete: ReferentialAction.Restrict);
  218. table.ForeignKey(
  219. name: "FK_PerformanceItem_Staff",
  220. column: x => x.PreOAStaffId,
  221. principalTable: "Staff",
  222. principalColumn: "Id",
  223. onDelete: ReferentialAction.Restrict);
  224. });
  225. migrationBuilder.CreateTable(
  226. name: "MessageReadRecord",
  227. columns: table => new
  228. {
  229. MessageId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
  230. StaffId = table.Column<int>(type: "int", nullable: false),
  231. isReaded = table.Column<bool>(type: "bit", nullable: false),
  232. MessageId1 = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
  233. },
  234. constraints: table =>
  235. {
  236. table.PrimaryKey("PK_MessageReadRecord", x => new { x.MessageId, x.StaffId });
  237. table.ForeignKey(
  238. name: "FK_MessageReadRecord_Message",
  239. column: x => x.MessageId,
  240. principalTable: "Message",
  241. principalColumn: "Id",
  242. onDelete: ReferentialAction.Restrict);
  243. table.ForeignKey(
  244. name: "FK_MessageReadRecord_Message_MessageId1",
  245. column: x => x.MessageId1,
  246. principalTable: "Message",
  247. principalColumn: "Id",
  248. onDelete: ReferentialAction.Restrict);
  249. table.ForeignKey(
  250. name: "FK_MessageReadRecord_Staff",
  251. column: x => x.StaffId,
  252. principalTable: "Staff",
  253. principalColumn: "Id",
  254. onDelete: ReferentialAction.Restrict);
  255. });
  256. migrationBuilder.CreateTable(
  257. name: "ItemStaff",
  258. columns: table => new
  259. {
  260. ItemId = table.Column<int>(type: "int", nullable: false),
  261. DoPersonId = table.Column<int>(type: "int", nullable: false),
  262. PerformancePoint = table.Column<double>(type: "float", nullable: false)
  263. },
  264. constraints: table =>
  265. {
  266. table.PrimaryKey("PK_ItemStaff", x => new { x.ItemId, x.DoPersonId });
  267. table.ForeignKey(
  268. name: "FK_ItemStaff_PerformanceItem",
  269. column: x => x.ItemId,
  270. principalTable: "PerformanceItem",
  271. principalColumn: "Id",
  272. onDelete: ReferentialAction.Restrict);
  273. table.ForeignKey(
  274. name: "FK_ItemStaff_Staff",
  275. column: x => x.DoPersonId,
  276. principalTable: "Staff",
  277. principalColumn: "Id",
  278. onDelete: ReferentialAction.Restrict);
  279. });
  280. migrationBuilder.CreateTable(
  281. name: "MessagePerformanceItems",
  282. columns: table => new
  283. {
  284. MessageId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
  285. ItemId = table.Column<int>(type: "int", nullable: false)
  286. },
  287. constraints: table =>
  288. {
  289. table.PrimaryKey("PK_MessagePerformanceItems", x => new { x.ItemId, x.MessageId });
  290. table.ForeignKey(
  291. name: "FK_MessagePerformanceItem_Item",
  292. column: x => x.ItemId,
  293. principalTable: "PerformanceItem",
  294. principalColumn: "Id",
  295. onDelete: ReferentialAction.Cascade);
  296. table.ForeignKey(
  297. name: "FK_MessagePerformanceItem_Message",
  298. column: x => x.MessageId,
  299. principalTable: "Message",
  300. principalColumn: "Id",
  301. onDelete: ReferentialAction.Cascade);
  302. });
  303. migrationBuilder.InsertData(
  304. table: "StaffGrade",
  305. columns: new[] { "Id", "Coefficient", "Grade" },
  306. values: new object[,]
  307. {
  308. { 1, 1.2, "S级" },
  309. { 2, 1.1000000000000001, "A3级" },
  310. { 3, 1.1000000000000001, "A2级" },
  311. { 4, 1.1000000000000001, "A1级" },
  312. { 5, 1.0, "B3级" },
  313. { 6, 1.0, "B2级" },
  314. { 7, 0.90000000000000002, "B1级" },
  315. { 8, 0.90000000000000002, "C3级" },
  316. { 9, 0.69999999999999996, "C2级" },
  317. { 10, 0.69999999999999996, "C1级" },
  318. { 11, 0.59999999999999998, "D3级" },
  319. { 12, 0.59999999999999998, "D2级" },
  320. { 13, 0.5, "D1级" }
  321. });
  322. migrationBuilder.InsertData(
  323. table: "VerifyCoefficient",
  324. columns: new[] { "CheckerId", "DoPersonId", "Coefficient" },
  325. values: new object[,]
  326. {
  327. { 2, 5, 0.20000000000000001 },
  328. { 2, 13, 0.5 },
  329. { 4, 12, 0.40000000000000002 },
  330. { 3, 12, 0.40000000000000002 },
  331. { 2, 12, 0.40000000000000002 },
  332. { 4, 11, 0.40000000000000002 },
  333. { 3, 11, 0.40000000000000002 },
  334. { 2, 11, 0.40000000000000002 },
  335. { 4, 10, 0.29999999999999999 },
  336. { 3, 10, 0.29999999999999999 },
  337. { 2, 10, 0.29999999999999999 },
  338. { 4, 9, 0.29999999999999999 },
  339. { 3, 13, 0.5 },
  340. { 3, 9, 0.29999999999999999 },
  341. { 4, 8, 0.20000000000000001 },
  342. { 3, 8, 0.20000000000000001 },
  343. { 2, 8, 0.20000000000000001 },
  344. { 4, 7, 0.20000000000000001 },
  345. { 3, 7, 0.20000000000000001 },
  346. { 2, 7, 0.20000000000000001 },
  347. { 4, 6, 0.20000000000000001 },
  348. { 3, 6, 0.20000000000000001 },
  349. { 2, 6, 0.20000000000000001 },
  350. { 4, 5, 0.20000000000000001 },
  351. { 3, 5, 0.20000000000000001 },
  352. { 2, 9, 0.29999999999999999 },
  353. { 4, 13, 0.5 }
  354. });
  355. migrationBuilder.CreateIndex(
  356. name: "IX_AttachFile_UploadUserId",
  357. table: "AttachFile",
  358. column: "UploadUserId");
  359. migrationBuilder.CreateIndex(
  360. name: "IX_Customer_ResponseManId",
  361. table: "Customer",
  362. column: "ResponseManId");
  363. migrationBuilder.CreateIndex(
  364. name: "IX_ItemStaff_DoPersonId",
  365. table: "ItemStaff",
  366. column: "DoPersonId");
  367. migrationBuilder.CreateIndex(
  368. name: "IX_Message_FromId",
  369. table: "Message",
  370. column: "FromId");
  371. migrationBuilder.CreateIndex(
  372. name: "IX_MessagePerformanceItems_MessageId",
  373. table: "MessagePerformanceItems",
  374. column: "MessageId");
  375. migrationBuilder.CreateIndex(
  376. name: "IX_MessageReadRecord_MessageId1",
  377. table: "MessageReadRecord",
  378. column: "MessageId1");
  379. migrationBuilder.CreateIndex(
  380. name: "IX_MessageReadRecord_StaffId",
  381. table: "MessageReadRecord",
  382. column: "StaffId");
  383. migrationBuilder.CreateIndex(
  384. name: "IX_PerformanceItem_CalMonthId",
  385. table: "PerformanceItem",
  386. column: "CalMonthId");
  387. migrationBuilder.CreateIndex(
  388. name: "IX_PerformanceItem_CustomerId",
  389. table: "PerformanceItem",
  390. column: "CustomerId");
  391. migrationBuilder.CreateIndex(
  392. name: "IX_PerformanceItem_PreOAStaffId",
  393. table: "PerformanceItem",
  394. column: "PreOAStaffId");
  395. migrationBuilder.CreateIndex(
  396. name: "IX_PerformanceItem_ReviewerId",
  397. table: "PerformanceItem",
  398. column: "ReviewerId");
  399. migrationBuilder.CreateIndex(
  400. name: "IX_Staff_StaffGradeId",
  401. table: "Staff",
  402. column: "StaffGradeId");
  403. migrationBuilder.CreateIndex(
  404. name: "IX_VerifyCoefficient_DoPersonId",
  405. table: "VerifyCoefficient",
  406. column: "DoPersonId");
  407. }
  408. protected override void Down(MigrationBuilder migrationBuilder)
  409. {
  410. migrationBuilder.DropTable(
  411. name: "AttachFile");
  412. migrationBuilder.DropTable(
  413. name: "BasePointRules");
  414. migrationBuilder.DropTable(
  415. name: "ItemStaff");
  416. migrationBuilder.DropTable(
  417. name: "MessagePerformanceItems");
  418. migrationBuilder.DropTable(
  419. name: "MessageReadRecord");
  420. migrationBuilder.DropTable(
  421. name: "VerifyCoefficient");
  422. migrationBuilder.DropTable(
  423. name: "PerformanceItem");
  424. migrationBuilder.DropTable(
  425. name: "Message");
  426. migrationBuilder.DropTable(
  427. name: "CalMonth");
  428. migrationBuilder.DropTable(
  429. name: "Customer");
  430. migrationBuilder.DropTable(
  431. name: "Staff");
  432. migrationBuilder.DropTable(
  433. name: "StaffGrade");
  434. }
  435. }
  436. }