学 赵 1 year ago
parent
commit
ab7b2443e6
  1. 139
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/detail.js
  2. 113
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/unable-bk.js
  3. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/unable.js
  4. 16
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/usable.js
  5. 10
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs
  6. 57
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs
  7. 58
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs
  8. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/ImportExcelCommon/ExportImporter.cs

139
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/detail.js

@ -1,73 +1,73 @@
const schema = { export default function (businessType, type) {
title: "通用代码", const schema = {
type: "object", title: "通用代码",
disableSelection: true, type: "object",
properties: { disableSelection: true,
settleBillNum: { properties: {
title: "关联结算单号", settleBillNum: {
type: "string", title: "关联结算单号",
}, type: "string",
billNum: { },
title: "发票分组号", billNum: {
type: "string", title: "发票分组号",
}, type: "string",
settleDate: { },
title: "下线日期", settleDate: {
type: "string", title: "下线日期",
input: "datetime", type: "string",
}, input: "datetime",
invBillNum: { },
title: "发票号", invBillNum: {
type: "string", title: "发票号",
}, type: "string",
lu: { },
title: "客户零件号", lu: {
type: "string", title: "客户零件号",
}, type: "string",
partCode: { },
title: "厂内零件号", partCode: {
type: "string", title: "厂内零件号",
}, type: "string",
materialDesc: { },
title: "零件描述", materialDesc: {
type: "decimal", title: "零件描述",
}, type: "decimal",
pn: { },
title: "标识号", pn: {
type: "string", title: "标识号",
}, type: "string",
qty: { },
title: "结算数量", qty: {
type: "number", title: "结算数量",
}, type: "number",
price: { },
title: "单价", price: {
type: "number", title: "单价",
}, type: "number",
groupNum: { },
title: "结算分组号", groupNum: {
type: "decimal", title: "结算分组号",
}, type: "decimal",
site: { },
title: "工厂地点", site: {
type: "string", title: "工厂地点",
}, type: "string",
isReturn: { },
title: "是否退货", isReturn: {
type: "boolean", title: "是否退货",
}, type: "boolean",
isMaidan: { },
title: "是否买单", isMaidan: {
type: "boolean", title: "是否买单",
}, type: "boolean",
contractDocID: { },
title: "合同号", contractDocID: {
type: "string", title: "合同号",
type: "string",
},
}, },
}, };
};
export default function (businessType, type) {
let service; let service;
if (type === "unable") { if (type === "unable") {
if (businessType === "JisBBAC") { if (businessType === "JisBBAC") {
@ -86,6 +86,7 @@ export default function (businessType, type) {
service = "pub_can_sa_service"; service = "pub_can_sa_service";
} }
} }
if (businessType === "JisBBAC" || businessType === "JisHBPO" || businessType === "MaiDanJianBBAC" || businessType === "MaiDanJianHBPO") { if (businessType === "JisBBAC" || businessType === "JisHBPO" || businessType === "MaiDanJianBBAC" || businessType === "MaiDanJianHBPO") {
schema.properties.pn.title = "生产码"; schema.properties.pn.title = "生产码";
} else if (businessType === "ZhiGongJianBBAC" || businessType === "ZhiGongJianHBPO" || businessType === "YinDuJian") { } else if (businessType === "ZhiGongJianBBAC" || businessType === "ZhiGongJianHBPO" || businessType === "YinDuJian") {
@ -207,5 +208,3 @@ export default function (businessType, type) {
}, },
}; };
} }
export { schema };

113
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/settle/unable-bk.js

