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.

611 lines
40 KiB

2 years ago
  1. using EasyBL.WebApi.Message;
  2. using Entity;
  3. using Entity.Sugar;
  4. using Newtonsoft.Json;
  5. using Newtonsoft.Json.Linq;
  6. using SqlSugar;
  7. using SqlSugar.Base;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Web;
  11. namespace EasyBL.WEBSITE.TE
  12. {
  13. public class TEAPIService : ServiceBase
  14. {
  15. #region 獲取最新消息個數(近一個月內)
  16. /// <summary>
  17. /// 獲取最新消息個數(近一個月內)
  18. /// </summary>
  19. /// <param name="i_crm"></param>
  20. /// <returns></returns>
  21. public ResponseMessage GetNewsCount(RequestMessage i_crm)
  22. {
  23. ResponseMessage rm = null;
  24. string sMsg = null;
  25. var db = SugarBase.DB;
  26. try
  27. {
  28. do
  29. {
  30. var sLang = _fetchString(i_crm, "Lang") ?? i_crm.LANG;
  31. var rDate = DateTime.Now.AddDays(-30);
  32. var iCount = db.Queryable<OTB_WSM_News>()
  33. .Count(x => x.OrgID == i_crm.ORIGID && x.News_Show == "Y" && x.News_LanguageType == sLang && x.CreateDate >= rDate);
  34. rm = new SuccessResponseMessage(null, i_crm);
  35. rm.DATA.Add(BLWording.REL, iCount);
  36. } while (false);
  37. }
  38. catch (Exception ex)
  39. {
  40. sMsg = Util.GetLastExceptionMsg(ex);
  41. LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, "EasyBL.WebSite.TE.TEAPIService", "獲取最新消息個數(近一個月內)", nameof(GetNewsCount), "", "", "");
  42. }
  43. finally
  44. {
  45. if (null != sMsg)
  46. {
  47. rm = new ErrorResponseMessage(sMsg, i_crm);
  48. }
  49. }
  50. return rm;
  51. }
  52. #endregion 獲取最新消息個數(近一個月內)
  53. #region 前臺Tracking查詢
  54. /// <summary>
  55. /// 前臺Tracking查詢
  56. /// </summary>
  57. /// <param name="i_crm">todo: describe i_crm parameter on GetTrackingProgress</param>
  58. /// <returns></returns>
  59. public ResponseMessage GetTrackingProgress(RequestMessage i_crm)
  60. {
  61. ResponseMessage rm = null;
  62. string sMsg = null;
  63. var db = SugarBase.GetIntance();
  64. var oExportMap = new SetMap();
  65. try
  66. {
  67. do
  68. {
  69. var sQueryNum = _fetchString(i_crm, "QueryNum");
  70. if (sQueryNum.Length < 12)
  71. {
  72. sMsg = "查詢碼錯誤";
  73. if (i_crm.LANG == "zh")
  74. {
  75. sMsg = "查询码错误";
  76. }
  77. else if (i_crm.LANG == "en")
  78. {
  79. sMsg = "Query code error";
  80. }
  81. break;
  82. }
  83. var sValidCode = _fetchString(i_crm, "ValidCode");
  84. var sIP = _fetchString(i_crm, "IP");
  85. var sIPInfo = _fetchString(i_crm, "IPInfo");
  86. var sType = sQueryNum.Substring(3, 1);
  87. var sParentId = "";
  88. var sCustomerName = "";
  89. var sAgentName = "";
  90. var sResponsiblePerson = "";
  91. var sFlag = _fetchString(i_crm, "flag");
  92. var sCaptcha = "";
  93. if (sValidCode != null)
  94. {
  95. if (HttpContext.Current.Session[BLWording.CAPTCHA + sFlag] != null)
  96. {
  97. sCaptcha = HttpContext.Current.Session[BLWording.CAPTCHA + sFlag].ToString();
  98. }
  99. if (sCaptcha != sValidCode)
  100. {
  101. sMsg = "驗證碼錯誤";
  102. if (i_crm.LANG == "zh")
  103. {
  104. sMsg = "验证码错误";
  105. }
  106. else if (i_crm.LANG == "en")
  107. {
  108. sMsg = "Incorrect verification code";
  109. }
  110. break;
  111. }
  112. }
  113. if (sType == "I")
  114. {
  115. var oImport = db.Queryable<OTB_OPM_ImportExhibition>()
  116. .Single(it => it.RefNumber == sQueryNum && it.OrgID == i_crm.ORIGID);
  117. if (oImport != null)
  118. {
  119. sParentId = oImport.ImportBillNO;
  120. sResponsiblePerson = oImport.ResponsiblePerson;
  121. var JImport = (JObject)JsonConvert.DeserializeObject(oImport.Import);
  122. var saFlows = new List<SetMap>();
  123. oExportMap.Put("Type", "IM");
  124. var oCus = new OTB_CRM_Customers();
  125. OTB_OPM_Exhibition oExhibition = null;
  126. if (oImport.SupplierType == "S")
  127. {
  128. if (!string.IsNullOrEmpty(oImport.Supplier))
  129. {
  130. oCus = db.Queryable<OTB_CRM_Customers>().Single(it => it.guid == oImport.Supplier);
  131. sCustomerName = string.IsNullOrEmpty(oCus.CustomerCName) ? oCus.CustomerEName : oCus.CustomerCName;
  132. }
  133. if (!string.IsNullOrEmpty(oImport.Agent))
  134. {
  135. var oAgent = db.Queryable<OTB_CRM_Customers>().Single(it => it.guid == oImport.Agent);
  136. sAgentName = string.IsNullOrEmpty(oAgent.CustomerCName) ? oAgent.CustomerEName : oAgent.CustomerCName;
  137. }
  138. }
  139. else
  140. {
  141. if (!string.IsNullOrEmpty(oImport.Agent))
  142. {
  143. oCus = db.Queryable<OTB_CRM_Customers>().Single(it => it.guid == oImport.Agent);
  144. sAgentName = string.IsNullOrEmpty(oCus.CustomerCName) ? oCus.CustomerEName : oCus.CustomerCName;
  145. }
  146. if (!string.IsNullOrEmpty(oImport.Supplier))
  147. {
  148. var oSupplier = db.Queryable<OTB_CRM_Customers>().Single(it => it.guid == oImport.Supplier);
  149. sCustomerName = string.IsNullOrEmpty(oSupplier.CustomerCName) ? oSupplier.CustomerEName : oSupplier.CustomerCName;
  150. }
  151. }
  152. if (oCus == null)
  153. {
  154. oCus = new OTB_CRM_Customers();
  155. }
  156. if (oImport.ExhibitionNO != "")
  157. {
  158. oExhibition = db.Queryable<OTB_OPM_Exhibition>()
  159. .Single(it => it.SN == oImport.ExhibitionNO.ObjToInt());
  160. if (oExhibition == null)
  161. {
  162. oExhibition = new OTB_OPM_Exhibition();
  163. }
  164. }
  165. oExportMap.Put("SupplierName", oCus.CustomerCName ?? "");
  166. oExportMap.Put("SupplierEName", oCus.CustomerEName ?? "");
  167. oExportMap.Put("Exhibitioname_TW", oExhibition.Exhibitioname_TW ?? "");
  168. oExportMap.Put("Exhibitioname_CN", oExhibition.Exhibitioname_CN ?? "");
  169. oExportMap.Put("Exhibitioname_EN", oExhibition.Exhibitioname_EN ?? "");
  170. oExportMap.Put("PrgCode", "ExhibitionImport_Upd");
  171. var Flow = new SetMap();
  172. Flow.Put("Parent", true);
  173. Flow.Put("Index", 0);
  174. Flow.Put("ShotName", "IMPORT");
  175. Flow.Put("FlowName", "ExhibitionImport_Upd.Import");
  176. Flow.Put("Number", oImport.BoxNo);
  177. Flow.Put("Unit", oImport.Unit);
  178. Flow.Put("BillLadNO", oImport.BillLadNO);
  179. Flow.Put("BillLadNOSub", oImport.BillLadNOSub);
  180. Flow.Put("ContainerNumber", oImport.ContainerNumber);
  181. Flow.Put("Data", oImport.Import);
  182. Flow.Put("ShipmentPort", oImport.ShipmentPortCode);
  183. Flow.Put("Destination", oImport.DestinationPortCode);
  184. var sPath = "";
  185. if (oImport.SignatureFileId != null && oImport.SignatureFileId != "")
  186. {
  187. var oFile = db.Queryable<OTB_SYS_Files>()
  188. .Single(it => it.OrgID == i_crm.ORIGID && it.ParentID == oImport.SignatureFileId);
  189. if (oFile != null)
  190. {
  191. sPath = oFile.FilePath;
  192. }
  193. }
  194. Flow.Put("SignatureFile", sPath);
  195. saFlows.Add(Flow);
  196. var jaReImports = (JArray)JsonConvert.DeserializeObject(oImport.ReImports);
  197. if (jaReImports != null && jaReImports.Count > 0)
  198. {
  199. var iIndex = 1;
  200. foreach (JObject jo in jaReImports)
  201. {
  202. var sFilePath = "";
  203. var sIndex = jaReImports.Count > 1 ? ("-" + iIndex) : "";
  204. var sSignatureFileId = jo["SignatureFileId"].ToString();
  205. var JReImport = (JObject)jo["ReImport"];
  206. var JReImportData = (JObject)jo["ReImportData"];
  207. Flow = new SetMap();
  208. Flow.Put("Index", sIndex);
  209. Flow.Put("ShotName", "RETURN" + sIndex);
  210. Flow.Put("FlowName", "ExhibitionImport_Upd.ReImport" + (jaReImports.Count > 1 ? iIndex.ToString() : ""));
  211. Flow.Put("Number", JReImportData["Number"] ?? "");
  212. Flow.Put("Unit", JReImportData["Unit"] ?? "");
  213. Flow.Put("BillLadNO", JReImportData["BillLadNO"] ?? "");
  214. Flow.Put("BillLadNOSub", JReImportData["BillLadNOSub"] ?? "");
  215. Flow.Put("ContainerNumber", JReImportData["ContainerNumber"] ?? "");
  216. Flow.Put("Data", JReImport.ToString());
  217. Flow.Put("ShipmentPort", JReImportData["DestinationPortCode"] ?? "");
  218. Flow.Put("Destination", JReImportData["ReShipmentPortCode"] ?? "");
  219. if (sSignatureFileId != "")
  220. {
  221. var oFile = db.Queryable<OTB_SYS_Files>()
  222. .Single(it => it.OrgID == i_crm.ORIGID && it.ParentID == sSignatureFileId);
  223. if (oFile != null)
  224. {
  225. sPath = oFile.FilePath;
  226. }
  227. }
  228. Flow.Put("SignatureFile", sFilePath);
  229. saFlows.Add(Flow);
  230. iIndex++;
  231. }
  232. }
  233. oExportMap.Put("Flows", saFlows);
  234. }
  235. }
  236. else if (sType == "E")
  237. {
  238. var sParentQueryNum = sQueryNum.Substring(0, sQueryNum.Length - 3);
  239. var oExport = db.Queryable<OTB_OPM_ExportExhibition>()
  240. .Single(it => it.RefNumber == sParentQueryNum && it.OrgID == i_crm.ORIGID);
  241. if (oExport != null)
  242. {
  243. sParentId = oExport.ExportBillNO;
  244. sResponsiblePerson = oExport.ResponsiblePerson;
  245. if (!string.IsNullOrEmpty(oExport.Agent))
  246. {
  247. var oCus = db.Queryable<OTB_CRM_Customers>().Single(it => it.guid == oExport.Agent);
  248. sAgentName = string.IsNullOrEmpty(oCus.CustomerCName) ? oCus.CustomerEName : oCus.CustomerCName;
  249. }
  250. var oExhibition = new OTB_OPM_Exhibition();
  251. if (oExport.ExhibitionNO != "")
  252. {
  253. oExhibition = db.Queryable<OTB_OPM_Exhibition>()
  254. .Single(it => it.SN == oExport.ExhibitionNO.ObjToInt());
  255. if (oExhibition == null)
  256. {
  257. oExhibition = new OTB_OPM_Exhibition();
  258. }
  259. }
  260. var Exhibitors = (JArray)JsonConvert.DeserializeObject(oExport.Exhibitors);
  261. foreach (JObject Exhibitor in Exhibitors)
  262. {
  263. if (Exhibitor["RefSupplierNo"] != null && Exhibitor["RefSupplierNo"].ToString() == sQueryNum)
  264. {
  265. var JExportData = (JObject)Exhibitor["ExportData"];
  266. var iIndex = 0;
  267. var saFlows = new List<SetMap>();
  268. oExportMap.Put("Type", "EX");
  269. oExportMap.Put("SupplierName", Exhibitor["SupplierName"] ?? "");
  270. oExportMap.Put("SupplierEName", Exhibitor["SupplierEName"] ?? "");
  271. oExportMap.Put("Exhibitioname_TW", oExhibition.Exhibitioname_TW);
  272. oExportMap.Put("Exhibitioname_CN", oExhibition.Exhibitioname_CN);
  273. oExportMap.Put("Exhibitioname_EN", oExhibition.Exhibitioname_EN);
  274. oExportMap.Put("PrgCode", "ExhibitionExport_Upd");
  275. sCustomerName = oExportMap["SupplierName"].ToString() == "" ? oExportMap["SupplierEName"].ToString() : oExportMap["SupplierName"].ToString();
  276. var Flow = new SetMap();
  277. Flow.Put("Parent", true);
  278. Flow.Put("Index", iIndex);
  279. Flow.Put("ShotName", "EXPORT");
  280. Flow.Put("FlowName", "ExhibitionExport_Upd.ExportData");
  281. Flow.Put("Number", ((JObject)JExportData["Intowarehouse"])["Number"] ?? "");
  282. Flow.Put("Unit", ((JObject)JExportData["Intowarehouse"])["Unit"] ?? "");
  283. Flow.Put("BillLadNO", oExport.BillLadNO);
  284. Flow.Put("BillLadNOSub", oExport.BillLadNOSub);
  285. Flow.Put("ContainerNumber", oExport.ContainerNumber);
  286. var JClearanceData = (JObject)Exhibitor["ClearanceData"];
  287. JExportData["GoodsArrival"] = JClearanceData["GoodsArrival"];
  288. JExportData["CargoRelease"] = JClearanceData["CargoRelease"];
  289. JExportData["WaitingApproach"] = JClearanceData["WaitingApproach"];
  290. JExportData["ServiceBooth"] = JClearanceData["ServiceBooth"];
  291. //JExportData["Sign"] = JClearanceData["Sign"];
  292. Flow.Put("Data", JExportData.ToString());
  293. Flow.Put("ShipmentPort", oExport.ShipmentPortCode);
  294. Flow.Put("Destination", oExport.DestinationCode);
  295. Flow.Put("SitiContactor1", oExport.SitiContactor1);
  296. Flow.Put("SitiTelephone1", oExport.SitiTelephone1);
  297. Flow.Put("SitiContactor2", oExport.SitiContactor2);
  298. Flow.Put("SitiTelephone2", oExport.SitiTelephone2);
  299. saFlows.Add(Flow);
  300. iIndex++;
  301. var sReturnType = Exhibitor["ReturnType"].ToString();
  302. if (sReturnType == "H") //退運回台
  303. {
  304. var JReImport = (JObject)Exhibitor["ReImport"];
  305. var bReturn_ReImport = ((JObject)JReImport["CargoCollection"])["Checked"] != null ? true : false;
  306. if (bReturn_ReImport)
  307. {
  308. Flow = new SetMap();
  309. Flow.Put("Index", iIndex);
  310. Flow.Put("ShotName", "RE-IMPORT");
  311. Flow.Put("FlowName", "ExhibitionExport_Upd.ReImport");
  312. Flow.Put("Number", JReImport["Number"] ?? "");
  313. Flow.Put("Unit", JReImport["Unit"] ?? "");
  314. Flow.Put("BillLadNO", "");
  315. Flow.Put("BillLadNOSub", "");
  316. Flow.Put("ContainerNumber", "");
  317. Flow.Put("Data", JReImport.ToString());
  318. Flow.Put("ShipmentPort", JReImport["ShipmentPortCode"] ?? "");
  319. Flow.Put("Destination", JReImport["DestinationCode"] ?? "");
  320. saFlows.Add(Flow);
  321. iIndex++;
  322. }
  323. }
  324. else if (sReturnType == "T") //出貨至第三地
  325. {
  326. var JTranserThird = (JObject)Exhibitor["TranserThird"];
  327. var bReturn_TranserThird = ((JObject)JTranserThird["CargoCollection"])["Checked"] != null ? true : false;
  328. if (bReturn_TranserThird)
  329. {
  330. Flow = new SetMap();
  331. Flow.Put("Index", iIndex);
  332. Flow.Put("ShotName", "TRANSFER");
  333. Flow.Put("FlowName", "ExhibitionExport_Upd.TransferThirdPlace");
  334. Flow.Put("Number", JTranserThird["Number"] ?? "");
  335. Flow.Put("Unit", JTranserThird["Unit"] ?? "");
  336. Flow.Put("BillLadNO", "");
  337. Flow.Put("BillLadNOSub", "");
  338. Flow.Put("ContainerNumber", "");
  339. Flow.Put("Data", JTranserThird.ToString());
  340. Flow.Put("ShipmentPort", JTranserThird["ShipmentPortCode"] ?? "");
  341. Flow.Put("Destination", JTranserThird["DestinationCode"] ?? "");
  342. saFlows.Add(Flow);
  343. iIndex++;
  344. if (Exhibitor["LastReturnType"] != null)
  345. {
  346. var sLastReturnType = Exhibitor["LastReturnType"].ToString();
  347. if (sLastReturnType == "F")
  348. {
  349. var JTransferFour = (JObject)Exhibitor["TransferFour"];
  350. var bReturn_TransferFour = ((JObject)JTransferFour["CargoCollection"])["Checked"] != null ? true : false;
  351. if (bReturn_TransferFour)
  352. {
  353. Flow = new SetMap();
  354. Flow.Put("Index", iIndex);
  355. Flow.Put("ShotName", "TRANSFER");
  356. Flow.Put("FlowName", "ExhibitionExport_Upd.TransferFourPlace");
  357. Flow.Put("Number", JTransferFour["Number"] ?? "");
  358. Flow.Put("Unit", JTransferFour["Unit"] ?? "");
  359. Flow.Put("BillLadNO", "");
  360. Flow.Put("BillLadNOSub", "");
  361. Flow.Put("ContainerNumber", "");
  362. Flow.Put("Data", JTransferFour.ToString());
  363. Flow.Put("ShipmentPort", JTransferFour["ShipmentPortCode"] ?? "");
  364. Flow.Put("Destination", JTransferFour["DestinationCode"] ?? "");
  365. saFlows.Add(Flow);
  366. iIndex++;
  367. }
  368. if (Exhibitor["ReturnType_4"] != null)
  369. {
  370. var sReturnType_4 = Exhibitor["ReturnType_4"].ToString();
  371. if (sReturnType_4 == "F")
  372. {
  373. var JTransferFive = (JObject)Exhibitor["TransferFive"];
  374. var bReturn_TransferFive = ((JObject)JTransferFive["CargoCollection"])["Checked"] != null ? true : false;
  375. if (bReturn_TransferFive)
  376. {
  377. Flow = new SetMap();
  378. Flow.Put("Index", iIndex);
  379. Flow.Put("ShotName", "TRANSFER");
  380. Flow.Put("FlowName", "ExhibitionExport_Upd.TransferFivePlace");
  381. Flow.Put("Number", JTransferFive["Number"] ?? "");
  382. Flow.Put("Unit", JTransferFive["Unit"] ?? "");
  383. Flow.Put("BillLadNO", "");
  384. Flow.Put("BillLadNOSub", "");
  385. Flow.Put("ContainerNumber", "");
  386. Flow.Put("Data", JTransferFive.ToString());
  387. Flow.Put("ShipmentPort", JTransferFive["ShipmentPortCode"] ?? "");
  388. Flow.Put("Destination", JTransferFive["DestinationCode"] ?? "");
  389. saFlows.Add(Flow);
  390. iIndex++;
  391. }
  392. if (Exhibitor["ReturnType_5"] != null)
  393. {
  394. var sReturnType_5 = Exhibitor["ReturnType_5"].ToString();
  395. if (sReturnType_5 == "F")
  396. {
  397. var JTransferSix = (JObject)Exhibitor["TransferSix"];
  398. var bReturn_TransferSix = ((JObject)JTransferSix["CargoCollection"])["Checked"] != null ? true : false;
  399. if (bReturn_TransferSix)
  400. {
  401. Flow = new SetMap();
  402. Flow.Put("Index", iIndex);
  403. Flow.Put("ShotName", "TRANSFER");
  404. Flow.Put("FlowName", "ExhibitionExport_Upd.TransferSixPlace");
  405. Flow.Put("Number", JTransferSix["Number"] ?? "");
  406. Flow.Put("Unit", JTransferSix["Unit"] ?? "");
  407. Flow.Put("BillLadNO", "");
  408. Flow.Put("BillLadNOSub", "");
  409. Flow.Put("ContainerNumber", "");
  410. Flow.Put("Data", JTransferSix.ToString());
  411. Flow.Put("ShipmentPort", JTransferSix["ShipmentPortCode"] ?? "");
  412. Flow.Put("Destination", JTransferSix["DestinationCode"] ?? "");
  413. saFlows.Add(Flow);
  414. iIndex++;
  415. }
  416. }
  417. else
  418. {
  419. var JReImportSix = (JObject)Exhibitor["ReImportSix"];
  420. if (JReImportSix != null)
  421. {
  422. var bReturn_ReImportSix = ((JObject)JReImportSix["CargoCollection"])["Checked"] != null ? true : false;
  423. if (bReturn_ReImportSix)
  424. {
  425. Flow = new SetMap();
  426. Flow.Put("Index", iIndex);
  427. Flow.Put("ShotName", "RE-IMPORT");
  428. Flow.Put("FlowName", "ExhibitionExport_Upd.ReImport");
  429. Flow.Put("Number", JReImportSix["Number"] ?? "");
  430. Flow.Put("Unit", JReImportSix["Unit"] ?? "");
  431. Flow.Put("BillLadNO", "");
  432. Flow.Put("BillLadNOSub", "");
  433. Flow.Put("ContainerNumber", "");
  434. Flow.Put("Data", JReImportSix.ToString());
  435. Flow.Put("ShipmentPort", JReImportSix["ShipmentPortCode"] ?? "");
  436. Flow.Put("Destination", JReImportSix["DestinationCode"] ?? "");
  437. saFlows.Add(Flow);
  438. iIndex++;
  439. }
  440. }
  441. }
  442. }
  443. }
  444. else
  445. {
  446. var JReImportFive = (JObject)Exhibitor["ReImportFive"];
  447. if (JReImportFive != null)
  448. {
  449. var bReturn_ReImportFive = ((JObject)JReImportFive["CargoCollection"])["Checked"] != null ? true : false;
  450. if (bReturn_ReImportFive)
  451. {
  452. Flow = new SetMap();
  453. Flow.Put("Index", iIndex);
  454. Flow.Put("ShotName", "RE-IMPORT");
  455. Flow.Put("FlowName", "ExhibitionExport_Upd.ReImport");
  456. Flow.Put("Number", JReImportFive["Number"] ?? "");
  457. Flow.Put("Unit", JReImportFive["Unit"] ?? "");
  458. Flow.Put("BillLadNO", "");
  459. Flow.Put("BillLadNOSub", "");
  460. Flow.Put("ContainerNumber", "");
  461. Flow.Put("Data", JReImportFive.ToString());
  462. Flow.Put("ShipmentPort", JReImportFive["ShipmentPortCode"] ?? "");
  463. Flow.Put("Destination", JReImportFive["DestinationCode"] ?? "");
  464. saFlows.Add(Flow);
  465. iIndex++;
  466. }
  467. }
  468. }
  469. }
  470. }
  471. else
  472. {
  473. var JReImportFour = (JObject)Exhibitor["ReImportFour"];
  474. if (JReImportFour != null)
  475. {
  476. var bReturn_ReImportFour = ((JObject)JReImportFour["CargoCollection"])["Checked"] != null ? true : false;
  477. if (bReturn_ReImportFour)
  478. {
  479. Flow = new SetMap();
  480. Flow.Put("Index", iIndex);
  481. Flow.Put("ShotName", "RE-IMPORT");
  482. Flow.Put("FlowName", "ExhibitionExport_Upd.ReImport");
  483. Flow.Put("Number", JReImportFour["Number"] ?? "");
  484. Flow.Put("Unit", JReImportFour["Unit"] ?? "");
  485. Flow.Put("BillLadNO", "");
  486. Flow.Put("BillLadNOSub", "");
  487. Flow.Put("ContainerNumber", "");
  488. Flow.Put("Data", JReImportFour.ToString());
  489. Flow.Put("ShipmentPort", JReImportFour["ShipmentPortCode"] ?? "");
  490. Flow.Put("Destination", JReImportFour["DestinationCode"] ?? "");
  491. saFlows.Add(Flow);
  492. iIndex++;
  493. }
  494. }
  495. }
  496. }
  497. }
  498. }
  499. else if (sReturnType == "P")
  500. { //部分運至第三地部分退運回台
  501. var JPartThird = (JObject)Exhibitor["PartThird"];
  502. var JPartReImport = (JObject)Exhibitor["PartReImport"];
  503. if (JPartThird != null)
  504. {
  505. var bReturn_PartThird = ((JObject)JPartThird["CargoCollection"])["Checked"] != null ? true : false;
  506. if (bReturn_PartThird)
  507. {
  508. Flow = new SetMap();
  509. Flow.Put("Index", iIndex);
  510. Flow.Put("ShotName", "TRANSFER");
  511. Flow.Put("FlowName", "ExhibitionExport_Upd.TransferThirdPlace");
  512. Flow.Put("Number", JPartThird["Number"] ?? "");
  513. Flow.Put("Unit", JPartThird["Unit"] ?? "");
  514. Flow.Put("BillLadNO", "");
  515. Flow.Put("BillLadNOSub", "");
  516. Flow.Put("ContainerNumber", "");
  517. Flow.Put("Data", JPartThird.ToString());
  518. Flow.Put("ShipmentPort", JPartThird["ShipmentPortCode"] ?? "");
  519. Flow.Put("Destination", JPartThird["DestinationCode"] ?? "");
  520. saFlows.Add(Flow);
  521. iIndex++;
  522. }
  523. }
  524. if (JPartReImport != null)
  525. {
  526. var bReturn_PartReImport = ((JObject)JPartReImport["CargoCollection"])["Checked"] != null ? true : false;
  527. if (bReturn_PartReImport)
  528. {
  529. Flow = new SetMap();
  530. Flow.Put("Index", iIndex);
  531. Flow.Put("ShotName", "RE-IMPORT");
  532. Flow.Put("FlowName", "ExhibitionExport_Upd.ReturnedHome");
  533. Flow.Put("Number", JPartReImport["Number"] ?? "");
  534. Flow.Put("Unit", JPartReImport["Unit"] ?? "");
  535. Flow.Put("BillLadNO", "");
  536. Flow.Put("BillLadNOSub", "");
  537. Flow.Put("ContainerNumber", "");
  538. Flow.Put("Data", JPartReImport.ToString());
  539. Flow.Put("ShipmentPort", JPartReImport["ShipmentPortCode"] ?? "");
  540. Flow.Put("Destination", JPartReImport["DestinationCode"] ?? "");
  541. saFlows.Add(Flow);
  542. iIndex++;
  543. }
  544. }
  545. }
  546. oExportMap.Put("Flows", saFlows);
  547. break;
  548. }
  549. }
  550. }
  551. }
  552. if (oExportMap.Keys.Count > 0)
  553. {
  554. var spm = new List<SugarParameter> {
  555. new SugarParameter("@OrgID", i_crm.ORIGID),
  556. new SugarParameter("@ResponsiblePerson", sResponsiblePerson),
  557. };
  558. var sDepartmentIDs = db.Ado.GetString(@"select DepartmentID+',' from [dbo].[OFN_SYS_GetParentDepartmentIdByUserID](@OrgID,@ResponsiblePerson) for xml path('')", spm);
  559. var oTrackingLog = new OTB_WSM_TrackingLog
  560. {
  561. OrgID = i_crm.ORIGID,
  562. QueryNumber = sQueryNum,
  563. QueryIp = string.IsNullOrEmpty(sIP) ? i_crm.ClientIP : sIP,
  564. IPInfo = sIPInfo,
  565. QueryTime = DateTime.Now,
  566. ParentId = sParentId,
  567. CustomerName = sCustomerName,
  568. AgentName = sAgentName,
  569. DepartmentIDs = sDepartmentIDs
  570. };
  571. db.Insertable<OTB_WSM_TrackingLog>(oTrackingLog).ExecuteCommand();
  572. }
  573. rm = new SuccessResponseMessage(null, i_crm);
  574. rm.DATA.Add(BLWording.REL, oExportMap);
  575. } while (false);
  576. }
  577. catch (Exception ex)
  578. {
  579. sMsg = Util.GetLastExceptionMsg(ex);
  580. LogAndSendEmail(sMsg + "Param:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, "EasyBL.WebSite.TE.TEAPIService", "", "GetTrackingProgress(前臺Tracking查詢)", "", "", "");
  581. }
  582. finally
  583. {
  584. if (null != sMsg)
  585. {
  586. rm = new ErrorResponseMessage(sMsg, i_crm);
  587. }
  588. }
  589. return rm;
  590. }
  591. #endregion 前臺Tracking查詢
  592. }
  593. }