学 赵
1 year ago
15 changed files with 238 additions and 469 deletions
@ -0,0 +1,112 @@ |
|||||
|
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") { |
||||
|
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, |
||||
|
}, |
||||
|
}; |
||||
|
} |
@ -1,19 +1,37 @@ |
|||||
import AppList from "../../components/list/index.js"; |
import AppList from "../../components/list/index.js"; |
||||
import html from "html"; |
import html from "html"; |
||||
|
import { ref } from "vue"; |
||||
import { useRoute } from "vue-router"; |
import { useRoute } from "vue-router"; |
||||
|
import { ElMessageBox } from "element-plus"; |
||||
import useConfig from "../../models/settle/detail.js"; |
import useConfig from "../../models/settle/detail.js"; |
||||
|
import request from "../../request/index.js"; |
||||
|
|
||||
export default { |
export default { |
||||
components: { AppList }, |
components: { AppList }, |
||||
template: html`<app-list :config="config" @command="onCommand" />`, |
template: html`<app-list ref="appListRef" :config="config" @command="onCommand" />`, |
||||
setup() { |
setup() { |
||||
|
const appListRef = ref(null); |
||||
const route = useRoute(); |
const route = useRoute(); |
||||
const businessType = route.meta.businessType; |
const businessType = route.meta.businessType; |
||||
const config = useConfig(businessType); |
const config = useConfig(businessType, "unable"); |
||||
const onCommand = async (item, rows) => { |
const onCommand = async (item, rows) => { |
||||
|
const url = config.edit.addUrl; |
||||
if (item.path === "add") { |
if (item.path === "add") { |
||||
|
try { |
||||
|
await ElMessageBox.confirm(`确认是否对所有符合查询条件的数据生成可结算单?`, "提示", { |
||||
|
type: "warning", |
||||
|
}); |
||||
|
appListRef.value.tableLoading = true; |
||||
|
const data = appListRef.value.buildQuery(); |
||||
|
const result = request(url, data, { method: "POST" }); |
||||
|
console.log(result); |
||||
|
} catch (e) { |
||||
|
console.log(e); |
||||
|
} finally { |
||||
|
appListRef.value.tableLoading = false; |
||||
|
} |
||||
} |
} |
||||
}; |
}; |
||||
return { config, onCommand }; |
return { appListRef, config, onCommand }; |
||||
}, |
}, |
||||
}; |
}; |
||||
|
@ -1,195 +0,0 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Linq; |
|
||||
using System.Linq.Expressions; |
|
||||
using System.Threading.Tasks; |
|
||||
using Coravel.Invocable; |
|
||||
using Microsoft.AspNetCore.Authorization; |
|
||||
using Microsoft.AspNetCore.Mvc; |
|
||||
using SettleAccount.Domain.BQ; |
|
||||
using Volo.Abp.Application.Services; |
|
||||
using Win.Sfs.SettleAccount.Entities.BQ.Managers; |
|
||||
using Win.Sfs.SettleAccount.Entities.BQ.Vmi; |
|
||||
using Win.Sfs.SettleAccount.EntityFrameworkCore; |
|
||||
using Win.Sfs.SettleAccount.MaterialRelationships; |
|
||||
using Win.Sfs.Shared.RepositoryBase; |
|
||||
|
|
||||
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// HBPO发运数据同步
|
|
||||
/// </summary>
|
|
||||
[AllowAnonymous] |
|
||||
[Route("api/settleaccount/[controller]/[action]")]
|
|
||||
public class BBACSeSyncAppService : ApplicationService, IInvocable, IJobService |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// WMS数据上下文
|
|
||||
/// </summary>
|
|
||||
private readonly WMSBJBMPTDbContext _wmsBJBMPTContext; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 同步位置标记
|
|
||||
/// </summary>
|
|
||||
private readonly INormalEfCoreRepository<SyncPositionFlag, Guid> _syncPositionFlagRepository; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// HBPO发运数据仓储
|
|
||||
/// </summary>
|
|
||||
private readonly INormalEfCoreRepository<BBAC_SE_DETAIL, Guid> _bbacSeDetailRepository; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 客户零件关系领域
|
|
||||
/// </summary>
|
|
||||
private readonly MaterialRelationshipManager _materialRelationshipManager; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 客户零件关系集合
|
|
||||
/// </summary>
|
|
||||
private List<MaterialRelationship> _addMaterialRelationships; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 构造
|
|
||||
/// </summary>
|
|
||||
public BBACSeSyncAppService( |
|
||||
WMSBJBMPTDbContext wmsBJBMPTContext, |
|
||||
INormalEfCoreRepository<SyncPositionFlag, Guid> syncPositionFlagRepository, |
|
||||
INormalEfCoreRepository<BBAC_SE_DETAIL, Guid> bbacSeDetailRepository, |
|
||||
MaterialRelationshipManager materialRelationshipManager) |
|
||||
{ |
|
||||
_wmsBJBMPTContext = wmsBJBMPTContext; |
|
||||
_syncPositionFlagRepository = syncPositionFlagRepository; |
|
||||
_bbacSeDetailRepository = bbacSeDetailRepository; |
|
||||
_materialRelationshipManager = materialRelationshipManager; |
|
||||
_addMaterialRelationships = new List<MaterialRelationship>(); |
|
||||
} |
|
||||
|
|
||||
[ApiExplorerSettings(IgnoreApi = true)] |
|
||||
public async Task Invoke(IServiceProvider serviceProvider) |
|
||||
{ |
|
||||
await this.Invoke().ConfigureAwait(false); |
|
||||
} |
|
||||
|
|
||||
[HttpPost] |
|
||||
public async Task Invoke() |
|
||||
{ |
|
||||
await SyncJitRecordAsync().ConfigureAwait(false); |
|
||||
await SyncJisRecordAsync().ConfigureAwait(false); |
|
||||
if (_addMaterialRelationships.Any()) |
|
||||
{ |
|
||||
_addMaterialRelationships = _addMaterialRelationships.Where(t => !string.IsNullOrEmpty(t.ErpMaterialCode)).GroupBy(t => new { t.ErpMaterialCode }).Select(t => t.First()).ToList(); |
|
||||
await _materialRelationshipManager.AddNewMaterialRelationships(_addMaterialRelationships).ConfigureAwait(false); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 同步JitRecord
|
|
||||
/// </summary>
|
|
||||
private async Task SyncJitRecordAsync() |
|
||||
{ |
|
||||
//同步表名称
|
|
||||
var syncTableName = "JisBBACSeSync_Jit"; |
|
||||
//BBAC类型集合
|
|
||||
var EnumDeliverSubBillTypes = GetDeliverSubBillTypes(); |
|
||||
|
|
||||
Expression<Func<TM_BJBMPT_JIT_RECORD, bool>> predicate = (t) => t.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && EnumDeliverSubBillTypes.Contains(t.DeliverSubBillType); |
|
||||
var syncPositionFlag = await _syncPositionFlagRepository.FindAsync(t => t.TableName == syncTableName).ConfigureAwait(false); |
|
||||
if (syncPositionFlag != null) |
|
||||
{ |
|
||||
predicate = (t) => t.UID > int.Parse(syncPositionFlag.Position) && t.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && EnumDeliverSubBillTypes.Contains(t.DeliverSubBillType); |
|
||||
} |
|
||||
|
|
||||
//WMS发运记录
|
|
||||
var wmsSeRecords = _wmsBJBMPTContext.TM_BJBMPT_JIT_RECORD.Where(predicate).OrderBy(b => b.UID).Take(100000).ToList(); |
|
||||
|
|
||||
var bbacSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIT_RECORD>, List<BBAC_SE_DETAIL>>(wmsSeRecords); |
|
||||
if (bbacSeDetails.Any()) |
|
||||
{ |
|
||||
//客户零件号和厂内零件号
|
|
||||
var materialRelationships = bbacSeDetails.GroupBy(t => new { t.LU, t.PartCode }).Select(t => new MaterialRelationship(GuidGenerator.Create(), t.Key.LU, "", t.Key.PartCode, "")); |
|
||||
_addMaterialRelationships.AddRange(materialRelationships); |
|
||||
|
|
||||
bbacSeDetails.ForEach(bbacSeDetail => |
|
||||
{ |
|
||||
bbacSeDetail.KeyCode = bbacSeDetail.PN + bbacSeDetail.LU; |
|
||||
bbacSeDetail.BusinessType = EnumBusinessType.JisBBAC; |
|
||||
}); |
|
||||
await _bbacSeDetailRepository.InsertManyAsync(bbacSeDetails); |
|
||||
|
|
||||
if (syncPositionFlag != null) |
|
||||
{ |
|
||||
syncPositionFlag.Position = wmsSeRecords.Last().UID.ToString(); |
|
||||
await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag); |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
syncPositionFlag = new SyncPositionFlag() |
|
||||
{ |
|
||||
TableName = syncTableName, |
|
||||
Position = wmsSeRecords.Last().UID.ToString() |
|
||||
}; |
|
||||
await _syncPositionFlagRepository.InsertAsync(syncPositionFlag); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 同步JisRecord
|
|
||||
/// </summary>
|
|
||||
private async Task SyncJisRecordAsync() |
|
||||
{ |
|
||||
//同步表名称
|
|
||||
var syncTableName = "JisBBACSeSync_Jis"; |
|
||||
//BBAC类型集合
|
|
||||
var EnumDeliverSubBillTypes = GetDeliverSubBillTypes(); |
|
||||
Expression<Func<TM_BJBMPT_JIS_RECORD, bool>> predicate = (t) => t.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && EnumDeliverSubBillTypes.Contains(t.DeliverSubBillType); |
|
||||
var syncPositionFlag = await _syncPositionFlagRepository.FindAsync(t => t.TableName == syncTableName); |
|
||||
if (syncPositionFlag != null) |
|
||||
{ |
|
||||
predicate = (t) => t.UID > int.Parse(syncPositionFlag.Position) && t.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && EnumDeliverSubBillTypes.Contains(t.DeliverSubBillType); |
|
||||
} |
|
||||
|
|
||||
//WMS发运数据
|
|
||||
var wmsRecords = _wmsBJBMPTContext.TM_BJBMPT_JIS_RECORD.Where(predicate).OrderBy(b => b.UID).Take(100000).ToList(); |
|
||||
|
|
||||
var bbacSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIS_RECORD>, List<BBAC_SE_DETAIL>>(wmsRecords); |
|
||||
if (bbacSeDetails.Any()) |
|
||||
{ |
|
||||
//客户零件号和厂内零件号
|
|
||||
var materialRelationships = bbacSeDetails.GroupBy(t => new { t.LU, t.PartCode }).Select(t => new MaterialRelationship(GuidGenerator.Create(), t.Key.LU, "", t.Key.PartCode, "")); |
|
||||
_addMaterialRelationships.AddRange(materialRelationships); |
|
||||
|
|
||||
bbacSeDetails.ForEach(bbacSeDetail => bbacSeDetail.KeyCode = bbacSeDetail.PN + bbacSeDetail.LU); |
|
||||
await _bbacSeDetailRepository.InsertManyAsync(bbacSeDetails); |
|
||||
|
|
||||
if (syncPositionFlag != null) |
|
||||
{ |
|
||||
syncPositionFlag.Position = wmsRecords.Last().UID.ToString(); |
|
||||
await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag); |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
syncPositionFlag = new SyncPositionFlag() |
|
||||
{ |
|
||||
TableName = syncTableName, |
|
||||
Position = wmsRecords.Last().UID.ToString() |
|
||||
}; |
|
||||
await _syncPositionFlagRepository.InsertAsync(syncPositionFlag); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 获取BBAC类型集合
|
|
||||
/// </summary>
|
|
||||
private List<EnumDeliverSubBillType> GetDeliverSubBillTypes() |
|
||||
{ |
|
||||
return new List<EnumDeliverSubBillType> |
|
||||
{ |
|
||||
EnumDeliverSubBillType.保险杠BBAC, |
|
||||
EnumDeliverSubBillType.买单件保险杠BBAC, |
|
||||
EnumDeliverSubBillType.买单件小件BBAC, |
|
||||
EnumDeliverSubBillType.小件BBAC |
|
||||
}; |
|
||||
} |
|
||||
} |
|
@ -1,225 +0,0 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Linq; |
|
||||
using System.Linq.Dynamic.Core; |
|
||||
using System.Linq.Expressions; |
|
||||
using System.Threading.Tasks; |
|
||||
using Coravel.Invocable; |
|
||||
using Microsoft.AspNetCore.Authorization; |
|
||||
using Microsoft.AspNetCore.Mvc; |
|
||||
using SettleAccount.Domain.BQ; |
|
||||
using Volo.Abp.Application.Services; |
|
||||
using Win.Sfs.SettleAccount.Entities.BQ.Managers; |
|
||||
using Win.Sfs.SettleAccount.Entities.BQ.Vmi; |
|
||||
using Win.Sfs.SettleAccount.EntityFrameworkCore; |
|
||||
using Win.Sfs.SettleAccount.MaterialRelationships; |
|
||||
using Win.Sfs.Shared.RepositoryBase; |
|
||||
|
|
||||
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// HBPO发运数据同步
|
|
||||
/// </summary>
|
|
||||
[AllowAnonymous] |
|
||||
[Route("api/settleaccount/[controller]/[action]")]
|
|
||||
public class HBPOSeSyncAppService : ApplicationService, IInvocable, IJobService |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// WMS数据上下文
|
|
||||
/// </summary>
|
|
||||
private readonly WMSBJBMPTDbContext _wmsBJBMPTContext; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 同步位置标记
|
|
||||
/// </summary>
|
|
||||
private readonly INormalEfCoreRepository<SyncPositionFlag, Guid> _syncPositionFlagRepository; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// HBPO发运数据仓储
|
|
||||
/// </summary>
|
|
||||
private readonly INormalEfCoreRepository<HBPO_SE_DETAIL, Guid> _hbpoSeDetailRepository; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// PUB发运数据仓储
|
|
||||
/// </summary>
|
|
||||
private readonly INormalEfCoreRepository<PUB_SE_DETAIL, Guid> _pubSeDetailRepository; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 客户零件关系领域
|
|
||||
/// </summary>
|
|
||||
private readonly MaterialRelationshipManager _materialRelationshipManager; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 客户零件关系集合
|
|
||||
/// </summary>
|
|
||||
private List<MaterialRelationship> _addMaterialRelationships; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 构造
|
|
||||
/// </summary>
|
|
||||
public HBPOSeSyncAppService( |
|
||||
WMSBJBMPTDbContext wmsBJBMPTContext, |
|
||||
INormalEfCoreRepository<SyncPositionFlag, Guid> syncPositionFlagRepository, |
|
||||
INormalEfCoreRepository<HBPO_SE_DETAIL, Guid> hbpoSeDetailRepository, |
|
||||
INormalEfCoreRepository<PUB_SE_DETAIL, Guid> pubSeDetailRepository, |
|
||||
MaterialRelationshipManager materialRelationshipManager) |
|
||||
{ |
|
||||
_wmsBJBMPTContext = wmsBJBMPTContext; |
|
||||
_syncPositionFlagRepository = syncPositionFlagRepository; |
|
||||
_hbpoSeDetailRepository = hbpoSeDetailRepository; |
|
||||
_pubSeDetailRepository = pubSeDetailRepository; |
|
||||
_materialRelationshipManager = materialRelationshipManager; |
|
||||
_addMaterialRelationships = new List<MaterialRelationship>(); |
|
||||
} |
|
||||
|
|
||||
[ApiExplorerSettings(IgnoreApi = true)] |
|
||||
public async Task Invoke(IServiceProvider serviceProvider) |
|
||||
{ |
|
||||
await this.Invoke().ConfigureAwait(false); |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 执行
|
|
||||
/// </summary>
|
|
||||
[HttpPost] |
|
||||
public async Task Invoke() |
|
||||
{ |
|
||||
await SyncJitRecordAsync().ConfigureAwait(false); |
|
||||
await SyncJisRecordAsync().ConfigureAwait(false); |
|
||||
if (_addMaterialRelationships.Any()) |
|
||||
{ |
|
||||
_addMaterialRelationships = _addMaterialRelationships.Where(t => !string.IsNullOrEmpty(t.ErpMaterialCode)).GroupBy(t => new { t.ErpMaterialCode }).Select(t => t.First()).ToList(); |
|
||||
await _materialRelationshipManager.AddNewMaterialRelationships(_addMaterialRelationships).ConfigureAwait(false); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 同步JitRecord
|
|
||||
/// </summary>
|
|
||||
private async Task SyncJitRecordAsync() |
|
||||
{ |
|
||||
//同步表名称
|
|
||||
var syncTableName = "JisHBPOSeSync_Jit"; |
|
||||
//HBPO类型集合
|
|
||||
var EnumDeliverSubBillTypes = GetDeliverSubBillTypes(); |
|
||||
Expression<Func<TM_BJBMPT_JIT_RECORD, bool>> predicate = (t) => t.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && EnumDeliverSubBillTypes.Contains(t.DeliverSubBillType); |
|
||||
var syncPositionFlag = await _syncPositionFlagRepository.FindAsync(t => t.TableName == syncTableName).ConfigureAwait(false); |
|
||||
if (syncPositionFlag != null) |
|
||||
{ |
|
||||
predicate = (t) => t.UID > int.Parse(syncPositionFlag.Position) && t.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && EnumDeliverSubBillTypes.Contains(t.DeliverSubBillType); |
|
||||
} |
|
||||
|
|
||||
//WMS发运数据
|
|
||||
var wmsSeRecords = _wmsBJBMPTContext.TM_BJBMPT_JIT_RECORD.Where(predicate).OrderBy(b => b.UID).ToList(); |
|
||||
if (wmsSeRecords.Any()) |
|
||||
{ |
|
||||
//JisHBPO发运
|
|
||||
var hbpoWmsSeRecords = wmsSeRecords.FindAll(t => t.DeliverSubBillType == EnumDeliverSubBillType.保险杠HBPO || t.DeliverSubBillType == EnumDeliverSubBillType.小件HBPO); |
|
||||
//买单件HBPO发运
|
|
||||
var maiDanHBPOWmsSeRecords = wmsSeRecords.FindAll(t => t.DeliverSubBillType == EnumDeliverSubBillType.买单件保险杠HBPO || t.DeliverSubBillType == EnumDeliverSubBillType.买单件小件HBPO); |
|
||||
|
|
||||
var hbpoSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIT_RECORD>, List<HBPO_SE_DETAIL>>(hbpoWmsSeRecords); |
|
||||
var maiDanHBPOSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIT_RECORD>, List<PUB_SE_DETAIL>>(maiDanHBPOWmsSeRecords); |
|
||||
|
|
||||
await SaveSeDataAsync(hbpoSeDetails, maiDanHBPOSeDetails).ConfigureAwait(false); |
|
||||
|
|
||||
if (syncPositionFlag != null) |
|
||||
{ |
|
||||
syncPositionFlag.Position = wmsSeRecords.Last().UID.ToString(); |
|
||||
await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag).ConfigureAwait(false); |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
syncPositionFlag = new SyncPositionFlag() |
|
||||
{ |
|
||||
TableName = syncTableName, |
|
||||
Position = wmsSeRecords.Last().UID.ToString() |
|
||||
}; |
|
||||
await _syncPositionFlagRepository.InsertAsync(syncPositionFlag).ConfigureAwait(false); ; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 同步JisRecord
|
|
||||
/// </summary>
|
|
||||
private async Task SyncJisRecordAsync() |
|
||||
{ |
|
||||
//同步表名称
|
|
||||
var syncTableName = "JisHBPOSeSync_Jis"; |
|
||||
//BBAC类型集合
|
|
||||
var EnumDeliverSubBillTypes = GetDeliverSubBillTypes(); |
|
||||
Expression<Func<TM_BJBMPT_JIS_RECORD, bool>> predicate = (t) => t.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && EnumDeliverSubBillTypes.Contains(t.DeliverSubBillType); |
|
||||
var syncPositionFlag = await _syncPositionFlagRepository.FindAsync(t => t.TableName == syncTableName).ConfigureAwait(false); |
|
||||
if (syncPositionFlag != null) |
|
||||
{ |
|
||||
predicate = (t) => t.UID > int.Parse(syncPositionFlag.Position) && t.DeliverBillType == EnumDeliverBjBmpBillType.JIS件 && EnumDeliverSubBillTypes.Contains(t.DeliverSubBillType); |
|
||||
} |
|
||||
|
|
||||
//WMS发运数据
|
|
||||
var wmsSeRecords = _wmsBJBMPTContext.TM_BJBMPT_JIS_RECORD.Where(predicate).OrderBy(b => b.UID).ToList(); |
|
||||
if (wmsSeRecords.Any()) |
|
||||
{ |
|
||||
//JisHBPO发运
|
|
||||
var hbpoWmsSeRecords = wmsSeRecords.FindAll(t => t.DeliverSubBillType == EnumDeliverSubBillType.保险杠HBPO || t.DeliverSubBillType == EnumDeliverSubBillType.小件HBPO); |
|
||||
//买单件HBPO发运
|
|
||||
var maiDanHBPOWmsSeRecords = wmsSeRecords.FindAll(t => t.DeliverSubBillType == EnumDeliverSubBillType.买单件保险杠HBPO || t.DeliverSubBillType == EnumDeliverSubBillType.买单件小件HBPO); |
|
||||
|
|
||||
var hbpoSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIS_RECORD>, List<HBPO_SE_DETAIL>>(hbpoWmsSeRecords); |
|
||||
var maiDanHBPOSeDetails = ObjectMapper.Map<List<TM_BJBMPT_JIS_RECORD>, List<PUB_SE_DETAIL>>(maiDanHBPOWmsSeRecords); |
|
||||
|
|
||||
await SaveSeDataAsync(hbpoSeDetails, maiDanHBPOSeDetails).ConfigureAwait(false); |
|
||||
|
|
||||
if (syncPositionFlag != null) |
|
||||
{ |
|
||||
syncPositionFlag.Position = wmsSeRecords.Last().UID.ToString(); |
|
||||
await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag).ConfigureAwait(false); |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
syncPositionFlag = new SyncPositionFlag() |
|
||||
{ |
|
||||
TableName = syncTableName, |
|
||||
Position = wmsSeRecords.Last().UID.ToString() |
|
||||
}; |
|
||||
await _syncPositionFlagRepository.InsertAsync(syncPositionFlag).ConfigureAwait(false); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 获取HBPO类型集合
|
|
||||
/// </summary>
|
|
||||
private List<EnumDeliverSubBillType> GetDeliverSubBillTypes() |
|
||||
{ |
|
||||
return new List<EnumDeliverSubBillType> |
|
||||
{ |
|
||||
EnumDeliverSubBillType.保险杠HBPO, |
|
||||
EnumDeliverSubBillType.买单件保险杠HBPO, |
|
||||
EnumDeliverSubBillType.买单件小件HBPO, |
|
||||
EnumDeliverSubBillType.小件HBPO |
|
||||
}; |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 保存发运树
|
|
||||
/// </summary>
|
|
||||
private async Task SaveSeDataAsync(List<HBPO_SE_DETAIL> hbpoSeDetails, List<PUB_SE_DETAIL> maiDanHBPOSeDetails) |
|
||||
{ |
|
||||
//客户零件号和厂内零件号
|
|
||||
var hbpoSeLuRePartCodes = hbpoSeDetails.Select(t => new { t.LU, t.PartCode }); |
|
||||
var maiDanHBPOSeLuRePartCodes = maiDanHBPOSeDetails.Select(t => new { t.LU, t.PartCode }); |
|
||||
var luRePartCodes = hbpoSeLuRePartCodes.Union(maiDanHBPOSeLuRePartCodes); |
|
||||
var materialRelationships = luRePartCodes.GroupBy(t => new { t.LU, t.PartCode }).Select(t => new MaterialRelationship(GuidGenerator.Create(), t.Key.LU, "", t.Key.PartCode, "")); |
|
||||
_addMaterialRelationships.AddRange(materialRelationships); |
|
||||
|
|
||||
hbpoSeDetails.ForEach(hbpoSeDetail => hbpoSeDetail.KeyCode = hbpoSeDetail.PN + hbpoSeDetail.LU); |
|
||||
maiDanHBPOSeDetails.ForEach(maiDanHBPOSeDetail => |
|
||||
{ |
|
||||
maiDanHBPOSeDetail.KeyCode = maiDanHBPOSeDetail.PN + maiDanHBPOSeDetail.LU; |
|
||||
maiDanHBPOSeDetail.BusinessType = EnumBusinessType.MaiDanJianHBPO; |
|
||||
}); |
|
||||
await _hbpoSeDetailRepository.InsertManyAsync(hbpoSeDetails).ConfigureAwait(false); |
|
||||
await _pubSeDetailRepository.InsertManyAsync(maiDanHBPOSeDetails).ConfigureAwait(false); |
|
||||
} |
|
||||
} |
|
Loading…
Reference in new issue