@ -1,113 +0,0 @@
//不可结算明细
import { version, state } from "../_options.js";
const schema = {
title: "可结算单",
type: "object",
properties: {
version,
state,
billNum: {
title: "结算单据",
type: "string",
oneToMany: "/settle/detail",
config: "/models/settle/detail.js",
},
settleBillNum: {
title: "关联结算单号",
type: "string",
},
invGroupNum: {
title: "发票分组号",
type: "string",
},
},
};
export default function (businessType) {
let service;
if (businessType === "JisBBAC") {
service = "bbac_can_sa_service";
} else if (businessType === "JisHBPO" || businessType === "MaiDanJianHBPO") {
service = "hbpo_can_sa_service";
} else {
service = "pub_can_sa_service";
}
const queryUrl = `settleaccount/${service}/main-query`;
const exportUrl = `settleaccount/${service}/export`;
const addUrl = `settleaccount/${service}/generate-invoice`;
const queryMethod = "POST";
const exportMethod = "POST";
const addMethod = "POST";
return {
query: {
url: queryUrl,
method: queryMethod,
hasFilter: true,
schema: {
title: "发票分组号",
type: "object",
properties: {
filters: {
title: "项目",
type: "array",
hidden: true,
items: {
type: "object",
properties: {
logic: {
type: "int",
},
column: {
type: "string",
},
action: {
type: "int",
},
value: {
type: "string",
},
},
},
default: [
{
logic: "and",
column: "version",
action: "equal",
value: null,
readOnly: true,
},
],
},
skipCount: {
hidden: true,
default: 0,
},
maxResultCount: {
hidden: true,
default: 10,
},
sorting: {
hidden: true,
},
businessType: {
hidden: true,
default: 0,
},
},
},
},
table: {
schema: schema,
},
edit: {
exportUrl,
addUrl,
exportMethod,
addMethod,
schema: schema,
},
};
}

2
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/unable.js

@ -14,6 +14,8 @@ export default {
const route = useRoute(); const route = useRoute();
const businessType = route.meta.businessType; const businessType = route.meta.businessType;
const config = useConfig(businessType, "unable"); const config = useConfig(businessType, "unable");
delete config.table.schema.properties["invBillNum"];
delete config.table.schema.properties["billNum"];
const onCommand = async (item) => { const onCommand = async (item) => {
const url = config.edit.addUrl; const url = config.edit.addUrl;
if (item.path === "add") { if (item.path === "add") {

16
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/usable.js

@ -3,7 +3,7 @@ import html from "html";
import { ref } from "vue"; import { ref } from "vue";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
import useConfig from "../../models/settle/usable.js"; import useConfig from "../../models/settle/usable.js";
import request from "../../request/index.js"; import request, { getUrl } from "../../request/index.js";
export default { export default {
components: { AppList }, components: { AppList },
@ -17,7 +17,19 @@ export default {
const url = config.edit.addUrl; const url = config.edit.addUrl;
if (item.path === "add") { if (item.path === "add") {
const invbillNum = rows[0].billNum; const invbillNum = rows[0].billNum;
await appListRef.value.onClick(async () => await request(url, invbillNum, { method: "POST" }, true), `确认为${invbillNum}创建发票?`, true); await appListRef.value.onClick(
async () => {
const result = await request(url, invbillNum, { method: "POST" }, true);
if (result.errors) {
if (result.data.code === 400 && result.data.fileName) {
window.open(getUrl(`settleaccount/getblobfile/download/${result.data.fileName}`));
}
console.log(result);
}
},
`确认为${invbillNum}创建发票?`,
true
);
} }
}; };
return { appListRef, config, onCommand }; return { appListRef, config, onCommand };

10
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Linq.Dynamic.Core; using System.Linq.Dynamic.Core;
using System.Security.Policy;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using EFCore.BulkExtensions; using EFCore.BulkExtensions;
@ -153,7 +154,6 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
[HttpPost] [HttpPost]
public async Task<PagedResultDto<PUB_SA_DTO>> GetListAsync(PUB_SARequestDto input) public async Task<PagedResultDto<PUB_SA_DTO>> GetListAsync(PUB_SARequestDto input)
{ {
input.Filters.RemoveAll(t => t.Column.ToLower() == "site");
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true).ConfigureAwait(false); var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true).ConfigureAwait(false);
var totalCount = await _repository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false); var totalCount = await _repository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false);
var dtos = ObjectMapper.Map<List<PUB_SA>, List<PUB_SA_DTO>>(entities); var dtos = ObjectMapper.Map<List<PUB_SA>, List<PUB_SA_DTO>>(entities);
@ -451,6 +451,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
EnumBusinessType.YinDuJian => "1040", EnumBusinessType.YinDuJian => "1040",
_ => throw new UserFriendlyException($"业务编码错误", "400") _ => throw new UserFriendlyException($"业务编码错误", "400")
}; };
site = clientCode;
if (businessType == EnumBusinessType.BeiJian) if (businessType == EnumBusinessType.BeiJian)
{ {
@ -526,7 +527,8 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
BillNum = pubSaBillNum, BillNum = pubSaBillNum,
State = "0", State = "0",
BusinessType = pubSaFirstDetail.BusinessType, BusinessType = pubSaFirstDetail.BusinessType,
Version = pubSaFirstDetail.Version Version = pubSaFirstDetail.Version,
Site = site
}; };
//可结算单号 //可结算单号
var pubCanSaBillNum = OrderNumberGenerator.GenerateOrderNumber("C"); var pubCanSaBillNum = OrderNumberGenerator.GenerateOrderNumber("C");
@ -538,13 +540,15 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
SettleBillNum = pubSaBillNum, SettleBillNum = pubSaBillNum,
State = SettleBillState., State = SettleBillState.,
BusinessType = pubSa.BusinessType, BusinessType = pubSa.BusinessType,
Version = pubSa.Version Version = pubSa.Version,
Site = site
}; };
#region 入库数据赋值 #region 入库数据赋值
pubSaDetails.ForEach(pubSaDetail => pubSaDetails.ForEach(pubSaDetail =>
{ {
pubSaDetail.BillNum = pubSaBillNum; pubSaDetail.BillNum = pubSaBillNum;
pubSaDetail.Site = site;
}); });
//不可结算 结算分组号码(根据价格区分结算、不可结算) //不可结算 结算分组号码(根据价格区分结算、不可结算)
var pubNotSaGroupNums = pubSaDetails.FindAll(t => t.Price == default(decimal)).Select(t => t.GroupNum).Distinct(); var pubNotSaGroupNums = pubSaDetails.FindAll(t => t.Price == default(decimal)).Select(t => t.GroupNum).Distinct();

