diff --git a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs
index 45cf2742..2ae7a7d4 100644
--- a/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs
+++ b/Myshipping.Application/Service/TaskManagePlat/TaskManageService.cs
@@ -1105,6 +1105,7 @@ namespace Myshipping.Application
///
/// 任务主键数组
/// 返回结果
+ [HttpPost("/TaskManage/LaraPaperCalc")]
public async Task> LaraPaperCalc(string[] PKIds)
{
List list = new List();
@@ -1122,18 +1123,40 @@ namespace Myshipping.Application
if (mblnoList.Count > 0)
{
//根据主单号获取任务类型是DRAFT的任务,取时间最新的
- var taskList = _taskBaseInfoRepository.AsQueryable()
- .LeftJoin(_taskFileInfoRepository.AsQueryable(), (tsk, file) => tsk.PK_ID == file.TASK_PKID)
- .Where((tsk, file) => PKIds.Contains(tsk.PK_ID) && tsk.TASK_TYPE == TaskBusiTypeEnum.DRAFT.ToString() && file != null)
- .OrderByDescending(tsk => tsk.CreatedTime)
+ var fileList = _taskBaseInfoRepository.EntityContext.Queryable()
+ .InnerJoin((tsk, file) => tsk.PK_ID == file.TASK_PKID)
+ .Where((tsk, file) =>
+ tsk.TASK_TYPE == TaskBusiTypeEnum.DRAFT.ToString() && mblnoList.Contains(tsk.MBL_NO))
.Select((tsk, file) => new { tsk = tsk, file = file }).ToList();
+ var calcList = fileList.GroupBy(t => t.tsk.PK_ID)
+ .Select(a =>
+ {
+ var currList = a.ToList();
+
+ return new
+ {
+ tsk = currList.FirstOrDefault().tsk,
+ clist = a.Select(x => x.file).ToList()
+ };
+ }).OrderByDescending(t => t.tsk.CreatedTime).ToList();
+
- list = mblnoList.Select((mbl,idx) => {
+ list = mblnoList.Select((mbl, idx) =>
+ {
var calcInfo = new LaraPaperCalcInfo();
+ calcInfo.MBLNo = mbl;
calcInfo.Indx = idx + 1;
+ var files = calcList.FirstOrDefault(t => t.tsk.MBL_NO.Equals(mbl, StringComparison.OrdinalIgnoreCase));
+
+ if (files != null)
+ {
+ calcInfo.DraftNum = files.clist.Select(t => t.FILE_NAME.GetPageNum()).Sum();
+ }
+
+ calcInfo.PaperNum = calcInfo.DraftNum * 3;
return calcInfo;
}).ToList();
@@ -1149,4 +1172,24 @@ namespace Myshipping.Application
}
}
+
+ public static class DraftPaperExtension
+ {
+ public static int GetPageNum(this string Name)
+ {
+ try
+ {
+ if (string.IsNullOrWhiteSpace(Name))
+ return 0;
+
+ string s = Regex.Replace(Name.Substring(Name.LastIndexOf('-') + 1), "\\.[a-zA-Z]+", "");
+
+ return int.Parse(s);
+ }
+ catch(Exception ex)
+ {
+ throw Oops.Bah($"文件名{0} 取页数异常,{1}", Name, ex.Message);
+ }
+ }
+ }
}