You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1248 lines
102 KiB

2 years ago
  1. using EasyBL.WebApi.Message;
  2. using Entity.Sugar;
  3. using Entity.ViewModels;
  4. using Newtonsoft.Json.Linq;
  5. using SqlSugar;
  6. using SqlSugar.Base;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Data;
  10. using System.Drawing;
  11. using EasyBL;
  12. using Newtonsoft.Json;
  13. using System.Linq;
  14. namespace EasyBL.WEBAPP.OPM
  15. {
  16. public class ExhibitionExport_QryService : ServiceBase
  17. {
  18. #region 出口分頁查詢
  19. /// <summary>
  20. /// 出口分頁查詢
  21. /// </summary>
  22. /// <param name="i_crm"></param>
  23. /// <returns></returns>
  24. public ResponseMessage QueryPage(RequestMessage i_crm)
  25. {
  26. ResponseMessage rm = null;
  27. string sMsg = null;
  28. var db = SugarBase.GetIntance();
  29. try
  30. {
  31. do
  32. {
  33. var pml = new PageModel
  34. {
  35. PageIndex = _fetchInt(i_crm, @"pageIndex"),
  36. PageSize = _fetchInt(i_crm, @"pageSize")
  37. };
  38. var iPageCount = 0;
  39. var sSortField = _fetchString(i_crm, @"sortField");
  40. var sSortOrder = _fetchString(i_crm, @"sortOrder");
  41. var sRefNumber = _fetchString(i_crm, @"RefNumber");
  42. var sExportBillName = _fetchString(i_crm, @"ExportBillName");
  43. var sBillNO = _fetchString(i_crm, @"BillNO");
  44. var sExhibitionDateStart = _fetchString(i_crm, @"ExhibitionDateStart");
  45. var sExhibitionDateEnd = _fetchString(i_crm, @"ExhibitionDateEnd");
  46. var sAgent = _fetchString(i_crm, @"Agent");
  47. var sResponsiblePerson = _fetchString(i_crm, @"ResponsiblePerson");
  48. var sBillLadNO = _fetchString(i_crm, @"BillLadNO");
  49. var sJobTracking = _fetchString(i_crm, @"JobTracking");
  50. var sIsIncludeVoid = _fetchString(i_crm, @"IsIncludeVoid");
  51. var sSupplier = _fetchString(i_crm, @"Supplier");
  52. var sREF = _fetchString(i_crm, @"REF");
  53. var sDepartmentID = _fetchString(i_crm, @"DepartmentID");
  54. var sFlow_Status = _fetchString(i_crm, @"Flow_Status");
  55. var bExcel = _fetchBool(i_crm, @"Excel");
  56. var sExcelType = _fetchString(i_crm, @"ExcelType");
  57. string[] saJobTracking = null;
  58. string[] saIsIncludeVoid = null;
  59. var rExhibitionDateStart = new DateTime();
  60. var rExhibitionDateEnd = new DateTime();
  61. if (!string.IsNullOrEmpty(sExhibitionDateStart))
  62. {
  63. rExhibitionDateStart = SqlFunc.ToDate(sExhibitionDateStart);
  64. }
  65. if (!string.IsNullOrEmpty(sExhibitionDateEnd))
  66. {
  67. rExhibitionDateEnd = SqlFunc.ToDate(sExhibitionDateEnd).AddDays(1);
  68. }
  69. if (!string.IsNullOrEmpty(sJobTracking))
  70. {
  71. saJobTracking = sJobTracking.Split(',');
  72. }
  73. if (!string.IsNullOrEmpty(sIsIncludeVoid))
  74. {
  75. saIsIncludeVoid = sIsIncludeVoid.Split(',');
  76. }
  77. var spOrgID = new SugarParameter("@OrgID", i_crm.ORIGID);
  78. var spUserID = new SugarParameter("@UserID", i_crm.USERID);
  79. var spDepartmentID = new SugarParameter("@DepartmentID", sDepartmentID);
  80. var saRoles = db.Queryable<OTB_SYS_MembersToRule>().Where(x => x.OrgID == i_crm.ORIGID && x.MemberID == i_crm.USERID).Select(x => x.RuleID).ToList().ToArray();
  81. var saChildDeptIds = db.Ado.SqlQuery<string>("select DepartmentId from [dbo].[OFN_SYS_GetChilDepartmentIdByDepartmentId](@OrgID,@DepartmentID)", spOrgID, spDepartmentID).ToArray();
  82. var saDeptIdsByUser = db.Ado.SqlQuery<string>("SELECT DepartmentId FROM [dbo].[OFN_SYS_GetChilDepartmentIdByUserID](@OrgID,@UserID)", spOrgID, spUserID).ToArray();
  83. var saChildUserIds = db.Ado.SqlQuery<string>("SELECT MemberID FROM [dbo].[OFN_SYS_GetMemberIDDownByChief](@OrgID,@UserID)", spOrgID, spUserID).ToArray();
  84. pml.DataList = db.Queryable<OTB_OPM_ExportExhibition, OTB_SYS_Members, OTB_OPM_Exhibition, OTB_CRM_Customers, OTB_CRM_Customers>
  85. ((t1, t2, t3, t5, t6) =>
  86. new object[] {
  87. JoinType.Inner, t1.OrgID == t2.OrgID && t1.ResponsiblePerson == t2.MemberID,
  88. JoinType.Left, t1.OrgID == t3.OrgID && t1.ExhibitionNO == t3.SN.ToString(),
  89. JoinType.Left, t1.OrgID == t5.OrgID && t1.Agent == t5.guid,
  90. JoinType.Left, t1.OrgID == t6.OrgID && t1.Organizer == t6.guid
  91. }
  92. )
  93. .Where((t1) => t1.OrgID == i_crm.ORIGID)
  94. .WhereIF(!string.IsNullOrEmpty(sRefNumber), (t1) => (t1.RefNumber + t1.Exhibitors).Contains(sRefNumber))
  95. .WhereIF(!string.IsNullOrEmpty(sExportBillName), (t1, t2, t3) => (t3.Exhibitioname_TW + t3.Exhibitioname_EN + t3.ExhibitioShotName_TW).Contains(sExportBillName))
  96. .WhereIF(!string.IsNullOrEmpty(sResponsiblePerson), (t1) => t1.ResponsiblePerson == sResponsiblePerson)
  97. .WhereIF(!string.IsNullOrEmpty(sAgent), (t1, t2, t3, t4, t5) => (t5.CustomerCName + t5.CustomerEName).Contains(sAgent))
  98. .WhereIF(!string.IsNullOrEmpty(sSupplier), (t1, t2, t3, t5, t6) => (t6.CustomerCName + t6.CustomerEName).Contains(sSupplier))
  99. .WhereIF(!string.IsNullOrEmpty(sBillLadNO), (t1) => (t1.BillLadNO + t1.Exhibitors).Contains(sBillLadNO))
  100. .WhereIF(!string.IsNullOrEmpty(sFlow_Status), (t1) => t1.Flow_Status == sFlow_Status)
  101. .WhereIF(!string.IsNullOrEmpty(sBillNO), (t1) => (t1.Bills + t1.ReturnBills).Contains("\"BillNO\":%\"" + sBillNO))
  102. .WhereIF(!string.IsNullOrEmpty(sREF), (t1) => t1.REF.Contains(sREF))
  103. .WhereIF(!string.IsNullOrEmpty(sDepartmentID), (t1) => SqlFunc.ContainsArray(saChildDeptIds, t1.DepartmentID))
  104. .WhereIF(!string.IsNullOrEmpty(sJobTracking), (t1) => SqlFunc.ContainsArray(saJobTracking, t1.Release))
  105. .WhereIF(!string.IsNullOrEmpty(sIsIncludeVoid), (t1) => SqlFunc.ContainsArray(saIsIncludeVoid, t1.IsVoid))
  106. .WhereIF(!string.IsNullOrEmpty(sExhibitionDateStart), (t1) => t1.ExhibitionDateStart >= rExhibitionDateStart.Date)
  107. .WhereIF(!string.IsNullOrEmpty(sExhibitionDateEnd), (t1) => t1.ExhibitionDateEnd <= rExhibitionDateEnd.Date)
  108. .Where((t1) => t1.CreateUser == i_crm.USERID || t1.ResponsiblePerson == i_crm.USERID || SqlFunc.ContainsArray(saDeptIdsByUser, t1.DepartmentID) ||
  109. SqlFunc.Subqueryable<OTB_SYS_Members>().Where(c => c.MemberID == t1.CreateUser && c.OrgID == t1.OrgID).Select(c => c.ImmediateSupervisor) == i_crm.USERID ||
  110. SqlFunc.Subqueryable<OTB_SYS_Members>().Where(p => p.MemberID == t1.ResponsiblePerson && p.OrgID == t1.OrgID).Select(c => c.ImmediateSupervisor) == i_crm.USERID || SqlFunc.ContainsArray(saChildUserIds, t1.CreateUser) || SqlFunc.ContainsArray(saChildUserIds, t1.ResponsiblePerson) || SqlFunc.ContainsArray(saRoles, "Account") || SqlFunc.ContainsArray(saRoles, "CDD") || SqlFunc.ContainsArray(saRoles, "Admin") || SqlFunc.ContainsArray(saRoles, "Manager"))
  111. .Select((t1, t2, t3, t5) => new View_OPM_ExportExhibition
  112. {
  113. OrgID = t1.OrgID,
  114. ExportBillNO = t1.ExportBillNO,
  115. RefNumber = t1.RefNumber,
  116. ExportBillName = t3.Exhibitioname_TW,
  117. ExportBillEName = t3.Exhibitioname_EN,
  118. ExhibitionDateStart = t1.ExhibitionDateStart,
  119. ExhibitionDateEnd = t1.ExhibitionDateEnd,
  120. BillLadNO = t1.BillLadNO,
  121. IsVoid = t1.IsVoid,
  122. Flow_Status = t1.Flow_Status,
  123. Bills = t1.Bills,
  124. ReturnBills = t1.ReturnBills,
  125. REF = t1.REF,
  126. IsAlert = SqlFunc.MappingColumn(t1.ImportBillNO, "[dbo].[OFN_OPM_CheckDate](t1.Release,t1.ExhibitionDateStart,5)"),
  127. AgentName = SqlFunc.IIF(SqlFunc.HasValue(t5.CustomerCName), t5.CustomerCName, t5.CustomerEName),
  128. ResponsiblePersonName = t2.MemberName,
  129. })
  130. .MergeTable()
  131. .OrderByIF(string.IsNullOrEmpty(sSortField), "IsAlert desc,ExhibitionDateStart desc,ExportBillName,RefNumber desc")
  132. .OrderByIF(!string.IsNullOrEmpty(sSortField), sSortField + " " + sSortOrder)
  133. .ToPageList(pml.PageIndex, bExcel ? 100000 : pml.PageSize, ref iPageCount);
  134. pml.Total = iPageCount;
  135. rm = new SuccessResponseMessage(null, i_crm);
  136. if (bExcel)
  137. {
  138. }
  139. else
  140. {
  141. rm.DATA.Add(BLWording.REL, pml);
  142. }
  143. } while (false);
  144. }
  145. catch (Exception ex)
  146. {
  147. sMsg = Util.GetLastExceptionMsg(ex);
  148. LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, "EasyBL.WEBAPP.OPM.ImportExhibition_QryService", "", "QueryPage(出口分頁查詢)", "", "", "");
  149. }
  150. finally
  151. {
  152. if (null != sMsg)
  153. {
  154. rm = new ErrorResponseMessage(sMsg, i_crm);
  155. }
  156. }
  157. return rm;
  158. }
  159. #endregion 出口分頁查詢
  160. #region 出口分頁查詢
  161. /// <summary>
  162. /// 出口分頁查詢
  163. /// </summary>
  164. /// <param name="i_crm"></param>
  165. /// <returns></returns>
  166. public ResponseMessage GetExcel(RequestMessage i_crm)
  167. {
  168. ResponseMessage rm = null;
  169. string sMsg = null;
  170. var db = SugarBase.GetIntance();
  171. try
  172. {
  173. do
  174. {
  175. var pml = new PageModel
  176. {
  177. PageIndex = _fetchInt(i_crm, @"pageIndex"),
  178. PageSize = _fetchInt(i_crm, @"pageSize")
  179. };
  180. var iPageCount = 0;
  181. var sSortField = _fetchString(i_crm, @"sortField");
  182. var sSortOrder = _fetchString(i_crm, @"sortOrder");
  183. var sRefNumber = _fetchString(i_crm, @"RefNumber");
  184. var sExportBillName = _fetchString(i_crm, @"ExportBillName");
  185. var sBillNO = _fetchString(i_crm, @"BillNO");
  186. var sExhibitionDateStart = _fetchString(i_crm, @"ExhibitionDateStart");
  187. var sExhibitionDateEnd = _fetchString(i_crm, @"ExhibitionDateEnd");
  188. var sAgent = _fetchString(i_crm, @"Agent");
  189. var sResponsiblePerson = _fetchString(i_crm, @"ResponsiblePerson");
  190. var sBillLadNO = _fetchString(i_crm, @"BillLadNO");
  191. var sJobTracking = _fetchString(i_crm, @"JobTracking");
  192. var sIsIncludeVoid = _fetchString(i_crm, @"IsIncludeVoid");
  193. var sSupplier = _fetchString(i_crm, @"Supplier");
  194. var sREF = _fetchString(i_crm, @"REF");
  195. var sDepartmentID = _fetchString(i_crm, @"DepartmentID");
  196. var sFlow_Status = _fetchString(i_crm, @"Flow_Status");
  197. var bExcel = _fetchBool(i_crm, @"Excel");
  198. var sExcelType = _fetchString(i_crm, @"ExcelType");
  199. string[] saJobTracking = null;
  200. string[] saIsIncludeVoid = null;
  201. var rExhibitionDateStart = new DateTime();
  202. var rExhibitionDateEnd = new DateTime();
  203. if (!string.IsNullOrEmpty(sExhibitionDateStart))
  204. {
  205. rExhibitionDateStart = SqlFunc.ToDate(sExhibitionDateStart);
  206. }
  207. if (!string.IsNullOrEmpty(sExhibitionDateEnd))
  208. {
  209. rExhibitionDateEnd = SqlFunc.ToDate(sExhibitionDateEnd).AddDays(1);
  210. }
  211. if (!string.IsNullOrEmpty(sJobTracking))
  212. {
  213. saJobTracking = sJobTracking.Split(',');
  214. }
  215. if (!string.IsNullOrEmpty(sIsIncludeVoid))
  216. {
  217. saIsIncludeVoid = sIsIncludeVoid.Split(',');
  218. }
  219. var spOrgID = new SugarParameter("@OrgID", i_crm.ORIGID);
  220. var spUserID = new SugarParameter("@UserID", i_crm.USERID);
  221. var spDepartmentID = new SugarParameter("@DepartmentID", sDepartmentID);
  222. var saRoles = db.Queryable<OTB_SYS_MembersToRule>().Where(x => x.OrgID == i_crm.ORIGID && x.MemberID == i_crm.USERID).Select(x => x.RuleID).ToList().ToArray();
  223. var saChildDeptIds = db.Ado.SqlQuery<string>("select DepartmentId from [dbo].[OFN_SYS_GetChilDepartmentIdByDepartmentId](@OrgID,@DepartmentID)", spOrgID, spDepartmentID).ToArray();
  224. var saDeptIdsByUser = db.Ado.SqlQuery<string>("SELECT DepartmentId FROM [dbo].[OFN_SYS_GetChilDepartmentIdByUserID](@OrgID,@UserID)", spOrgID, spUserID).ToArray();
  225. var saChildUserIds = db.Ado.SqlQuery<string>("SELECT MemberID FROM [dbo].[OFN_SYS_GetMemberIDDownByChief](@OrgID,@UserID)", spOrgID, spUserID).ToArray();
  226. pml.DataList = db.Queryable<OTB_OPM_ExportExhibition, OTB_SYS_Members, OTB_OPM_Exhibition, OTB_SYS_Arguments, OTB_CRM_Customers, OTB_CRM_Customers>
  227. ((t1, t2, t3, t4, t5, t6) =>
  228. new object[] {
  229. JoinType.Inner, t1.OrgID == t2.OrgID && t1.ResponsiblePerson == t2.MemberID,
  230. JoinType.Left, t1.OrgID == t3.OrgID && t1.ExhibitionNO == t3.SN.ToString(),
  231. JoinType.Left, t1.OrgID == t4.OrgID && t1.TransportationMode == t4.ArgumentID && t4.ArgumentClassID == "Transport",
  232. JoinType.Left, t1.OrgID == t5.OrgID && t1.Agent == t5.guid,
  233. JoinType.Left, t1.OrgID == t6.OrgID && t1.Organizer == t6.guid
  234. }
  235. )
  236. .Where((t1) => t1.OrgID == i_crm.ORIGID)
  237. .WhereIF(!string.IsNullOrEmpty(sRefNumber), (t1) => (t1.RefNumber + t1.Exhibitors).Contains(sRefNumber))
  238. .WhereIF(!string.IsNullOrEmpty(sExportBillName), (t1, t2, t3) => (t3.Exhibitioname_TW + t3.Exhibitioname_EN + t3.ExhibitioShotName_TW).Contains(sExportBillName))
  239. .WhereIF(!string.IsNullOrEmpty(sResponsiblePerson), (t1) => t1.ResponsiblePerson == sResponsiblePerson)
  240. .WhereIF(!string.IsNullOrEmpty(sAgent), (t1, t2, t3, t4, t5) => (t5.CustomerCName + t5.CustomerEName).Contains(sAgent))
  241. .WhereIF(!string.IsNullOrEmpty(sSupplier), (t1, t2, t3, t4, t5, t6) => (t6.CustomerCName + t6.CustomerEName).Contains(sSupplier))
  242. .WhereIF(!string.IsNullOrEmpty(sBillLadNO), (t1) => (t1.BillLadNO + t1.Exhibitors).Contains(sBillLadNO))
  243. .WhereIF(!string.IsNullOrEmpty(sFlow_Status), (t1) => t1.Flow_Status == sFlow_Status)
  244. .WhereIF(!string.IsNullOrEmpty(sBillNO), (t1) => (t1.Bills + t1.ReturnBills).Contains(sBillNO))
  245. .WhereIF(!string.IsNullOrEmpty(sREF), (t1) => t1.REF.Contains(sREF))
  246. .WhereIF(!string.IsNullOrEmpty(sDepartmentID), (t1) => SqlFunc.ContainsArray(saChildDeptIds, t1.DepartmentID))
  247. .WhereIF(!string.IsNullOrEmpty(sJobTracking), (t1) => SqlFunc.ContainsArray(saJobTracking, t1.Release))
  248. .WhereIF(!string.IsNullOrEmpty(sIsIncludeVoid), (t1) => SqlFunc.ContainsArray(saIsIncludeVoid, t1.IsVoid))
  249. .WhereIF(!string.IsNullOrEmpty(sExhibitionDateStart), (t1) => t1.ExhibitionDateStart >= rExhibitionDateStart.Date)
  250. .WhereIF(!string.IsNullOrEmpty(sExhibitionDateEnd), (t1) => t1.ExhibitionDateEnd <= rExhibitionDateEnd.Date)
  251. .Where((t1) => t1.CreateUser == i_crm.USERID || t1.ResponsiblePerson == i_crm.USERID || SqlFunc.ContainsArray(saDeptIdsByUser, t1.DepartmentID) ||
  252. SqlFunc.Subqueryable<OTB_SYS_Members>().Where(c => c.MemberID == t1.CreateUser && c.OrgID == t1.OrgID).Select(c => c.ImmediateSupervisor) == i_crm.USERID ||
  253. SqlFunc.Subqueryable<OTB_SYS_Members>().Where(p => p.MemberID == t1.ResponsiblePerson && p.OrgID == t1.OrgID).Select(c => c.ImmediateSupervisor) == i_crm.USERID || SqlFunc.ContainsArray(saChildUserIds, t1.CreateUser) || SqlFunc.ContainsArray(saChildUserIds, t1.ResponsiblePerson) || SqlFunc.ContainsArray(saRoles, "Account") || SqlFunc.ContainsArray(saRoles, "CDD") || SqlFunc.ContainsArray(saRoles, "Admin") || SqlFunc.ContainsArray(saRoles, "Manager"))
  254. .Select((t1, t2, t3, t4, t5, t6) => new View_OPM_ExportExhibition
  255. {
  256. OrgID = t1.OrgID,
  257. ExportBillNO = t1.ExportBillNO,
  258. ExhibitionNO = t1.ExhibitionNO,
  259. RefNumber = t1.RefNumber,
  260. ExportDeclarationNO = t1.ExportDeclarationNO,
  261. ImportBillNO = t1.ImportBillNO,
  262. ExportBillName = t3.Exhibitioname_TW,
  263. ExportBillEName = t3.Exhibitioname_EN,
  264. ExhibitioShotName_TW = t3.ExhibitioShotName_TW,
  265. ExhibitionDateStart = t1.ExhibitionDateStart,
  266. ExhibitionDateEnd = t1.ExhibitionDateEnd,
  267. CarriersNumber = t1.CarriersNumber,
  268. ResponsiblePerson = t1.ResponsiblePerson,
  269. BillLadNO = t1.BillLadNO,
  270. BillLadNOSub = t1.BillLadNOSub,
  271. ContainerNumber = t1.ContainerNumber,
  272. ShipmentPort = t1.ShipmentPort,
  273. Destination = t1.Destination,
  274. ShippingCompany = t1.ShippingCompany,
  275. Suppliers = t1.Suppliers,
  276. Release = t1.Release,
  277. Exhibitors = t1.Exhibitors,
  278. IsVoid = t1.IsVoid,
  279. Flow_Status = t1.Flow_Status,
  280. Bills = t1.Bills,
  281. ReturnBills = t1.ReturnBills,
  282. REF = t1.REF,
  283. DepartmentID = t1.DepartmentID,
  284. Memo = t1.Memo,
  285. IsAlert = SqlFunc.MappingColumn(t1.ImportBillNO, "[dbo].[OFN_OPM_CheckDate](t1.Release,t1.ExhibitionDateStart,5)"),
  286. ExhibitionDate = SqlFunc.MappingColumn(t1.ImportBillNO, "CONVERT(varchar(100),t1.ExhibitionDateStart, 111)+'~'+CONVERT(VARCHAR(100),t1.ExhibitionDateEnd, 111)"),
  287. OrganizerName = SqlFunc.IIF(SqlFunc.HasValue(t6.CustomerCName), t6.CustomerCName, t6.CustomerEName),
  288. AgentName = SqlFunc.IIF(SqlFunc.HasValue(t5.CustomerCName), t5.CustomerCName, t5.CustomerEName),
  289. ResponsiblePersonName = t2.MemberName,
  290. TransportationModeName = t4.ArgumentValue,
  291. _DocumentDeadline = SqlFunc.MappingColumn(t1.ImportBillNO, "CONVERT(VARCHAR(100),DocumentDeadline, 111)"),
  292. _ClosingDate = SqlFunc.MappingColumn(t1.ImportBillNO, "CONVERT(VARCHAR(100),ClosingDate, 111)"),
  293. _ETC = SqlFunc.MappingColumn(t1.ImportBillNO, "CONVERT(VARCHAR(100),ETC, 111)"),
  294. _ETD = SqlFunc.MappingColumn(t1.ImportBillNO, "CONVERT(VARCHAR(100),ETD, 111)"),
  295. _ETA = SqlFunc.MappingColumn(t1.ImportBillNO, "CONVERT(VARCHAR(100),ETA, 111)"),
  296. _ReminderAgentExecutionDate = SqlFunc.MappingColumn(t1.ImportBillNO, "CONVERT(VARCHAR(100),ReminderAgentExecutionDate, 111)"),
  297. _PreExhibitionDate = SqlFunc.MappingColumn(t1.ImportBillNO, "CONVERT(VARCHAR(100),PreExhibitionDate, 111)"),
  298. _ExitDate = SqlFunc.MappingColumn(t1.ImportBillNO, "CONVERT(VARCHAR(100),ExitDate, 111)"),
  299. })
  300. .MergeTable()
  301. .OrderByIF(string.IsNullOrEmpty(sSortField), "IsAlert desc,ExhibitionDateStart desc,ExportBillName,RefNumber desc")
  302. .OrderByIF(!string.IsNullOrEmpty(sSortField), sSortField + " " + sSortOrder)
  303. .ToPageList(pml.PageIndex, bExcel ? 100000 : pml.PageSize, ref iPageCount);
  304. pml.Total = iPageCount;
  305. rm = new SuccessResponseMessage(null, i_crm);
  306. if (bExcel)
  307. {
  308. var sFileName = "";
  309. var oHeader_Last = new object();
  310. var oHeader = new Dictionary<string, string>();
  311. var listMerge = new List<Dictionary<string, int>>();
  312. var dicAlain = new Dictionary<string, string>();
  313. var dt_new = new DataTable();
  314. var saCustomers1 = pml.DataList;
  315. var saBasicInformation = pml.DataList as List<View_OPM_ExportExhibition>;
  316. switch (sExcelType)
  317. {
  318. case "Export_BasicInformation":
  319. {
  320. dt_new = saBasicInformation.ListToDataTable<View_OPM_ExportExhibition>();
  321. sFileName = "出口基本資料";
  322. oHeader = new Dictionary<string, string>
  323. {
  324. { "RowIndex", "項次" },
  325. { "RefNumber", "查詢號碼" },
  326. { "ResponsiblePersonName", "負責業務" },
  327. { "ExportBillName", "展覽名稱" },
  328. { "ExportBillEName", "英文展名" },
  329. { "ExhibitionDate", "展覽日期起訖" },
  330. { "OrganizerName", "主辦單位" },
  331. { "AgentName", "國外代理" },
  332. { "CarriersNumber", "承運家數" },
  333. { "ShipmentPort", "起運地" },
  334. { "Destination", "目的地" },
  335. { "BillLadNO", "提單號碼" },
  336. { "BillLadNOSub", "分提單號碼" },
  337. { "ContainerNumber", "貨櫃號碼" },
  338. { "ExportDeclarationNO", "出口報單號碼" },
  339. { "TransportationModeName", "運送方式" },
  340. { "ShippingCompany", "船公司" },
  341. { "_DocumentDeadline", "文件截止日" },
  342. { "_ClosingDate", "收貨截止日" },
  343. { "_ETC", "ETC" },
  344. { "_ETD", "ETD" },
  345. { "_ETA", "ETA" },
  346. { "_ReminderAgentExecutionDate", "提醒代理執行日" },
  347. { "_PreExhibitionDate", "佈展日期" },
  348. { "_ExitDate", "退場日期" },
  349. { "Memo", "特別注意事項" }
  350. };
  351. dicAlain = ExcelService.GetExportAlain(oHeader, "RefNumber,_ClosingDate,_ClosingDate,_ETC,_ETD,_ETA,_ReminderAgentExecutionDate,_PreExhibitionDate,_ExitDate");
  352. oHeader_Last = oHeader;
  353. }
  354. break;
  355. case "Export_BusinessTrackingSchedule":
  356. {
  357. var Export_BusinessTrackingSchedule_List = new List<Dictionary<string, object>>();
  358. var Export_BusinessTrackingSchedule_Group = new Dictionary<string, object>();
  359. var dt = saBasicInformation.ListToDataTable<View_OPM_ExportExhibition>();
  360. sFileName = "業務追蹤進度表";
  361. oHeader = new Dictionary<string, string>
  362. {
  363. { "RowIndex", "項次" },
  364. { "RefNumber", "查詢號碼" },
  365. { "ResponsiblePersonName", "負責業務" },
  366. { "ExportBillName", "展覽名稱" },
  367. { "ExportBillEName", "英文展名" },
  368. { "ExhibitionDate", "展覽日期起訖" },
  369. { "OrganizerName", "主辦單位" },
  370. { "AgentName", "國外代理" },
  371. { "CarriersNumber", "承運家數" },
  372. { "ShipmentPort", "起運地" },
  373. { "Destination", "目的地" },
  374. { "BillLadNO", "提單號碼" },
  375. { "BillLadNOSub", "分提單號碼" },
  376. { "ContainerNumber", "貨櫃號碼" },
  377. { "ExportDeclarationNO", "出口報單號碼" },
  378. { "TransportationModeName", "運送方式" },
  379. { "ShippingCompany", "船公司" },
  380. { "DocumentDeadline", "文件截止日" },
  381. { "ClosingDate", "收貨截止日" },
  382. { "ETC", " ETC " },
  383. { "ETD", " ETD " },
  384. { "ETA", " ETA " },
  385. { "ReminderAgentExecutionDate", "提醒代理執行日" },
  386. { "PreExhibitionDate", "佈展日期" },
  387. { "ExitDate", "退場日期" },
  388. { "Memo", "特別注意事項" }
  389. };
  390. dicAlain = ExcelService.GetExportAlain(oHeader, new string[] { "Email", "Contactor", "ContactorEmail" });
  391. Export_BusinessTrackingSchedule_Group.Add("Header", oHeader);
  392. Export_BusinessTrackingSchedule_Group.Add("HeaderName", "基本資料");
  393. Export_BusinessTrackingSchedule_Group.Add("Color", Color.Chocolate);
  394. Export_BusinessTrackingSchedule_List.Add(Export_BusinessTrackingSchedule_Group);
  395. oHeader = new Dictionary<string, string>();
  396. Export_BusinessTrackingSchedule_Group = new Dictionary<string, object>();
  397. oHeader.Add("Exhibitors_CustomerCode", "廠商代碼");
  398. oHeader.Add("Exhibitors_SupplierName", "廠商名稱");
  399. oHeader.Add("Exhibitors_RefSupplierNo", "廠商查詢號碼");
  400. oHeader.Add("Exhibitors_ExportBillNO", "帳單號碼");
  401. Export_BusinessTrackingSchedule_Group.Add("Header", oHeader);
  402. Export_BusinessTrackingSchedule_Group.Add("HeaderName", "參展商資料");
  403. Export_BusinessTrackingSchedule_Group.Add("Color", Color.Aqua);
  404. Export_BusinessTrackingSchedule_List.Add(Export_BusinessTrackingSchedule_Group);
  405. oHeader = new Dictionary<string, string>();
  406. Export_BusinessTrackingSchedule_Group = new Dictionary<string, object>();
  407. oHeader.Add("ExportData_Intowarehouse_Date", "貨物進倉");
  408. oHeader.Add("ExportData_Intowarehouse_Number", "到貨件數");
  409. oHeader.Add("ExportData_CustomsDeclaration_Date", "報關作業");
  410. oHeader.Add("ExportData_ExportRelease_Date", "出口放行");
  411. Export_BusinessTrackingSchedule_Group.Add("Header", oHeader);
  412. Export_BusinessTrackingSchedule_Group.Add("HeaderName", "貨物出口");
  413. Export_BusinessTrackingSchedule_Group.Add("Color", Color.HotPink);
  414. Export_BusinessTrackingSchedule_List.Add(Export_BusinessTrackingSchedule_Group);
  415. oHeader = new Dictionary<string, string>();
  416. Export_BusinessTrackingSchedule_Group = new Dictionary<string, object>();
  417. oHeader.Add("ClearanceData_GoodsArrival_Date", "貨物抵達");
  418. oHeader.Add("ClearanceData_CargoRelease_Date", "貨物放行");
  419. oHeader.Add("ClearanceData_WaitingApproach_Date", "等待進場");
  420. oHeader.Add("ClearanceData_ServiceBooth_Date", "送達攤位");
  421. Export_BusinessTrackingSchedule_Group.Add("Header", oHeader);
  422. Export_BusinessTrackingSchedule_Group.Add("HeaderName", "目的地清關作業");
  423. Export_BusinessTrackingSchedule_Group.Add("Color", Color.Yellow);
  424. Export_BusinessTrackingSchedule_List.Add(Export_BusinessTrackingSchedule_Group);
  425. oHeader = new Dictionary<string, string>();
  426. Export_BusinessTrackingSchedule_Group = new Dictionary<string, object>();
  427. dt_new = new DataTable();
  428. foreach (DataColumn col in dt.Columns)
  429. {
  430. dt_new.Columns.Add(col.ToString());
  431. }
  432. dt_new.Columns.Add("Exhibitors_CustomerCode");
  433. dt_new.Columns.Add("Exhibitors_SupplierName");
  434. dt_new.Columns.Add("Exhibitors_RefSupplierNo");
  435. dt_new.Columns.Add("Exhibitors_ExportBillNO");
  436. dt_new.Columns.Add("ExportData_Intowarehouse_Date");
  437. dt_new.Columns.Add("ExportData_Intowarehouse_Number");
  438. dt_new.Columns.Add("ExportData_CustomsDeclaration_Date");
  439. dt_new.Columns.Add("ExportData_ExportRelease_Date");
  440. dt_new.Columns.Add("ClearanceData_GoodsArrival_Date");
  441. dt_new.Columns.Add("ClearanceData_CargoRelease_Date");
  442. dt_new.Columns.Add("ClearanceData_WaitingApproach_Date");
  443. dt_new.Columns.Add("ClearanceData_ServiceBooth_Date");
  444. //添加Header
  445. var dicHeaderKeys = new Dictionary<string, int>();
  446. foreach (DataRow row in dt.Rows)
  447. {
  448. var JExhibitors = (JArray)JsonConvert.DeserializeObject(row["Exhibitors"].ToString());
  449. if (JExhibitors.Count > 0)
  450. {
  451. //廠商資料
  452. foreach (JObject Exhibitor in JExhibitors)
  453. {
  454. if (!dicHeaderKeys.Keys.Contains("ReImport") && Exhibitor["ReImport"] != null)
  455. {
  456. oHeader.Add("ReImport_CargoCollection_Date", "貨物收取");
  457. oHeader.Add("ReImport_Number", "退運件數");
  458. oHeader.Add("ReImport_Unit", "單位");
  459. oHeader.Add("ReImport_FileValidation_Date", "文件確認");
  460. oHeader.Add("ReImport_TransportationMode", "運送方式");
  461. oHeader.Add("ReImport_GoodsType", "貨型");
  462. oHeader.Add("ReImport_HuiYun_Date", "回運中");
  463. oHeader.Add("ReImport_GoodsArrival_Date", "貨物抵達");
  464. oHeader.Add("ReImport_CustomsDeclaration_Date", "報關作業");
  465. oHeader.Add("ReImport_CargoRelease_Date", "貨物放行");
  466. oHeader.Add("ReImport_Sign_Date", "客戶簽收");
  467. Export_BusinessTrackingSchedule_Group.Add("Header", oHeader);
  468. Export_BusinessTrackingSchedule_Group.Add("HeaderName", "展貨退運");
  469. Export_BusinessTrackingSchedule_Group.Add("Color", Color.LightSalmon);
  470. Export_BusinessTrackingSchedule_List.Add(Export_BusinessTrackingSchedule_Group);
  471. oHeader = new Dictionary<string, string>();
  472. Export_BusinessTrackingSchedule_Group = new Dictionary<string, object>();
  473. dt_new.Columns.Add("ReImport_CargoCollection_Date");
  474. dt_new.Columns.Add("ReImport_Number");
  475. dt_new.Columns.Add("ReImport_Unit");
  476. dt_new.Columns.Add("ReImport_FileValidation_Date");
  477. dt_new.Columns.Add("ReImport_TransportationMode");
  478. dt_new.Columns.Add("ReImport_GoodsType");
  479. dt_new.Columns.Add("ReImport_HuiYun_Date");
  480. dt_new.Columns.Add("ReImport_GoodsArrival_Date");
  481. dt_new.Columns.Add("ReImport_CustomsDeclaration_Date");
  482. dt_new.Columns.Add("ReImport_CargoRelease_Date");
  483. dt_new.Columns.Add("ReImport_Sign_Date");
  484. dicHeaderKeys.Add("ReImport", dicHeaderKeys.Keys.Count + 1);
  485. }
  486. if (!dicHeaderKeys.Keys.Contains("TranserThird") && Exhibitor["TranserThird"] != null)
  487. {
  488. oHeader.Add("TranserThird_CargoCollection_Date", "貨物收取");
  489. oHeader.Add("TranserThird_Number", "件數");
  490. oHeader.Add("TranserThird_Unit", "單位");
  491. oHeader.Add("TranserThird_FileValidation_Date", "文件確認");
  492. oHeader.Add("TranserThird_TransportationMode", "運送方式");
  493. oHeader.Add("TranserThird_GoodsType", "貨型");
  494. oHeader.Add("TranserThird_Destination", "目的地");
  495. oHeader.Add("TranserThird_InTransit_Date", "回運中");
  496. oHeader.Add("TranserThird_GoodsArrival_Date", "貨物抵達");
  497. oHeader.Add("TranserThird_CargoRelease_Date", "貨物放行");
  498. oHeader.Add("TranserThird_ServiceBooth_Date", "送達攤位");
  499. Export_BusinessTrackingSchedule_Group.Add("Header", oHeader);
  500. Export_BusinessTrackingSchedule_Group.Add("HeaderName", "轉運其他地區");
  501. Export_BusinessTrackingSchedule_Group.Add("Color", Color.Bisque);
  502. Export_BusinessTrackingSchedule_List.Add(Export_BusinessTrackingSchedule_Group);
  503. oHeader = new Dictionary<string, string>();
  504. Export_BusinessTrackingSchedule_Group = new Dictionary<string, object>();
  505. dt_new.Columns.Add("TranserThird_CargoCollection_Date");
  506. dt_new.Columns.Add("TranserThird_Number");
  507. dt_new.Columns.Add("TranserThird_Unit");
  508. dt_new.Columns.Add("TranserThird_FileValidation_Date");
  509. dt_new.Columns.Add("TranserThird_TransportationMode");
  510. dt_new.Columns.Add("TranserThird_GoodsType");
  511. dt_new.Columns.Add("TranserThird_Destination");
  512. dt_new.Columns.Add("TranserThird_InTransit_Date");
  513. dt_new.Columns.Add("TranserThird_GoodsArrival_Date");
  514. dt_new.Columns.Add("TranserThird_CargoRelease_Date");
  515. dt_new.Columns.Add("TranserThird_ServiceBooth_Date");
  516. dicHeaderKeys.Add("TranserThird", dicHeaderKeys.Keys.Count + 1);
  517. }
  518. if (!dicHeaderKeys.Keys.Contains("PartThird") && Exhibitor["PartThird"] != null)
  519. {
  520. oHeader.Add("PartThird_CargoCollection_Date", "貨物收取");
  521. oHeader.Add("PartThird_Number", "件數");
  522. oHeader.Add("PartThird_Unit", "單位");
  523. oHeader.Add("PartThird_FileValidation_Date", "文件確認");
  524. oHeader.Add("PartThird_TransportationMode", "運送方式");
  525. oHeader.Add("PartThird_GoodsType", "貨型");
  526. oHeader.Add("PartThird_Destination", "目的地");
  527. oHeader.Add("PartThird_InTransit_Date", "回運中");
  528. oHeader.Add("PartThird_GoodsArrival_Date", "貨物抵達");
  529. oHeader.Add("PartThird_CargoRelease_Date", "貨物放行");
  530. oHeader.Add("PartThird_Sign_Date", "客戶簽收");
  531. Export_BusinessTrackingSchedule_Group.Add("Header", oHeader);
  532. Export_BusinessTrackingSchedule_Group.Add("HeaderName", "轉運其他地區(部份轉運其他地區;部份退運回台)");
  533. Export_BusinessTrackingSchedule_Group.Add("Color", Color.LightCoral);
  534. Export_BusinessTrackingSchedule_List.Add(Export_BusinessTrackingSchedule_Group);
  535. oHeader = new Dictionary<string, string>();
  536. Export_BusinessTrackingSchedule_Group = new Dictionary<string, object>();
  537. dt_new.Columns.Add("PartThird_CargoCollection_Date");
  538. dt_new.Columns.Add("PartThird_Number");
  539. dt_new.Columns.Add("PartThird_Unit");
  540. dt_new.Columns.Add("PartThird_FileValidation_Date");
  541. dt_new.Columns.Add("PartThird_TransportationMode");
  542. dt_new.Columns.Add("PartThird_GoodsType");
  543. dt_new.Columns.Add("PartThird_Destination");
  544. dt_new.Columns.Add("PartThird_InTransit_Date");
  545. dt_new.Columns.Add("PartThird_GoodsArrival_Date");
  546. dt_new.Columns.Add("PartThird_CargoRelease_Date");
  547. dt_new.Columns.Add("PartThird_Sign_Date");
  548. dicHeaderKeys.Add("PartThird", dicHeaderKeys.Keys.Count + 1);
  549. }
  550. if (!dicHeaderKeys.Keys.Contains("PartReImport") && Exhibitor["PartReImport"] != null)
  551. {
  552. oHeader.Add("PartReImport_CargoCollection_Date", "貨物收取");
  553. oHeader.Add("PartReImport_Number", "退運件數");
  554. oHeader.Add("PartReImport_Unit", "單位");
  555. oHeader.Add("PartReImport_FileValidation_Date", "文件確認");
  556. oHeader.Add("PartReImport_GoodsType", "貨型");
  557. oHeader.Add("PartReImport_HuiYun_Date", "回運中");
  558. oHeader.Add("PartReImport_GoodsArrival_Date", "貨物抵達");
  559. oHeader.Add("PartReImport_CustomsDeclaration_Date", "報關作業");
  560. oHeader.Add("PartReImport_CargoRelease_Date", "貨物放行");
  561. oHeader.Add("PartReImport_Sign_Date", "客戶簽收");
  562. Export_BusinessTrackingSchedule_Group.Add("Header", oHeader);
  563. Export_BusinessTrackingSchedule_Group.Add("HeaderName", "展後回運(部份轉運其他地區;部份退運回台)");
  564. Export_BusinessTrackingSchedule_Group.Add("Color", Color.LightSalmon);
  565. Export_BusinessTrackingSchedule_List.Add(Export_BusinessTrackingSchedule_Group);
  566. oHeader = new Dictionary<string, string>();
  567. Export_BusinessTrackingSchedule_Group = new Dictionary<string, object>();
  568. dt_new.Columns.Add("PartReImport_CargoCollection_Date");
  569. dt_new.Columns.Add("PartReImport_Number");
  570. dt_new.Columns.Add("PartReImport_Unit");
  571. dt_new.Columns.Add("PartReImport_FileValidation_Date");
  572. dt_new.Columns.Add("PartReImport_GoodsType");
  573. dt_new.Columns.Add("PartReImport_HuiYun_Date");
  574. dt_new.Columns.Add("PartReImport_GoodsArrival_Date");
  575. dt_new.Columns.Add("PartReImport_CustomsDeclaration_Date");
  576. dt_new.Columns.Add("PartReImport_CargoRelease_Date");
  577. dt_new.Columns.Add("PartReImport_Sign_Date");
  578. dicHeaderKeys.Add("PartReImport", dicHeaderKeys.Keys.Count + 1);
  579. }
  580. if (!dicHeaderKeys.Keys.Contains("ReImportFour") && Exhibitor["ReImportFour"] != null)
  581. {
  582. oHeader.Add("ReImportFour_CargoCollection_Date", "貨物收取");
  583. oHeader.Add("ReImportFour_Number", "退運件數");
  584. oHeader.Add("ReImportFour_Unit", "單位");
  585. oHeader.Add("ReImportFour_FileValidation_Date", "文件確認");
  586. oHeader.Add("ReImportFour_TransportationMode", "運送方式");
  587. oHeader.Add("ReImportFour_GoodsType", "貨型");
  588. oHeader.Add("ReImportFour_HuiYun_Date", "回運中");
  589. oHeader.Add("ReImportFour_GoodsArrival_Date", "貨物抵達");
  590. oHeader.Add("ReImportFour_CustomsDeclaration_Date", "報關作業");
  591. oHeader.Add("ReImportFour_CargoRelease_Date", "貨物放行");
  592. oHeader.Add("ReImportFour_Sign_Date", "客戶簽收");
  593. Export_BusinessTrackingSchedule_Group.Add("Header", oHeader);
  594. Export_BusinessTrackingSchedule_Group.Add("HeaderName", "展後回運(出貨至第第三地後)");
  595. Export_BusinessTrackingSchedule_Group.Add("Color", Color.LightSalmon);
  596. Export_BusinessTrackingSchedule_List.Add(Export_BusinessTrackingSchedule_Group);
  597. oHeader = new Dictionary<string, string>();
  598. Export_BusinessTrackingSchedule_Group = new Dictionary<string, object>();
  599. dt_new.Columns.Add("ReImportFour_CargoCollection_Date");
  600. dt_new.Columns.Add("ReImportFour_Number");
  601. dt_new.Columns.Add("ReImportFour_Unit");
  602. dt_new.Columns.Add("ReImportFour_FileValidation_Date");
  603. dt_new.Columns.Add("ReImportFour_TransportationMode");
  604. dt_new.Columns.Add("ReImportFour_GoodsType");
  605. dt_new.Columns.Add("ReImportFour_HuiYun_Date");
  606. dt_new.Columns.Add("ReImportFour_GoodsArrival_Date");
  607. dt_new.Columns.Add("ReImportFour_CustomsDeclaration_Date");
  608. dt_new.Columns.Add("ReImportFour_CargoRelease_Date");
  609. dt_new.Columns.Add("ReImportFour_Sign_Date");
  610. dicHeaderKeys.Add("ReImportFour", dicHeaderKeys.Keys.Count + 1);
  611. }
  612. if (!dicHeaderKeys.Keys.Contains("TransferFour") && Exhibitor["TransferFour"] != null)
  613. {
  614. oHeader.Add("TransferFour_CargoCollection_Date", "貨物收取");
  615. oHeader.Add("TransferFour_Number", "件數");
  616. oHeader.Add("TransferFour_Unit", "單位");
  617. oHeader.Add("TransferFour_FileValidation_Date", "文件確認");
  618. oHeader.Add("TransferFour_TransportationMode", "運送方式");
  619. oHeader.Add("TransferFour_GoodsType", "貨型");
  620. oHeader.Add("TransferFour_Destination", "目的地");
  621. oHeader.Add("TransferFour_InTransit_Date", "回運中");
  622. oHeader.Add("TransferFour_GoodsArrival_Date", "貨物抵達");
  623. oHeader.Add("TransferFour_CargoRelease_Date", "貨物放行");
  624. oHeader.Add("TransferFour_Sign_Date", "客戶簽收");
  625. Export_BusinessTrackingSchedule_Group.Add("Header", oHeader);
  626. Export_BusinessTrackingSchedule_Group.Add("HeaderName", "出貨至第四地");
  627. Export_BusinessTrackingSchedule_Group.Add("Color", Color.PaleGreen);
  628. Export_BusinessTrackingSchedule_List.Add(Export_BusinessTrackingSchedule_Group);
  629. oHeader = new Dictionary<string, string>();
  630. Export_BusinessTrackingSchedule_Group = new Dictionary<string, object>();
  631. dt_new.Columns.Add("TransferFour_CargoCollection_Date");
  632. dt_new.Columns.Add("TransferFour_Number");
  633. dt_new.Columns.Add("TransferFour_Unit");
  634. dt_new.Columns.Add("TransferFour_FileValidation_Date");
  635. dt_new.Columns.Add("TransferFour_TransportationMode");
  636. dt_new.Columns.Add("TransferFour_GoodsType");
  637. dt_new.Columns.Add("TransferFour_Destination");
  638. dt_new.Columns.Add("TransferFour_InTransit_Date");
  639. dt_new.Columns.Add("TransferFour_GoodsArrival_Date");
  640. dt_new.Columns.Add("TransferFour_CargoRelease_Date");
  641. dt_new.Columns.Add("TransferFour_Sign_Date");
  642. dicHeaderKeys.Add("TransferFour", dicHeaderKeys.Keys.Count + 1);
  643. }
  644. if (!dicHeaderKeys.Keys.Contains("ReImportFive") && Exhibitor["ReImportFive"] != null)
  645. {
  646. oHeader.Add("ReImportFive_CargoCollection_Date", "貨物收取");
  647. oHeader.Add("ReImportFive_Number", "退運件數");
  648. oHeader.Add("ReImportFive_Unit", "單位");
  649. oHeader.Add("ReImportFive_FileValidation_Date", "文件確認");
  650. oHeader.Add("ReImportFive_TransportationMode", "運送方式");
  651. oHeader.Add("ReImportFive_GoodsType", "貨型");
  652. oHeader.Add("ReImportFive_HuiYun_Date", "回運中");
  653. oHeader.Add("ReImportFive_GoodsArrival_Date", "貨物抵達");
  654. oHeader.Add("ReImportFive_CustomsDeclaration_Date", "報關作業");
  655. oHeader.Add("ReImportFive_CargoRelease_Date", "貨物放行");
  656. oHeader.Add("ReImportFive_Sign_Date", "客戶簽收");
  657. Export_BusinessTrackingSchedule_Group.Add("Header", oHeader);
  658. Export_BusinessTrackingSchedule_Group.Add("HeaderName", "展後回運(出貨至第四地後)");
  659. Export_BusinessTrackingSchedule_Group.Add("Color", Color.CornflowerBlue);
  660. Export_BusinessTrackingSchedule_List.Add(Export_BusinessTrackingSchedule_Group);
  661. oHeader = new Dictionary<string, string>();
  662. Export_BusinessTrackingSchedule_Group = new Dictionary<string, object>();
  663. dt_new.Columns.Add("ReImportFive_CargoCollection_Date");
  664. dt_new.Columns.Add("ReImportFive_Number");
  665. dt_new.Columns.Add("ReImportFive_Unit");
  666. dt_new.Columns.Add("ReImportFive_FileValidation_Date");
  667. dt_new.Columns.Add("ReImportFive_TransportationMode");
  668. dt_new.Columns.Add("ReImportFive_GoodsType");
  669. dt_new.Columns.Add("ReImportFive_HuiYun_Date");
  670. dt_new.Columns.Add("ReImportFive_GoodsArrival_Date");
  671. dt_new.Columns.Add("ReImportFive_CustomsDeclaration_Date");
  672. dt_new.Columns.Add("ReImportFive_CargoRelease_Date");
  673. dt_new.Columns.Add("ReImportFive_Sign_Date");
  674. dicHeaderKeys.Add("ReImportFive", dicHeaderKeys.Keys.Count + 1);
  675. }
  676. if (!dicHeaderKeys.Keys.Contains("TransferFive") && Exhibitor["TransferFive"] != null)
  677. {
  678. oHeader.Add("TransferFive_CargoCollection_Date", "貨物收取");
  679. oHeader.Add("TransferFive_Number", "件數");
  680. oHeader.Add("TransferFive_Unit", "單位");
  681. oHeader.Add("TransferFive_FileValidation_Date", "文件確認");
  682. oHeader.Add("TransferFive_TransportationMode", "運送方式");
  683. oHeader.Add("TransferFive_GoodsType", "貨型");
  684. oHeader.Add("TransferFive_Destination", "目的地");
  685. oHeader.Add("TransferFive_InTransit_Date", "回運中");
  686. oHeader.Add("TransferFive_GoodsArrival_Date", "貨物抵達");
  687. oHeader.Add("TransferFive_CargoRelease_Date", "貨物放行");
  688. oHeader.Add("TransferFive_Sign_Date", "客戶簽收");
  689. Export_BusinessTrackingSchedule_Group.Add("Header", oHeader);
  690. Export_BusinessTrackingSchedule_Group.Add("HeaderName", "出貨至第五地");
  691. Export_BusinessTrackingSchedule_Group.Add("Color", Color.ForestGreen);
  692. Export_BusinessTrackingSchedule_List.Add(Export_BusinessTrackingSchedule_Group);
  693. oHeader = new Dictionary<string, string>();
  694. Export_BusinessTrackingSchedule_Group = new Dictionary<string, object>();
  695. dt_new.Columns.Add("TransferFive_CargoCollection_Date");
  696. dt_new.Columns.Add("TransferFive_Number");
  697. dt_new.Columns.Add("TransferFive_Unit");
  698. dt_new.Columns.Add("TransferFive_FileValidation_Date");
  699. dt_new.Columns.Add("TransferFive_TransportationMode");
  700. dt_new.Columns.Add("TransferFive_GoodsType");
  701. dt_new.Columns.Add("TransferFive_Destination");
  702. dt_new.Columns.Add("TransferFive_InTransit_Date");
  703. dt_new.Columns.Add("TransferFive_GoodsArrival_Date");
  704. dt_new.Columns.Add("TransferFive_CargoRelease_Date");
  705. dt_new.Columns.Add("TransferFive_Sign_Date");
  706. dicHeaderKeys.Add("TransferFive", dicHeaderKeys.Keys.Count + 1);
  707. }
  708. if (!dicHeaderKeys.Keys.Contains("ReImportSix") && Exhibitor["ReImportSix"] != null)
  709. {
  710. oHeader.Add("ReImportSix_CargoCollection_Date", "貨物收取");
  711. oHeader.Add("ReImportSix_Number", "退運件數");
  712. oHeader.Add("ReImportSix_Unit", "單位");
  713. oHeader.Add("ReImportSix_FileValidation_Date", "文件確認");
  714. oHeader.Add("ReImportSix_TransportationMode", "運送方式");
  715. oHeader.Add("ReImportSix_GoodsType", "貨型");
  716. oHeader.Add("ReImportSix_HuiYun_Date", "回運中");
  717. oHeader.Add("ReImportSix_GoodsArrival_Date", "貨物抵達");
  718. oHeader.Add("ReImportSix_CustomsDeclaration_Date", "報關作業");
  719. oHeader.Add("ReImportSix_CustomsDeclaration_CustomsClearance", "通關方式");
  720. oHeader.Add("ReImportSix_CargoRelease_Date", "貨物放行");
  721. oHeader.Add("ReImportSix_Sign_Date", "客戶簽收");
  722. Export_BusinessTrackingSchedule_Group.Add("Header", oHeader);
  723. Export_BusinessTrackingSchedule_Group.Add("HeaderName", "展後回運(出貨至第五地後)");
  724. Export_BusinessTrackingSchedule_Group.Add("Color", Color.DimGray);
  725. Export_BusinessTrackingSchedule_List.Add(Export_BusinessTrackingSchedule_Group);
  726. oHeader = new Dictionary<string, string>();
  727. Export_BusinessTrackingSchedule_Group = new Dictionary<string, object>();
  728. dt_new.Columns.Add("ReImportSix_CargoCollection_Date");
  729. dt_new.Columns.Add("ReImportSix_Number");
  730. dt_new.Columns.Add("ReImportSix_Unit");
  731. dt_new.Columns.Add("ReImportSix_FileValidation_Date");
  732. dt_new.Columns.Add("ReImportSix_TransportationMode");
  733. dt_new.Columns.Add("ReImportSix_GoodsType");
  734. dt_new.Columns.Add("ReImportSix_HuiYun_Date");
  735. dt_new.Columns.Add("ReImportSix_GoodsArrival_Date");
  736. dt_new.Columns.Add("ReImportSix_CustomsDeclaration_Date");
  737. dt_new.Columns.Add("ReImportSix_CustomsDeclaration_CustomsClearance");
  738. dt_new.Columns.Add("ReImportSix_CargoRelease_Date");
  739. dt_new.Columns.Add("ReImportSix_Sign_Date");
  740. dicHeaderKeys.Add("ReImportSix", dicHeaderKeys.Keys.Count + 1);
  741. }
  742. if (!dicHeaderKeys.Keys.Contains("TransferSix") && Exhibitor["TransferSix"] != null)
  743. {
  744. oHeader.Add("TransferSix_CargoCollection_Date", "貨物收取");
  745. oHeader.Add("TransferSix_Number", "件數");
  746. oHeader.Add("TransferSix_Unit", "單位");
  747. oHeader.Add("TransferSix_FileValidation_Date", "文件確認");
  748. oHeader.Add("TransferSix_TransportationMode", "運送方式");
  749. oHeader.Add("TransferSix_GoodsType", "貨型");
  750. oHeader.Add("TransferSix_Destination", "目的地");
  751. oHeader.Add("TransferSix_InTransit_Date", "回運中");
  752. oHeader.Add("TransferSix_GoodsArrival_Date", "貨物抵達");
  753. oHeader.Add("TransferSix_CargoRelease_Date", "貨物放行");
  754. oHeader.Add("TransferSix_Sign_Date", "客戶簽收");
  755. Export_BusinessTrackingSchedule_Group.Add("Header", oHeader);
  756. Export_BusinessTrackingSchedule_Group.Add("HeaderName", "出貨至第六地");
  757. Export_BusinessTrackingSchedule_Group.Add("Color", Color.SlateGray);
  758. Export_BusinessTrackingSchedule_List.Add(Export_BusinessTrackingSchedule_Group);
  759. oHeader = new Dictionary<string, string>();
  760. Export_BusinessTrackingSchedule_Group = new Dictionary<string, object>();
  761. dt_new.Columns.Add("TransferSix_CargoCollection_Date");
  762. dt_new.Columns.Add("TransferSix_Number");
  763. dt_new.Columns.Add("TransferSix_Unit");
  764. dt_new.Columns.Add("TransferSix_FileValidation_Date");
  765. dt_new.Columns.Add("TransferSix_TransportationMode");
  766. dt_new.Columns.Add("TransferSix_GoodsType");
  767. dt_new.Columns.Add("TransferSix_Destination");
  768. dt_new.Columns.Add("TransferSix_InTransit_Date");
  769. dt_new.Columns.Add("TransferSix_GoodsArrival_Date");
  770. dt_new.Columns.Add("TransferSix_CargoRelease_Date");
  771. dt_new.Columns.Add("TransferSix_Sign_Date");
  772. dicHeaderKeys.Add("TransferSix", dicHeaderKeys.Keys.Count + 1);
  773. }
  774. }
  775. }
  776. }
  777. var iFirstRow = 4;
  778. foreach (DataRow row in dt.Rows)
  779. {
  780. var row_new = dt_new.NewRow();//
  781. var JExhibitors = (JArray)JsonConvert.DeserializeObject(row["Exhibitors"].ToString());
  782. if (JExhibitors.Count > 0)
  783. {
  784. //合併基本資料
  785. var iMergeColCount = ((Dictionary<string, string>)Export_BusinessTrackingSchedule_List[0]["Header"]).Keys.Count;
  786. for (var iFirstCol = 0; iFirstCol < iMergeColCount; iFirstCol++)
  787. {
  788. var dicMerge = new Dictionary<string, int>
  789. {
  790. { "FirstRow", iFirstRow },
  791. { "FirstCol", iFirstCol },
  792. { "RowCount", JExhibitors.Count },
  793. { "ColCount", 1 }
  794. };
  795. listMerge.Add(dicMerge);
  796. }
  797. //廠商資料
  798. foreach (JObject Exhibitor in JExhibitors)
  799. {
  800. row_new = dt_new.NewRow();
  801. foreach (DataColumn col in dt.Columns)
  802. {
  803. row_new[col.ToString()] = row[col.ToString()];
  804. }
  805. var jExportData = (JObject)Exhibitor["ExportData"];
  806. var jClearanceData = (JObject)Exhibitor["ClearanceData"];
  807. var jReImport = (JObject)Exhibitor["ReImport"];
  808. var jTranserThird = (JObject)Exhibitor["TranserThird"];
  809. var jPartThird = (JObject)Exhibitor["PartThird"];
  810. var jPartReImport = (JObject)Exhibitor["PartReImport"];
  811. var jReImportFour = (JObject)Exhibitor["ReImportFour"];
  812. var jTransferFour = (JObject)Exhibitor["TransferFour"];
  813. var jReImportFive = (JObject)Exhibitor["ReImportFive"];
  814. var jTransferFive = (JObject)Exhibitor["TransferFive"];
  815. var jReImportSix = (JObject)Exhibitor["ReImportSix"];
  816. var jTransferSix = (JObject)Exhibitor["TransferSix"];
  817. row_new["Exhibitors_CustomerCode"] = Exhibitor["CustomerCode"];
  818. row_new["Exhibitors_SupplierName"] = Exhibitor["SupplierName"];
  819. row_new["Exhibitors_RefSupplierNo"] = Exhibitor["RefSupplierNo"];
  820. row_new["Exhibitors_ExportBillNO"] = Exhibitor["BillNO"] ?? "";
  821. if (jExportData != null)
  822. {
  823. row_new["ExportData_Intowarehouse_Date"] = ((JObject)jExportData["Intowarehouse"])["Date"];
  824. row_new["ExportData_Intowarehouse_Number"] = ((JObject)jExportData["Intowarehouse"])["Number"];
  825. row_new["ExportData_CustomsDeclaration_Date"] = ((JObject)jExportData["CustomsDeclaration"])["Date"];
  826. row_new["ExportData_ExportRelease_Date"] = ((JObject)jExportData["ExportRelease"])["Date"];
  827. }
  828. if (jClearanceData != null)
  829. {
  830. row_new["ClearanceData_GoodsArrival_Date"] = ((JObject)jClearanceData["GoodsArrival"])["Date"];
  831. row_new["ClearanceData_CargoRelease_Date"] = ((JObject)jClearanceData["CargoRelease"])["Date"];
  832. row_new["ClearanceData_WaitingApproach_Date"] = jClearanceData["WaitingApproach"] == null ? "" : ((JObject)jClearanceData["WaitingApproach"])["Date"];
  833. row_new["ClearanceData_ServiceBooth_Date"] = ((JObject)jClearanceData["ServiceBooth"])["Date"];
  834. }
  835. if (jReImport != null)
  836. {
  837. row_new["ReImport_CargoCollection_Date"] = ((JObject)jReImport["CargoCollection"])["Date"];
  838. row_new["ReImport_Number"] = jReImport["Number"];
  839. row_new["ReImport_Unit"] = jReImport["Unit"];
  840. row_new["ReImport_FileValidation_Date"] = ((JObject)jReImport["FileValidation"])["Date"];
  841. var sTransportationMode = jReImport["TransportationMode"] == null ? "" : jReImport["TransportationMode"].ToString();
  842. if (sTransportationMode != "")
  843. {
  844. var oArgument = db.Queryable<OTB_SYS_Arguments>()
  845. .Single(it => it.OrgID == i_crm.ORIGID && it.ArgumentClassID == "Transport" && it.ArgumentID == sTransportationMode);
  846. if (oArgument == null)
  847. {
  848. oArgument = new OTB_SYS_Arguments();
  849. }
  850. row_new["ReImport_TransportationMode"] = oArgument.ArgumentValue ?? "";
  851. }
  852. row_new["ReImport_GoodsType"] = jReImport["GoodsType"];
  853. row_new["ReImport_HuiYun_Date"] = ((JObject)jReImport["HuiYun"])["Date"];
  854. row_new["ReImport_GoodsArrival_Date"] = ((JObject)jReImport["GoodsArrival"])["Date"];
  855. row_new["ReImport_CustomsDeclaration_Date"] = ((JObject)jReImport["CustomsDeclaration"])["Date"];
  856. row_new["ReImport_CargoRelease_Date"] = ((JObject)jReImport["CargoRelease"])["Date"];
  857. row_new["ReImport_Sign_Date"] = ((JObject)jReImport["Sign"])["Date"];
  858. }
  859. if (jTranserThird != null)
  860. {
  861. row_new["TranserThird_CargoCollection_Date"] = ((JObject)jTranserThird["CargoCollection"])["Date"];
  862. row_new["TranserThird_Number"] = jTranserThird["Number"];
  863. row_new["TranserThird_Unit"] = jTranserThird["Number"];
  864. row_new["TranserThird_FileValidation_Date"] = ((JObject)jTranserThird["FileValidation"])["Date"];
  865. var sTransportationMode = jTranserThird["TransportationMode"] == null ? "" : jTranserThird["TransportationMode"].ToString();
  866. if (sTransportationMode != "")
  867. {
  868. var oArgument = db.Queryable<OTB_SYS_Arguments>()
  869. .Single(it => it.OrgID == i_crm.ORIGID && it.ArgumentClassID == "Transport" && it.ArgumentID == sTransportationMode);
  870. if (oArgument == null)
  871. {
  872. oArgument = new OTB_SYS_Arguments();
  873. }
  874. row_new["TranserThird_TransportationMode"] = oArgument.ArgumentValue ?? "";
  875. }
  876. row_new["TranserThird_GoodsType"] = jTranserThird["GoodsType"];
  877. row_new["TranserThird_Destination"] = jTranserThird["Destination"];
  878. row_new["TranserThird_InTransit_Date"] = ((JObject)jTranserThird["InTransit"])["Date"];
  879. row_new["TranserThird_GoodsArrival_Date"] = ((JObject)jTranserThird["GoodsArrival"])["Date"];
  880. row_new["TranserThird_CargoRelease_Date"] = ((JObject)jTranserThird["CargoRelease"])["Date"];
  881. row_new["TranserThird_ServiceBooth_Date"] = ((JObject)jTranserThird["ServiceBooth"])["Date"];
  882. }
  883. if (jPartThird != null)
  884. {
  885. row_new["PartThird_CargoCollection_Date"] = ((JObject)jPartThird["CargoCollection"])["Date"];
  886. row_new["PartThird_Number"] = jPartThird["Number"];
  887. row_new["PartThird_Unit"] = jPartThird["Unit"];
  888. row_new["PartThird_FileValidation_Date"] = ((JObject)jPartThird["FileValidation"])["Date"];
  889. var sTransportationMode = jPartThird["TransportationMode"] == null ? "" : jPartThird["TransportationMode"].ToString();
  890. if (sTransportationMode != "")
  891. {
  892. var oArgument = db.Queryable<OTB_SYS_Arguments>()
  893. .Single(it => it.OrgID == i_crm.ORIGID && it.ArgumentClassID == "Transport" && it.ArgumentID == sTransportationMode);
  894. if (oArgument == null)
  895. {
  896. oArgument = new OTB_SYS_Arguments();
  897. }
  898. row_new["PartThird_TransportationMode"] = oArgument.ArgumentValue ?? "";
  899. }
  900. row_new["PartThird_GoodsType"] = jPartThird["GoodsType"];
  901. row_new["PartThird_Destination"] = jPartThird["Destination"];
  902. row_new["PartThird_InTransit_Date"] = ((JObject)jPartThird["InTransit"])["Date"];
  903. row_new["PartThird_GoodsArrival_Date"] = ((JObject)jPartThird["GoodsArrival"])["Date"];
  904. row_new["PartThird_CargoRelease_Date"] = ((JObject)jPartThird["CargoRelease"])["Date"];
  905. row_new["PartThird_Sign_Date"] = ((JObject)jPartThird["Sign"])["Date"];
  906. }
  907. if (jPartReImport != null)
  908. {
  909. row_new["PartReImport_CargoCollection_Date"] = ((JObject)jPartReImport["CargoCollection"])["Date"];
  910. row_new["PartReImport_Number"] = jPartReImport["Number"];
  911. row_new["PartReImport_Unit"] = jPartReImport["Unit"];
  912. row_new["PartReImport_FileValidation_Date"] = ((JObject)jPartReImport["FileValidation"])["Date"];
  913. row_new["PartReImport_GoodsType"] = jPartReImport["GoodsType"];
  914. row_new["PartReImport_HuiYun_Date"] = ((JObject)jPartReImport["HuiYun"])["Date"];
  915. row_new["PartReImport_GoodsArrival_Date"] = ((JObject)jPartReImport["GoodsArrival"])["Date"];
  916. row_new["PartReImport_CustomsDeclaration_Date"] = ((JObject)jPartReImport["CustomsDeclaration"])["Date"];
  917. row_new["PartReImport_CargoRelease_Date"] = ((JObject)jPartReImport["CargoRelease"])["Date"];
  918. row_new["PartReImport_Sign_Date"] = ((JObject)jPartReImport["Sign"])["Date"];
  919. }
  920. if (jReImportFour != null)
  921. {
  922. row_new["ReImportFour_CargoCollection_Date"] = ((JObject)jReImportFour["CargoCollection"])["Date"];
  923. row_new["ReImportFour_Number"] = jReImportFour["Number"];
  924. row_new["ReImportFour_Unit"] = jReImportFour["Unit"];
  925. row_new["ReImportFour_FileValidation_Date"] = ((JObject)jReImportFour["FileValidation"])["Date"];
  926. var sTransportationMode = jReImportFour["TransportationMode"] == null ? "" : jReImportFour["TransportationMode"].ToString();
  927. if (sTransportationMode != "")
  928. {
  929. var oArgument = db.Queryable<OTB_SYS_Arguments>()
  930. .Single(it => it.OrgID == i_crm.ORIGID && it.ArgumentClassID == "Transport" && it.ArgumentID == sTransportationMode);
  931. if (oArgument == null)
  932. {
  933. oArgument = new OTB_SYS_Arguments();
  934. }
  935. row_new["ReImportFour_TransportationMode"] = oArgument.ArgumentValue ?? "";
  936. }
  937. row_new["ReImportFour_GoodsType"] = jReImportFour["GoodsType"];
  938. row_new["ReImportFour_HuiYun_Date"] = ((JObject)jReImportFour["HuiYun"])["Date"];
  939. row_new["ReImportFour_GoodsArrival_Date"] = ((JObject)jReImportFour["GoodsArrival"])["Date"];
  940. row_new["ReImportFour_CustomsDeclaration_Date"] = ((JObject)jReImportFour["CustomsDeclaration"])["Date"];
  941. row_new["ReImportFour_CargoRelease_Date"] = ((JObject)jReImportFour["CargoRelease"])["Date"];
  942. row_new["ReImportFour_Sign_Date"] = ((JObject)jReImportFour["Sign"])["Date"];
  943. }
  944. if (jTransferFour != null)
  945. {
  946. row_new["TransferFour_CargoCollection_Date"] = ((JObject)jTransferFour["CargoCollection"])["Date"];
  947. row_new["TransferFour_Number"] = jTransferFour["Number"];
  948. row_new["TransferFour_Unit"] = jTransferFour["Unit"];
  949. row_new["TransferFour_FileValidation_Date"] = ((JObject)jTransferFour["FileValidation"])["Date"];
  950. var sTransportationMode = jTransferFour["TransportationMode"] == null ? "" : jTransferFour["TransportationMode"].ToString();
  951. if (sTransportationMode != "")
  952. {
  953. var oArgument = db.Queryable<OTB_SYS_Arguments>()
  954. .Single(it => it.OrgID == i_crm.ORIGID && it.ArgumentClassID == "Transport" && it.ArgumentID == sTransportationMode);
  955. if (oArgument == null)
  956. {
  957. oArgument = new OTB_SYS_Arguments();
  958. }
  959. row_new["TransferFour_TransportationMode"] = oArgument.ArgumentValue ?? "";
  960. }
  961. row_new["TransferFour_GoodsType"] = jTransferFour["GoodsType"];
  962. row_new["TransferFour_Destination"] = jTransferFour["Destination"];
  963. row_new["TransferFour_InTransit_Date"] = ((JObject)jTransferFour["InTransit"])["Date"];
  964. row_new["TransferFour_GoodsArrival_Date"] = ((JObject)jTransferFour["GoodsArrival"])["Date"];
  965. row_new["TransferFour_CargoRelease_Date"] = ((JObject)jTransferFour["CargoRelease"])["Date"];
  966. row_new["TransferFour_Sign_Date"] = ((JObject)jTransferFour["Sign"])["Date"];
  967. }
  968. if (jReImportFive != null)
  969. {
  970. row_new["ReImportFive_CargoCollection_Date"] = ((JObject)jReImportFive["CargoCollection"])["Date"];
  971. row_new["ReImportFive_Number"] = jReImportFive["Number"];
  972. row_new["ReImportFive_Unit"] = jReImportFive["Unit"];
  973. row_new["ReImportFive_FileValidation_Date"] = ((JObject)jReImportFive["FileValidation"])["Date"];
  974. var sTransportationMode = jReImportFive["TransportationMode"] == null ? "" : jReImportFive["TransportationMode"].ToString();
  975. if (sTransportationMode != "")
  976. {
  977. var oArgument = db.Queryable<OTB_SYS_Arguments>()
  978. .Single(it => it.OrgID == i_crm.ORIGID && it.ArgumentClassID == "Transport" && it.ArgumentID == sTransportationMode);
  979. if (oArgument == null)
  980. {
  981. oArgument = new OTB_SYS_Arguments();
  982. }
  983. row_new["ReImportFive_TransportationMode"] = oArgument.ArgumentValue ?? "";
  984. }
  985. row_new["ReImportFive_GoodsType"] = jReImportFive["GoodsType"];
  986. row_new["ReImportFive_HuiYun_Date"] = ((JObject)jReImportFive["HuiYun"])["Date"];
  987. row_new["ReImportFive_GoodsArrival_Date"] = ((JObject)jReImportFive["GoodsArrival"])["Date"];
  988. row_new["ReImportFive_CustomsDeclaration_Date"] = ((JObject)jReImportFive["CustomsDeclaration"])["Date"];
  989. row_new["ReImportFive_CargoRelease_Date"] = ((JObject)jReImportFive["CargoRelease"])["Date"];
  990. row_new["ReImportFive_Sign_Date"] = ((JObject)jReImportFive["Sign"])["Date"];
  991. }
  992. if (jTransferFive != null)
  993. {
  994. row_new["TransferFive_CargoCollection_Date"] = ((JObject)jTransferFive["CargoCollection"])["Date"];
  995. row_new["TransferFive_Number"] = jTransferFive["Number"];
  996. row_new["TransferFive_Unit"] = jTransferFive["Unit"];
  997. row_new["TransferFive_FileValidation_Date"] = ((JObject)jTransferFive["FileValidation"])["Date"];
  998. var sTransportationMode = jTransferFive["TransportationMode"] == null ? "" : jTransferFive["TransportationMode"].ToString();
  999. if (sTransportationMode != "")
  1000. {
  1001. var oArgument = db.Queryable<OTB_SYS_Arguments>()
  1002. .Single(it => it.OrgID == i_crm.ORIGID && it.ArgumentClassID == "Transport" && it.ArgumentID == sTransportationMode);
  1003. if (oArgument == null)
  1004. {
  1005. oArgument = new OTB_SYS_Arguments();
  1006. }
  1007. row_new["TransferFive_TransportationMode"] = oArgument.ArgumentValue ?? "";
  1008. }
  1009. row_new["TransferFive_GoodsType"] = jTransferFive["GoodsType"];
  1010. row_new["TransferFive_Destination"] = jTransferFive["Destination"];
  1011. row_new["TransferFive_InTransit_Date"] = ((JObject)jTransferFive["InTransit"])["Date"];
  1012. row_new["TransferFive_GoodsArrival_Date"] = ((JObject)jTransferFive["GoodsArrival"])["Date"];
  1013. row_new["TransferFive_CargoRelease_Date"] = ((JObject)jTransferFive["CargoRelease"])["Date"];
  1014. row_new["TransferFive_Sign_Date"] = ((JObject)jTransferFive["Sign"])["Date"];
  1015. }
  1016. if (jReImportSix != null)
  1017. {
  1018. row_new["ReImportSix_CargoCollection_Date"] = ((JObject)jReImportSix["CargoCollection"])["Date"];
  1019. row_new["ReImportSix_Number"] = jReImportSix["Number"];
  1020. row_new["ReImportSix_Unit"] = jReImportSix["Unit"];
  1021. row_new["ReImportSix_FileValidation_Date"] = ((JObject)jReImportSix["FileValidation"])["Date"];
  1022. var sTransportationMode = jReImportSix["TransportationMode"] == null ? "" : jReImportSix["TransportationMode"].ToString();
  1023. if (sTransportationMode != "")
  1024. {
  1025. var oArgument = db.Queryable<OTB_SYS_Arguments>()
  1026. .Single(it => it.OrgID == i_crm.ORIGID && it.ArgumentClassID == "Transport" && it.ArgumentID == sTransportationMode);
  1027. if (oArgument == null)
  1028. {
  1029. oArgument = new OTB_SYS_Arguments();
  1030. }
  1031. row_new["ReImportSix_TransportationMode"] = oArgument.ArgumentValue ?? "";
  1032. }
  1033. row_new["ReImportSix_GoodsType"] = jReImportSix["GoodsType"];
  1034. row_new["ReImportSix_HuiYun_Date"] = ((JObject)jReImportSix["HuiYun"])["Date"];
  1035. row_new["ReImportSix_GoodsArrival_Date"] = ((JObject)jReImportSix["GoodsArrival"])["Date"];
  1036. row_new["ReImportSix_CustomsDeclaration_Date"] = ((JObject)jReImportSix["CustomsDeclaration"])["Date"];
  1037. var sCustomsClearance = ((JObject)jReImportSix["CustomsDeclaration"])["CustomsClearance"].ToString();
  1038. if (sCustomsClearance != "")
  1039. {
  1040. var oArgument = db.Queryable<OTB_SYS_Arguments>()
  1041. .Single(it => it.OrgID == i_crm.ORIGID && it.ArgumentClassID == "Clearance" && it.ArgumentID == sCustomsClearance);
  1042. if (oArgument == null)
  1043. {
  1044. oArgument = new OTB_SYS_Arguments();
  1045. }
  1046. row_new["ReImportSix_CustomsDeclaration_CustomsClearance"] = oArgument.ArgumentValue ?? "";
  1047. }
  1048. row_new["ReImportSix_CargoRelease_Date"] = ((JObject)jReImportSix["CargoRelease"])["Date"];
  1049. row_new["ReImportSix_Sign_Date"] = ((JObject)jReImportSix["Sign"])["Date"];
  1050. }
  1051. if (jTransferSix != null)
  1052. {
  1053. row_new["TransferSix_CargoCollection_Date"] = ((JObject)jTransferSix["CargoCollection"])["Date"];
  1054. row_new["TransferSix_Number"] = jTransferSix["Number"];
  1055. row_new["TransferSix_Unit"] = jTransferSix["Unit"];
  1056. row_new["TransferSix_FileValidation_Date"] = ((JObject)jTransferSix["FileValidation"])["Date"];
  1057. var sTransportationMode = jTransferSix["TransportationMode"] == null ? "" : jTransferSix["TransportationMode"].ToString();
  1058. if (sTransportationMode != "")
  1059. {
  1060. var oArgument = db.Queryable<OTB_SYS_Arguments>()
  1061. .Single(it => it.OrgID == i_crm.ORIGID && it.ArgumentClassID == "Transport" && it.ArgumentID == sTransportationMode);
  1062. if (oArgument == null)
  1063. {
  1064. oArgument = new OTB_SYS_Arguments();
  1065. }
  1066. row_new["TransferSi_TransportationMode"] = oArgument.ArgumentValue ?? "";
  1067. }
  1068. row_new["TransferSix_GoodsType"] = jTransferSix["GoodsType"];
  1069. row_new["TransferSix_Destination"] = jTransferSix["Destination"];
  1070. row_new["TransferSix_InTransit_Date"] = ((JObject)jTransferSix["InTransit"])["Date"];
  1071. row_new["TransferSix_GoodsArrival_Date"] = ((JObject)jTransferSix["GoodsArrival"])["Date"];
  1072. row_new["TransferSix_CargoRelease_Date"] = ((JObject)jTransferSix["CargoRelease"])["Date"];
  1073. row_new["TransferSix_Sign_Date"] = ((JObject)jTransferSix["Sign"])["Date"];
  1074. }
  1075. dt_new.Rows.Add(row_new);
  1076. iFirstRow++;
  1077. }
  1078. }
  1079. else
  1080. {
  1081. foreach (DataColumn col in dt.Columns)
  1082. {
  1083. row_new[col.ToString()] = row[col.ToString()];
  1084. }
  1085. dt_new.Rows.Add(row_new);
  1086. iFirstRow++;
  1087. }
  1088. }
  1089. oHeader_Last = Export_BusinessTrackingSchedule_List;
  1090. }
  1091. break;
  1092. default:
  1093. {
  1094. break;
  1095. }
  1096. }
  1097. var bOk = new ExcelService().CreateExcelByTb(dt_new, out string sPath, oHeader_Last, dicAlain, listMerge, sFileName);
  1098. rm.DATA.Add(BLWording.REL, sPath);
  1099. }
  1100. else
  1101. {
  1102. rm.DATA.Add(BLWording.REL, pml);
  1103. }
  1104. } while (false);
  1105. }
  1106. catch (Exception ex)
  1107. {
  1108. sMsg = Util.GetLastExceptionMsg(ex);
  1109. LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, "EasyBL.WEBAPP.OPM.ImportExhibition_QryService", "", "QueryPage(出口分頁查詢)", "", "", "");
  1110. }
  1111. finally
  1112. {
  1113. if (null != sMsg)
  1114. {
  1115. rm = new ErrorResponseMessage(sMsg, i_crm);
  1116. }
  1117. }
  1118. return rm;
  1119. }
  1120. #endregion 出口分頁查詢
  1121. #region 出口單筆查詢
  1122. /// <summary>
  1123. /// 出口單筆查詢
  1124. /// </summary>
  1125. /// <param name="i_crm"></param>
  1126. /// <returns></returns>
  1127. public ResponseMessage QueryOne(RequestMessage i_crm)
  1128. {
  1129. ResponseMessage rm = null;
  1130. string sMsg = null;
  1131. var db = SugarBase.GetIntance();
  1132. try
  1133. {
  1134. do
  1135. {
  1136. var sId = _fetchString(i_crm, @"Guid");
  1137. var oExportExhibition = db.Queryable<OTB_OPM_ExportExhibition, OTB_CRM_Customers, OTB_OPM_Exhibition>
  1138. ((t1, t2, t3) =>
  1139. new object[] {
  1140. JoinType.Left, t1.OrgID == t2.OrgID && t1.Agent == t2.guid,
  1141. JoinType.Left, t1.OrgID == t3.OrgID && t1.ExhibitionNO == t3.SN.ToString()
  1142. }
  1143. )
  1144. .Where((t1, t2, t3) => t1.OrgID == i_crm.ORIGID && t1.ExportBillNO == sId)
  1145. .Select((t1, t2, t3) => new View_OPM_ExportExhibition
  1146. {
  1147. ExportBillNO = SqlFunc.GetSelfAndAutoFill(t1.ExportBillNO),
  1148. Exhibitioname_TW = t3.Exhibitioname_TW,
  1149. Exhibitioname_EN = t3.Exhibitioname_EN,
  1150. AgentName = SqlFunc.IIF(SqlFunc.HasValue(t2.CustomerCName), t2.CustomerCName, t2.CustomerEName)
  1151. }).Single();
  1152. rm = new SuccessResponseMessage(null, i_crm);
  1153. rm.DATA.Add(BLWording.REL, oExportExhibition);
  1154. } while (false);
  1155. }
  1156. catch (Exception ex)
  1157. {
  1158. sMsg = Util.GetLastExceptionMsg(ex);
  1159. LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, "EasyBL.WEBAPP.OPM.ImportExhibition_QryService", "", "QueryOne(出口單筆查詢)", "", "", "");
  1160. }
  1161. finally
  1162. {
  1163. if (null != sMsg)
  1164. {
  1165. rm = new ErrorResponseMessage(sMsg, i_crm);
  1166. }
  1167. }
  1168. return rm;
  1169. }
  1170. #endregion 出口單筆查詢
  1171. }
  1172. }