57
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs

@ -80,25 +80,25 @@ public class PriceListAppService : SettleAccountApplicationBase<PriceList>
result = result.FindAll(p => filter.Contains(p.Plant)).ToList(); result = result.FindAll(p => filter.Contains(p.Plant)).ToList();
result.FindAll(t => !string.IsNullOrEmpty(t.ES1) || !string.IsNullOrEmpty(t.ES2)).ForEach(t => t.PartNo = t.PartNo + new string(' ', 6) + t.ES1 + t.ES2); result.FindAll(t => !string.IsNullOrEmpty(t.ES1) || !string.IsNullOrEmpty(t.ES2)).ForEach(t => t.PartNo = t.PartNo + new string(' ', 6) + t.ES1 + t.ES2);
var newPrice = ObjectMapper.Map<List<PriceListImportDto>, List<PriceList>>(result); var newPrice = ObjectMapper.Map<List<PriceListImportDto>, List<PriceList>>(result);
newPrice = newPrice.GroupBy(p => new { p.LU, p.ClientCode, p.BeginTime, p.EndTime }).Select(p => p.FirstOrDefault()).ToList(); newPrice = newPrice.GroupBy(p => new { p.Date, p.ClientCode, p.LU, p.BeginTime, p.EndTime }).Select(p => p.FirstOrDefault()).ToList();
#region 校验 #region 校验
if (newPrice.Any()) if (newPrice.Any())
{ {
var query = from item1 in newPrice var query = from item1 in newPrice
join item2 in newPrice join item2 in newPrice
on new { item1.LU, item1.ClientCode } equals new { item2.LU, item2.ClientCode } on new { item1.Date, item1.ClientCode, item1.LU } equals new { item2.Date, item2.ClientCode, item2.LU }
where (item1.BeginTime > item2.BeginTime && item1.EndTime < item2.EndTime) || (item2.BeginTime > item1.BeginTime && item2.EndTime < item1.EndTime) || (item1.BeginTime == item2.BeginTime && item1.EndTime != item2.EndTime) || (item1.BeginTime != item2.BeginTime && item1.EndTime == item2.EndTime) where (item1.BeginTime > item2.BeginTime && item1.EndTime < item2.EndTime) || (item2.BeginTime > item1.BeginTime && item2.EndTime < item1.EndTime) || (item1.BeginTime == item2.BeginTime && item1.EndTime != item2.EndTime) || (item1.BeginTime != item2.BeginTime && item1.EndTime == item2.EndTime)
select item1.LU; select item1;
var repeat = query.Distinct().ToList(); var repeat = query.Distinct().ToList();
foreach (var item in repeat) foreach (var item in repeat)
{ {
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"导入文件中物料号:{item},时间区间存在交集", string.Empty)); checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"导入文件中物料号:{item.LU},合同签订时间:{item.Date},时间区间存在交集", string.Empty));
} }
foreach (var item in CheckPriceListContinuity(newPrice)) foreach (var item in CheckPriceListContinuity(newPrice))
{ {
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"导入文件中物料号:{item.LU},时间区间【{item.BeginTime}至{item.EndTime}】不连续", string.Empty)); checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"导入文件中物料号:{item.LU},合同签订时间:{item.Date},时间区间【{item.BeginTime}至{item.EndTime}】不连续", string.Empty));
} }
} }
if (checkList.Count > 0) if (checkList.Count > 0)
@ -108,22 +108,30 @@ public class PriceListAppService : SettleAccountApplicationBase<PriceList>
} }
#endregion #endregion
newPrice.ForEach(t => t.IsCancel = true);
newPrice.GroupBy(t => new { t.ClientCode, t.LU })
.SelectMany(t =>
{
var data = t.OrderByDescending(t => t.Date).First().Date;
return t.Where(t => t.Date == data);
})
.ForEach(t => t.IsCancel = false);
var importLus = newPrice.Select(t => t.LU).Distinct().ToList(); var importLus = newPrice.Select(t => t.LU).Distinct().ToList();
var oldPrices = _settleAccountDbContext.Set<PriceList>() var oldPrices = _settleAccountDbContext.Set<PriceList>()
.Where(t => t.IsCancel == false) .Where(t => t.IsCancel == false)
.Where(t => importLus.Contains(t.LU)) .Where(t => importLus.Contains(t.LU))
.ToList(); .ToList();
//系统中合同日期比导入文件中的合同日期晚 //系统中合同日期比导入文件中的合同日期晚
var oldPriceNewDate = from oldprice in oldPrices var oldPriceNewDate = from oldPriceItem in oldPrices
from newprice in newPrice from newPriceItem in newPrice.FindAll(t => t.IsCancel == false)
where oldprice.LU == newprice.LU && oldprice.Date > newprice.Date where oldPriceItem.ClientCode == newPriceItem.ClientCode && oldPriceItem.LU == newPriceItem.LU && oldPriceItem.Date > newPriceItem.Date
select oldprice; select new { oldPriceItem, newPriceItem };
oldPrices.ForEach(t => t.IsCancel = true); oldPrices.ForEach(t => t.IsCancel = true);
if (oldPriceNewDate.Any()) if (oldPriceNewDate.Any())
{ {
oldPrices.FindAll(t => oldPriceNewDate.Contains(t)).ForEach(t => t.IsCancel = false); oldPrices.FindAll(t => t.IsCancel == true && oldPriceNewDate.Select(t => t.oldPriceItem).Contains(t)).ForEach(t => t.IsCancel = false);
var importCancelLus = oldPrices.Select(t => t.LU).Distinct(); newPrice.FindAll(t => t.IsCancel == false && oldPriceNewDate.Select(t => t.newPriceItem).Contains(t)).ForEach(t => t.IsCancel = true);
newPrice.FindAll(t => importCancelLus.Contains(t.LU)).ForEach(t => t.IsCancel = true);
} }
foreach (var item in newPrice) foreach (var item in newPrice)
{ {
@ -155,22 +163,27 @@ public class PriceListAppService : SettleAccountApplicationBase<PriceList>
return priceList; // 只有一个或零个价格条目 return priceList; // 只有一个或零个价格条目
} }
var clientCodeGroup = priceList.GroupBy(t => t.ClientCode); var dateGroups = priceList.GroupBy(t => t.Date);
foreach (var item in clientCodeGroup) foreach (var dateGroup in dateGroups)
{ {
if (item.ToList().Count <= 1) var clientCodeGroups = dateGroup.GroupBy(t => t.ClientCode);
{ foreach (var clientCodeGroup in clientCodeGroups)
continue;
}
var sortedList = item.OrderBy(t => t.LU).ThenBy(t => t.BeginTime).ToList();
for (var i = 1; i < sortedList.Count; i++)
{ {
if (sortedList[i].LU == sortedList[i - 1].LU && sortedList[i].BeginTime != sortedList[i - 1].EndTime.AddDays(1)) if (clientCodeGroup.ToList().Count <= 1)
{ {
result.Add(sortedList[i]); continue;
}
var sortedList = clientCodeGroup.OrderBy(t => t.LU).ThenBy(t => t.BeginTime).ToList();
for (var i = 1; i < sortedList.Count; i++)
{
if (sortedList[i].LU == sortedList[i - 1].LU && sortedList[i].BeginTime != sortedList[i - 1].EndTime.AddDays(1))
{
result.Add(sortedList[i]);
}
} }
} }
} }
return result; // 所有价格时间都连续 return result; // 所有价格时间都连续
} }

58
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs

@ -63,25 +63,25 @@ public class PriceListAppServiceBJ : SettleAccountApplicationBase<PriceListBJ>
result = result.Where(p => filter.Contains(p.Plant)).ToList(); result = result.Where(p => filter.Contains(p.Plant)).ToList();
result.FindAll(t => !string.IsNullOrEmpty(t.ES1) || !string.IsNullOrEmpty(t.ES2)).ForEach(t => t.PartNo = t.PartNo + new string(' ', 6) + t.ES1 + t.ES2); result.FindAll(t => !string.IsNullOrEmpty(t.ES1) || !string.IsNullOrEmpty(t.ES2)).ForEach(t => t.PartNo = t.PartNo + new string(' ', 6) + t.ES1 + t.ES2);
var newPrice = ObjectMapper.Map<List<PriceListBJImportDto>, List<PriceListBJ>>(result); var newPrice = ObjectMapper.Map<List<PriceListBJImportDto>, List<PriceListBJ>>(result);
newPrice = newPrice.GroupBy(p => new { p.LU, p.BeginDate, p.EndDate }).Select(p => p.FirstOrDefault()).ToList(); newPrice = newPrice.GroupBy(p => new { p.Date, p.ClientCode, p.LU, p.BeginDate, p.EndDate }).Select(p => p.FirstOrDefault()).ToList();
#region 校验 #region 校验
if (newPrice.Any()) if (newPrice.Any())
{ {
var query = from item1 in newPrice var query = from item1 in newPrice
join item2 in newPrice join item2 in newPrice
on item1.LU equals item2.LU on new { item1.Date, item1.ClientCode, item1.LU } equals new { item2.Date, item2.ClientCode, item2.LU }
where (item1.BeginDate > item2.BeginDate && item1.EndDate < item2.EndDate) || (item2.BeginDate > item1.BeginDate && item2.EndDate < item1.EndDate) || (item1.BeginDate == item2.BeginDate && item1.EndDate != item2.EndDate) || (item1.BeginDate != item2.BeginDate && item1.EndDate == item2.EndDate) where (item1.BeginDate > item2.BeginDate && item1.EndDate < item2.EndDate) || (item2.BeginDate > item1.BeginDate && item2.EndDate < item1.EndDate) || (item1.BeginDate == item2.BeginDate && item1.EndDate != item2.EndDate) || (item1.BeginDate != item2.BeginDate && item1.EndDate == item2.EndDate)
select item1.LU; select item1;
var repeat = query.Distinct().ToList(); var repeat = query.Distinct().ToList();
foreach (var item in repeat) foreach (var item in repeat)
{ {
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"导入文件中物料号:{item},时间区间存在交集", string.Empty)); checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"导入文件中物料号:{item.LU},合同签订时间:{item.Date},时间区间存在交集", string.Empty));
} }
foreach (var item in CheckPriceListContinuity(newPrice)) foreach (var item in CheckPriceListContinuity(newPrice))
{ {
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"导入文件中物料号:{item.LU},时间区间【{item.BeginDate}至{item.EndDate}】不连续", string.Empty)); checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"导入文件中物料号:{item.LU},合同签订时间:{item.Date},时间区间【{item.BeginDate}至{item.EndDate}】不连续", string.Empty));
} }
} }
if (checkList.Count > 0) if (checkList.Count > 0)
@ -91,22 +91,30 @@ public class PriceListAppServiceBJ : SettleAccountApplicationBase<PriceListBJ>
} }
#endregion #endregion
newPrice.ForEach(t => t.IsCancel = true);
newPrice.GroupBy(t => new { t.ClientCode, t.LU })
.SelectMany(t =>
{
var data = t.OrderByDescending(t => t.Date).First().Date;
return t.Where(t => t.Date == data);
})
.ForEach(t => t.IsCancel = false);
var importLus = newPrice.Select(t => t.LU).Distinct().ToList(); var importLus = newPrice.Select(t => t.LU).Distinct().ToList();
var oldPrices = _settleAccountDbContext.Set<PriceListBJ>() var oldPrices = _settleAccountDbContext.Set<PriceListBJ>()
.Where(t => t.IsCancel == false) .Where(t => t.IsCancel == false)
.Where(t => importLus.Contains(t.LU)) .Where(t => importLus.Contains(t.LU))
.ToList(); .ToList();
//系统中合同日期比导入文件中的合同日期晚 //系统中合同日期比导入文件中的合同日期晚
var oldPriceNewDate = from oldprice in oldPrices var oldPriceNewDate = from oldPriceItem in oldPrices
from newprice in newPrice from newPriceItem in newPrice.FindAll(t => t.IsCancel == false)
where oldprice.LU == newprice.LU && oldprice.Date > newprice.Date where oldPriceItem.ClientCode == newPriceItem.ClientCode && oldPriceItem.LU == newPriceItem.LU && oldPriceItem.Date > newPriceItem.Date
select oldprice; select new { oldPriceItem, newPriceItem };
oldPrices.ForEach(t => t.IsCancel = true); oldPrices.ForEach(t => t.IsCancel = true);
if (oldPriceNewDate.Any()) if (oldPriceNewDate.Any())
{ {
oldPrices.FindAll(t => oldPriceNewDate.Contains(t)).ForEach(t => t.IsCancel = false); oldPrices.FindAll(t => t.IsCancel == true && oldPriceNewDate.Select(t => t.oldPriceItem).Contains(t)).ForEach(t => t.IsCancel = false);
var importCancelLus = oldPrices.Select(t => t.LU).Distinct(); newPrice.FindAll(t => t.IsCancel == false && oldPriceNewDate.Select(t => t.newPriceItem).Contains(t)).ForEach(t => t.IsCancel = true);
newPrice.FindAll(t => importCancelLus.Contains(t.LU)).ForEach(t => t.IsCancel = true);
} }
foreach (var item in newPrice) foreach (var item in newPrice)
{ {
@ -139,24 +147,28 @@ public class PriceListAppServiceBJ : SettleAccountApplicationBase<PriceListBJ>
return priceList; // 只有一个或零个价格条目 return priceList; // 只有一个或零个价格条目
} }
var clientCodeGroup = priceList.GroupBy(t => t.ClientCode); var dateGroups = priceList.GroupBy(t => t.Date);
foreach (var item in clientCodeGroup) foreach (var dateGroup in dateGroups)
{ {
if (item.ToList().Count <= 1) var clientCodeGroups = dateGroup.GroupBy(t => t.ClientCode);
{ foreach (var clientCodeGroup in clientCodeGroups)
continue;
}
var sortedList = item.OrderBy(t => t.LU).ThenBy(t => t.BeginDate).ToList();
for (var i = 1; i < sortedList.Count; i++)
{ {
if (sortedList[i].LU == sortedList[i - 1].LU && sortedList[i].BeginDate != sortedList[i - 1].EndDate.AddDays(1)) if (clientCodeGroup.ToList().Count <= 1)
{
continue;
}
var sortedList = clientCodeGroup.OrderBy(t => t.LU).ThenBy(t => t.BeginDate).ToList();
for (var i = 1; i < sortedList.Count; i++)
{ {
result.Add(sortedList[i]); if (sortedList[i].LU == sortedList[i - 1].LU && sortedList[i].BeginDate != sortedList[i - 1].EndDate.AddDays(1))
{
result.Add(sortedList[i]);
}
} }
} }
} }
return result; return result; // 所有价格时间都连续
} }
/// <summary> /// <summary>

4
code/src/Modules/SettleAccount/src/SettleAccount.Application/ImportExcelCommon/ExportImporter.cs

@ -52,6 +52,10 @@ namespace Win.Sfs.SettleAccount.ExcelImporter
public virtual async Task<List<T>> UploadExcelImport<T>([FromForm] IFormFileCollection files, IExcelImportAppService _excelImportService) public virtual async Task<List<T>> UploadExcelImport<T>([FromForm] IFormFileCollection files, IExcelImportAppService _excelImportService)
where T : class, new() where T : class, new()
{ {
if (files.Count > 1)
{
throw new UserFriendlyException("只能上传一个附件!", "400");
}
using var fs = ServiceProvider.CreateScope(); using var fs = ServiceProvider.CreateScope();
var fc = fs.ServiceProvider.GetRequiredService<IBlobContainer<MyFileContainer>>(); var fc = fs.ServiceProvider.GetRequiredService<IBlobContainer<MyFileContainer>>();
Type type = typeof(T).GetType(); Type type = typeof(T).GetType();

Loading…
Cancel
Save