mahao 1 year ago
parent
commit
302aa3b77b
  1. 18
      code/WebApp/vue3/package-lock.json
  2. 4
      code/WebApp/vue3/package.json
  3. 3
      code/WebApp/vue3/src/main.js
  4. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccount.HttpApi.Host.csproj
  5. 10
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json
  6. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/start.cmd
  7. 1
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js
  8. 1
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/index.html
  9. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/lib/element-plus/index.css
  10. 30
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/lib/element-plus/index.full.min.mjs
  11. 5
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/utils/index.js
  12. 17
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/job-item.js
  13. 105
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/invoice/invoice_map_group.js
  14. 100
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs
  15. 392
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs
  16. 380
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs
  17. 358
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs
  18. 357
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs
  19. 13
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobHostdService.cs
  20. 14
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobItemAppService.cs
  21. 330
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs
  22. 14
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs
  23. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_CAN_SA_MNG.cs
  24. 464
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs
  25. 183
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Temp/TempClass.cs
  26. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/IJobService.cs
  27. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/EnumBillState.cs

18
code/WebApp/vue3/package-lock.json

@ -38,7 +38,9 @@
"vue-echarts": "^6.6.0",
"vue-i18n": "^9.2.2",
"vue-router": "^4.2.2",
"wsmock-js": "^1.1.1"
"vxe-table": "^4.5.0-beta.16",
"wsmock-js": "^1.1.1",
"xe-utils": "^3.5.11"
},
"devDependencies": {
"@iconify/json": "^2.2.83",
@ -13223,6 +13225,15 @@
"vue": "^3.2.0"
}
},
"node_modules/vxe-table": {
"version": "4.5.0-beta.16",
"resolved": "https://registry.npmjs.org/vxe-table/-/vxe-table-4.5.0-beta.16.tgz",
"integrity": "sha512-rSChkgl1cIJzEr99WS2YZyqkOm3bqMtD2d2RrCSB3VVepWJe7B7jMYazGi6L32Y0J3ZM8rNOipFyB3W0j96mHA==",
"peerDependencies": {
"vue": "^3.2.28",
"xe-utils": "^3.5.0"
}
},
"node_modules/webpack-sources": {
"version": "3.2.3",
"resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz",
@ -13475,6 +13486,11 @@
"integrity": "sha512-GojqklwG8gpzOVEVki5KudKNoq7MbbjYZCbyWzEz7tyPA7eleiE0+ePwOWQQRb5fm86rD3S8Tc0tSFf3AOv50w==",
"dev": true
},
"node_modules/xe-utils": {
"version": "3.5.11",
"resolved": "https://registry.npmjs.org/xe-utils/-/xe-utils-3.5.11.tgz",
"integrity": "sha512-lyKc/lTBga1Zb63p+FED8mtxLnYIjSS8PVJM1N64NGdCu/3d1XubaVeke2p91RHssP0ExVAl2LUqZYperoz76Q=="
},
"node_modules/xml-name-validator": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-4.0.0.tgz",

4
code/WebApp/vue3/package.json

@ -71,7 +71,9 @@
"vue-echarts": "^6.6.0",
"vue-i18n": "^9.2.2",
"vue-router": "^4.2.2",
"wsmock-js": "^1.1.1"
"vxe-table": "^4.5.0-beta.16",
"wsmock-js": "^1.1.1",
"xe-utils": "^3.5.11"
},
"devDependencies": {
"@iconify/json": "^2.2.83",

3
code/WebApp/vue3/src/main.js

@ -1,7 +1,8 @@
import './style.css';
import { createApp } from 'vue';
import VXETable from 'vxe-table';
import App from './App.vue';
createApp(App).mount('#app');
createApp(App).use(VXETable).mount('#app');

2
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/SettleAccount.HttpApi.Host.csproj

@ -11,7 +11,7 @@
<DockerfileContext>..\..\..\..</DockerfileContext>
<TargetFramework>net5.0</TargetFramework>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<SatelliteResourceLanguages>en;zh-Hans</SatelliteResourceLanguages>
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>

10
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json

@ -69,7 +69,7 @@
"AuthServer": {
"Authority": "http://*:10582",
"Authority": "http://localhost:10582",
"ClientId": "basic-web",
"ClientSecret": "1q2w3e*"
},
@ -79,11 +79,5 @@
},
"DefaultBranchId": "3FA85F64-5717-4562-B3FC-2C963F66AFA6",
"AllowedHosts": "*",
"ElasticSearch": {
"Url": "http://localhost:9200"
}
"AllowedHosts": "*"
}

2
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/start.cmd

@ -8,4 +8,4 @@ if %errorlevel% == 0 (
%1 start mshta vbscript:createobject("wscript.shell").run("""%~0"" ::",0)(window.close)&&exit
start /b SettleAccount.HttpApi.Host.exe --urls http://dev.ccwin-in.com:10582
start /b SettleAccount.HttpApi.Host.exe --urls http://*:10582

1
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/components/list/index.js

@ -865,7 +865,6 @@ export default {
await load();
}
});
context.expose({ load });
return {
load,
config,

1
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/index.html

@ -64,6 +64,7 @@
"nprogress": "./lib/nprogress/nprogress.vite-esm.js",
"echarts/core": "./lib/echarts/echarts.esm.min.js",
"vue-echarts": "./lib/vue-echarts/index.esm.min.js",
"xe-echarts": "./lib/vue-echarts/index.esm.min.js",
"resize-detector": "./lib/resize-detector/index.js",
"@vue-office/excel": "./lib/@vue-office/excel/vue-office-excel.mjs",
"@vue/devtools-api": "./lib/@vue/devtools-api/shim.js",

2
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/lib/element-plus/index.css

File diff suppressed because one or more lines are too long

30
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/lib/element-plus/index.full.min.mjs

File diff suppressed because one or more lines are too long

5
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/utils/index.js

@ -1,5 +1,9 @@
import { get } from "lodash";
async function delay(ms) {
return new Promise((resolve, _) => setTimeout(resolve, ms));
}
// format html`...` by vscode lit-html
function html(strings, ...values) {
let output = "";
@ -135,6 +139,7 @@ async function importFunction(input) {
export default html;
export {
delay,
persentFormat,
bytesFormat,
format,

17
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/base-data/job-item.js

@ -1,15 +1,14 @@
import AppList from "../../components/list/index.js";
import html from "html";
import useConfig from "../../models/job-item.js";
import { defineAsyncComponent, ref, reactive, onMounted, watch } from "vue";
import { ref, nextTick, onMounted, onUnmounted } from "vue";
import useConfig2 from "../../models/job-log.js";
export default {
components: { AppList },
template: html`<app-list :config="config" @command="onCommand" ref="appListRef" />`,
template: html`<app-list v-if="refresh" :config="config" @command="onCommand" />`,
setup() {
const config = useConfig();
const appListRef = ref(null);
const onCommand = async (item, rows, showList) => {
console.log(item.path, item, rows);
console.log(showList);
@ -17,6 +16,16 @@ export default {
config.query.schema.properties.filters.default[0].value = rows[0].id;
showList({ test: "test" }, "/base-data/job-log", config);
};
return { config, onCommand };
const refresh = ref(true);
onMounted(async () => {
PubSub.subscribe("JobItem", () => {
refresh.value = false;
nextTick(() => (refresh.value = true));
});
});
onUnmounted(() => {
PubSub.unsubscribe(onMonitor);
});
return { config, onCommand, refresh };
},
};

105
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/invoice/invoice_map_group.js

@ -1,15 +1,114 @@
import AppList from "../../../components/list/index.js";
import html from "html";
import { ref } from "vue";
import { delay } from "../../../utils/index.js";
import useConfig from "../../../models/invoice/invoice_map_group.js";
import request from "../../../request/index.js";
export default {
components: { AppList },
template: html`<app-list :config="config" @command="onCommand" />`,
template: html`<app-list :config="config" @command="onCommand" />
<el-drawer v-model="drawer" destroy-on-close size="50%" class="page-drawer">
<template #header> <span class="el-dialog__title"> INVOICE_GRP_DETAIL_DTO </span> </template>
<el-row v-loading="loading">
<el-col style="height:calc(100vh - 180px);">
<el-tabs style="width:100%;height:100%;" v-if="drawer&&!loading">
<el-tab-pane label="invoicE_WAIT_DETAIL" v-if="model.invoicE_WAIT_DETAIL.length">
<el-auto-resizer>
<template #default="{ height, width }">
<el-table-v2
fixed
:data="model.invoicE_WAIT_DETAIL"
:columns="columns1"
:width="width"
:height="height"
/>
</template>
</el-auto-resizer>
</el-tab-pane>
<el-tab-pane label="invoicE_MAP_GROUP" v-if="model.invoicE_MAP_GROUP.length">
<el-auto-resizer>
<template #default="{ height, width }">
<el-table-v2
fixed
:data="model.invoicE_MAP_GROUP"
:columns="columns2"
:width="width"
:height="height"
/>
</template>
</el-auto-resizer>
</el-tab-pane>
<el-tab-pane label="invoicE_NOT_SETTLE" v-if="model.invoicE_NOT_SETTLE.length">
<el-auto-resizer>
<template #default="{ height, width }">
<el-table-v2
fixed
:data="model.invoicE_NOT_SETTLE"
:columns="columns3"
:width="width"
:height="height"
/>
</template>
</el-auto-resizer>
</el-tab-pane>
</el-tabs>
</el-col>
</el-row>
<template #footer>
<span class="dialog-footer">
<el-button type="primary" @click="drawer=false"> {{$t('confirm')}} </el-button>
</span>
</template>
</el-drawer>`,
styles: html` <style>
.page-drawer .el-tab-pane {
width: 100%;
height: 100%;
}
.page-drawer .el-tabs__content {
height: calc(100% - 40px);
}
</style>`,
setup() {
const config = useConfig();
const drawer = ref(false);
const loading = ref(false);
const model = ref({
invoicE_WAIT_DETAIL: [{ version: "version" }],
invoicE_MAP_GROUP: [{ version: "version" }],
invoicE_NOT_SETTLE: [{ version: "version" }],
});
const onCommand = async (item, rows) => {
console.log(item.path, item, rows);
drawer.value = true;
loading.value = true;
const data = { [item.path]: rows[0][item.path] };
// const response = await request("settleaccount/b-bAC_BA_SERVICE/detail-query", data, { method: "POST" });
// model.value = response.data;
await delay(1000);
loading.value = false;
};
return { config, onCommand };
const columns1 = [
{
key: "version",
dataKey: "version",
title: "期间",
},
];
const columns2 = [
{
dataKey: "version",
title: "期间",
},
];
const columns3 = [
{
dataKey: "version",
title: "期间",
},
];
return { config, onCommand, drawer, loading, model, columns1, columns2, columns3 };
},
};

100
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs

@ -26,6 +26,8 @@ using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.Entities.BQ.Temp;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.SettleAccount.Migrations;
@ -34,7 +36,9 @@ using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Bases
{
public abstract class BA_SERVICE: BASE_SERVICE
public abstract class BA_SERVICE
: BASE_SERVICE
{
protected readonly INormalEfCoreRepository<INVOICE_GRP, Guid> _repository;
protected readonly INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> _wRepository;
@ -223,10 +227,7 @@ namespace Win.Sfs.SettleAccount.Bases
await _invMng.SetForwardState(entity, SettleBillState.);
}
}
return ApplicationConsts.SuccessStr;
}
protected virtual async Task<List<INVOICE_MAP_GROUP_DTO>> GetMapGroupAsync(INVOICE_GRP_REQ_DTO input)
{
@ -300,8 +301,99 @@ namespace Win.Sfs.SettleAccount.Bases
return null;
}
/// <summary>
/// hbpo、jit、备件等
/// </summary>
/// <param name="dtos">可结算明细列表</param>
/// <param name="p_version">版本号</param>
/// <param name="p_InvGroupNum">发票分组</param>
/// <param name="p_parentInvBillNum">原发票号</param>
protected async Task<bool> ReissueSecInvoice(List<TEMP_CAN_SA_DETAIL> p_list, int p_version, string p_parentInvBillNum)
{
return await _invMng.ReissueSecInvoice(p_list,p_parentInvBillNum, p_version);
}
/// <summary>
/// 第一次开票
/// </summary>
/// <param name="dtos"></param>
/// <param name="p_notlist"></param>
/// <param name="p_version"></param>
/// <param name="p_InvGroupNum"></param>
/// <param name="p_parentInvBillNum">要作废的发票号</param>
/// <param name="businessType"></param>
/// <returns></returns>
protected async Task<bool> ReissueFirstInvoice(List<TEMP_CAN_SA_DETAIL> dtos,int p_version, string p_parentInvBillNum)
{
return await _invMng.ReissueFirstInvoice(dtos,p_parentInvBillNum,p_version);
}
/// <summary>
/// 校验规则
/// </summary>
/// <param name="dto1s"></param>
/// <param name="p_pricelist"></param>
/// <returns></returns>
protected async Task<List<ERR_EXP_DTO>> CheckInvoiceGenerationRules<T>(List<T> dto1s, List<PriceList> p_pricelist, EnumBusinessType p_businessType) where T : SA_CAN_BASE
{
var inner = from d in dto1s
join p in p_pricelist on d.LU equals p.LU
where
d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime
select d;
var left = from d in dto1s
join p in inner on new { d.LU, d.PN } equals new { p.LU, p.PN }
into temp
from tm in temp.DefaultIfEmpty()//校验错误项
where tm == null
select d;
List<ERR_EXP_DTO> errorList = new List<ERR_EXP_DTO>();
string name = string.Empty;
string keyname = string.Empty;
switch (p_businessType)
{
case EnumBusinessType.MaiDanJianHBPO:
name = "HBPO买单件";
keyname = "生产码";
break;
case EnumBusinessType.ZhiGongJianHBPO:
name = "HBPO直供件";
keyname = "发货单号";
break;
case EnumBusinessType.ZhiGongJianBBAC:
name = "BBAC直供件";
keyname = "发货单号";
break;
case EnumBusinessType.YinDuJian:
name = "HBPO印度件";
keyname = "发货单号";
break;
case EnumBusinessType.JisBBAC:
name = "BBAC-JIS";
keyname = "生产码";
break;
case EnumBusinessType.JisHBPO:
name = "HBPO-JIS";
keyname = "生产码";
break;
case EnumBusinessType.BeiJian:
name = "备件";
keyname = "交付识别号";
break;
}
foreach (var error in left)
{
errorList.Add(new ERR_EXP_DTO() { ItemCode = error.LU, CustomCode = $"{name}", Message = $"LU:{error.LU}{keyname}:{error.PN},下线日期:{error.SettleDate}没有对应区间销售价格表!" });
}
return errorList;
}
}
}

392
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs

@ -1,9 +1,12 @@
using AutoMapper;
using DocumentFormat.OpenXml.Vml.Office;
using EFCore.BulkExtensions;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Csv;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using NUglify.JavaScript.Syntax;
using SettleAccount.Bases;
using SettleAccount.Domain.BQ;
using Shouldly;
@ -27,104 +30,16 @@ using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.Entities.BQ.Temp;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.Shared.RepositoryBase;
using static Win.Sfs.SettleAccount.SettleAccountPermissions;
namespace Win.Sfs.SettleAccount.Bases
{
public class TMEP_INV
{
public string LU { set; get; }
public string ContractDocID { set; get; }
public decimal Amt { set; get; }
public decimal Qty { set; get; }
public decimal Price { set; get; }
/// <summary>
/// 开始日期
/// </summary>
public DateTime BeginDate { get; set; }
/// <summary>
/// 结束日期
/// </summary>
public DateTime EndDate { get; set; }
}
public class TEMP_CAN_SA_DETAIL
{
/// <summary>
///关联结算单号
/// </summary>
public string SettleBillNum { get; set; }
/// <summary>
///工厂地点
/// </summary>
public string Site { get; set; }
/// <summary>
/// 版本
/// </summary>
public int Version { get; set; }
/// <summary>
/// 单价
/// </summary>
public decimal Price { get; set; }
/// <summary>
/// 结算单号(发票分组号)
/// </summary>
public string BillNum { get; set; }
/// <summary>
/// 结算日期
/// </summary>
public DateTime SettleDate { get; set; }
/// <summary>
///发票组号
/// </summary>
public string InvGroupNum { get; set; }
/// <summary>
/// 零件号
/// </summary>
public string LU { get; set; }
/// <summary>
/// 物料描述
/// </summary>
public string MaterialDesc { get; set; }
/// <summary>
/// 生产号
/// </summary>
public string PN { get; set; }
/// <summary>
/// 结算数量
/// </summary>
public decimal Qty { get; set; }
/// <summary>
/// 结算分组号
/// </summary>
public string GroupNum { get; set; }
/// <summary>
/// 金额
/// </summary>
public decimal Amt { get; set; }
/// <summary>
/// 合同号
/// </summary>
public string ContractDocID { set; get; }
/// <summary>
/// 开始日期
/// </summary>
public DateTime BeginDate { get; set; }
/// <summary>
/// 结束日期
/// </summary>
public DateTime EndDate { get; set; }
}
@ -246,220 +161,99 @@ namespace Win.Sfs.SettleAccount.Bases
return new PagedResultDto<TEntityDto>(totalCount, dtos);
}
//public virtual async Task<bool> SetForwardState(TEntity p_entiy, SettleBillState state)
//{
// if (await SetForwardState(p_entiy.InvGroupNum, state) == true)
// {
// return true;
// }
// return false;
//}
///// <summary>
///// 向前流程
///// </summary>
///// <param name="p_billNum"></param>
///// <param name="state"></param>
///// <returns></returns>
///// <exception cref="BusinessException"></exception>
//public virtual async Task<bool> SetForwardState(string p_billNum, SettleBillState state)
//{
// var ls = _repository.Where(p => p.InvGroupNum == p_billNum).ToList();
// if (ls != null && ls.Count > 0)
// {
// throw new BusinessException("8989", string.Format("不存在编号为{0}", p_billNum));
// }
// foreach (TEntity p_entiy in ls)
// {
// switch (p_entiy.State)
// {
// case SettleBillState.财务已审核:
// if (state == SettleBillState.商务已审核)
// {
// p_entiy.State = state;
// }
// else
// {
// throw new BusinessException("8989", "当前状态不是【商务已审核】,无法设置成【财务已审核】状态");
// }
// break;
// case SettleBillState.商务已审核:
// if (state == SettleBillState.已开票)
// {
// p_entiy.State = state;
// }
// else
// {
// throw new BusinessException("8989", "当前状态不是【已开票】状态,无法设置成【商务已审核】");
// }
// break;
// case SettleBillState.已开票:
// if (state == SettleBillState.未结状态)
// {
// p_entiy.State = state;
// }
// else
// {
// throw new BusinessException("8989", "当前状态不是【未结状态】状态,无法设置成【已开票】");
// }
// break;
// case SettleBillState.已扣减:
// if (state == SettleBillState.客户已收票)
// {
// p_entiy.State = state;
// }
// else
// {
// throw new BusinessException("8989", "当前状态不是[客户收票],无法设置成【财务已审核】状态");
// }
// break;
// case SettleBillState.客户已收票:
// if (state == SettleBillState.财务已审核)
// {
// p_entiy.State = state;
// }
// else
// {
// throw new BusinessException("8989", "当前状态不是[财务已审核],无法设置成【客户已收票】状态");
// }
// break;
// }
// await _repository.UpdateAsync(p_entiy);
// return true;
// }
// return false;
//}
///// <summary>
///// 向后流程
///// </summary>
///// <param name="p_billNum"></param>
///// <param name="state"></param>
///// <returns></returns>
///// <exception cref="BusinessException"></exception>
//public virtual async Task<bool> SetBackwardState(string p_billNum, SettleBillState state)
//{
// var ls = _repository.Where(p => p.InvGroupNum == p_billNum).ToList();
// if (ls != null && ls.Count > 0)
// {
// throw new BusinessException("8989", string.Format("不存在发票分组号为{0}的可结算单", p_billNum));
// }
// foreach (TEntity p_entiy in ls)
// {
// switch (p_entiy.State)
// {
// case SettleBillState.商务已审核:
// if (state == SettleBillState.财务已审核)
// {
// p_entiy.State = state;
// }
// else
// {
// throw new BusinessException("8989", "当前状态不是【财务已审核】,无法设置成【商务已审核】状态");
// }
// break;
// case SettleBillState.已开票:
// if (state == SettleBillState.商务已审核)
// {
// p_entiy.State = state;
// }
// else
// {
// throw new BusinessException("8989", "当前状态不是【商务已审核】状态,无法设置成【已开票】");
// }
// break;
// case SettleBillState.未结状态:
// if (state == SettleBillState.已开票)
// {
// p_entiy.State = state;
// }
// else
// {
// throw new BusinessException("8989", "当前状态不是【已开票】状态,无法设置成【未结状态】");
// }
// break;
// case SettleBillState.客户已收票:
// if (state == SettleBillState.已扣减)
// {
// p_entiy.State = state;
// }
// else
// {
// throw new BusinessException("8989", "当前状态不是[财务已审核],无法设置成【财务已审核客户收票】状态");
// }
// break;
// case SettleBillState.财务已审核:
// if (state == SettleBillState.客户已收票)
// {
// p_entiy.State = state;
// }
// else
// {
// throw new BusinessException("8989", "当前状态不是[客户已收票],无法设置成【财务已审核】状态");
// }
// break;
// }
// await _repository.UpdateAsync(p_entiy);
// return true;
// }
// return false;
//}
//public virtual async Task<bool> SetNewState(TEntity p_entiy)
//{
// return await SetNewState(p_entiy.BillNum);
//}
//public virtual async Task<bool> SetNewState(string billNum)
//{
// var entity = await GetMainAsync(billNum);
// if (entity != null)
// {
// entity.State = SettleBillState.未结状态;
// await _repository.UpdateAsync(entity);
// return true;
// }
// return false;
// ;
//}
///// <summary>
///// 获得所有明细
///// </summary>
///// <param name="billNum"></param>
///// <returns></returns>
//public virtual async Task<List<TEntityDetail>> GetDetalListAsync(string billNum)
//{
// return await _detailRepository.Where(p => p.InvGroupNum == billNum).ToListAsync();
//}
///// <summary>
///// 获得主表信息
///// </summary>
///// <param name="billNum"></param>
///// <returns></returns>
//public virtual async Task<TEntity> GetMainAsync(string billNum)
//{
// return await _repository.Where(p => p.InvGroupNum == billNum).FirstOrDefaultAsync();
//}
/// <summary>
/// hbpo、jit、备件等
/// </summary>
/// <param name="dtos">可结算明细列表</param>
/// <param name="p_version">版本号</param>
/// <param name="p_InvGroupNum">发票分组</param>
/// <param name="p_parentInvBillNum">原发票号</param>
protected async Task<bool> SecInvoice(List<TEMP_CAN_SA_DETAIL> p_list, int p_version, string p_InvGroupNum, string p_parentInvBillNum,EnumBusinessType businessType)
{
return await _invmng.SecInvoice(p_list, p_version, p_InvGroupNum, p_parentInvBillNum, businessType);
}
/// <summary>
/// 第一次开票
/// </summary>
/// <param name="dtos"></param>
/// <param name="p_notlist"></param>
/// <param name="p_version"></param>
/// <param name="p_InvGroupNum"></param>
/// <param name="p_parentInvBillNum"></param>
/// <param name="businessType"></param>
/// <returns></returns>
protected async Task<bool> FirstInvoice(List<TEMP_CAN_SA_DETAIL> dtos, List<TEMP_NOT_SA_DETAIL> p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum,EnumBusinessType businessType)
{
return await _invmng.FirstInvoice(dtos, p_notlist, p_version, p_InvGroupNum, p_parentInvBillNum, businessType);
}
/// <summary>
/// 校验规则
/// </summary>
/// <param name="dto1s"></param>
/// <param name="p_pricelist"></param>
/// <returns></returns>
protected async Task<List<ERR_EXP_DTO>> CheckInvoiceGenerationRules<T>(List<T> dto1s, List<PriceList> p_pricelist,EnumBusinessType p_businessType) where T : SA_CAN_BASE
{
var inner = from d in dto1s
join p in p_pricelist on d.LU equals p.LU
where
d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime
select d;
var left = from d in dto1s
join p in inner on new { d.LU, d.PN } equals new { p.LU, p.PN }
into temp
from tm in temp.DefaultIfEmpty()//校验错误项
where tm == null
select d;
List<ERR_EXP_DTO> errorList = new List<ERR_EXP_DTO> ();
string name = string.Empty;
string keyname = string.Empty;
switch (p_businessType)
{
case EnumBusinessType.MaiDanJianHBPO:
name = "HBPO买单件";
keyname = "生产码";
break;
case EnumBusinessType.ZhiGongJianHBPO:
name = "HBPO直供件";
keyname = "发货单号";
break;
case EnumBusinessType.ZhiGongJianBBAC:
name = "BBAC直供件";
keyname = "发货单号";
break;
case EnumBusinessType.YinDuJian:
name = "HBPO印度件";
keyname = "发货单号";
break;
case EnumBusinessType.JisBBAC:
name = "BBAC-JIS";
keyname = "生产码";
break;
case EnumBusinessType.JisHBPO:
name = "HBPO-JIS";
keyname = "生产码";
break;
case EnumBusinessType.BeiJian:
name = "备件";
keyname = "交付识别号";
break;
}
foreach (var error in left)
{
errorList.Add(new ERR_EXP_DTO() { ItemCode = error.LU, CustomCode = $"{name}", Message = $"LU:{error.LU}{keyname}:{error.PN},下线日期:{error.SettleDate}没有对应区间销售价格表!" });
}
return errorList;
}
}
}

380
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs

@ -19,6 +19,7 @@ using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.Entities.BQ.Temp;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.Shared.RepositoryBase;
@ -33,11 +34,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
public class BBAC_BA_SERVICE : BA_SERVICE
{
private readonly INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> _adjRepository;
private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository;
public BBAC_BA_SERVICE(IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager,
@ -68,7 +66,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// <returns></returns>
public virtual async Task<string> ReissueInvoice(string p_invbillnum)
{
var mappingList= await GetMapGroupAsync(p_invbillnum);//结算分组
var mappingList= await GetMapGroupAsync(p_invbillnum);//发票对应结算分组
if (mappingList != null && mappingList.Count() > 0)
{
var version=int.Parse(DateTime.Now.ToString("yyyymm"));
@ -76,8 +75,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var inv= await GetInvoiceGroupByInvBillNum(p_invbillnum);
if (inv != null)
{
if (inv.InvoiceState == InvoiceBillState.)
{
throw new BusinessException("8989", $"选择发票:{p_invbillnum}状态为报废状态不能重开!");
}
var bbaclist = await _bbacMng.GetContainsAsync(inv.InvbillNum, gList);//结算分组对应结算零件
var adjlist=await _adjRepository.Where(p=>p.InvBillNum==inv.InvbillNum).ToListAsync();
var adjlist = await _adjRepository.Where(p => p.InvBillNum == inv.InvbillNum).ToListAsync();//调整表明细
if (adjlist != null && adjlist.Count() > 0)
{
foreach (var itm in adjlist)
@ -107,27 +110,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
//var groupNumList = entitys.Select(p => new { p.GroupNum).Distinct().ToList();
//var notList = _notRepository.Where(p => gNumList.Contains(p.GroupNum)).ToList();//不能结算
var dto1s = ObjectMapper.Map<List<BBAC_CAN_SA_DETAIL>, List<BBAC_CAN_SA_DETAIL_DTO>>(entitys);
var priceList = _priceRepository.ToList();//价格单
var inner = from d in dto1s
join p in priceList on d.LU equals p.LU
where
d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime
select d;
var left = from d in dto1s
join p in inner on new { d.LU, d.PN } equals new { p.LU, p.PN }
into temp
from tm in temp.DefaultIfEmpty()//校验错误项
where tm == null
select d;
List<ERR_EXP_DTO> errorList = new List<ERR_EXP_DTO>();
foreach (var error in left)
{
errorList.Add(new ERR_EXP_DTO() { ItemCode = error.LU, CustomCode = "业务类别BBAC", Version = version.ToString(), Message = "LU:{0}PN:{1},下线日期:{2}没有对应区间销售价格表!" });
}
var errorList =await CheckInvoiceGenerationRules(entitys, priceList, inv.BusinessType);
if (errorList.Count() > 0)
{
return await ExportErrorReportAsync(errorList);
@ -155,350 +139,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
EndDate = p.EndTime
};
var dtos = q.ToList();
if (dtos != null && dtos.Count > 0)
{
if (p_invbillnum.Substring(0, 1) == "INV")//一次开票
{
// dtos = dtos.OrderBy(p => p.SettleDate).ToList();
var _query = dtos.GroupBy(p => new { p.GroupNum }).Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) }).OrderBy(p => p.Amt);
Dictionary<string, decimal> dic = new Dictionary<string, decimal>();//原本
Dictionary<string, decimal> copyDic = new Dictionary<string, decimal>();//变换数组副本
foreach (var itm in _query.ToList())
{
dic.Add(itm.GroupNum, itm.Amt);
copyDic.Add(itm.GroupNum, itm.Amt);
}
Dictionary<string, List<string>> invoiceMap = new Dictionary<string, List<string>>();
foreach (var itm in dic)
{
if (copyDic.ContainsKey(itm.Key) == true)//是否存在分组
{
string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("INV");
List<string> invoiceGroupNumList = new List<string>();//每个发票对应的结算分组号
List<string> List = new List<string>();
decimal sum = itm.Value;//初始分组合计金额
//List<string> luList = dtos.Where(p => p.GroupNum == itm.Key).Select(p => p.LU + p.ContractDocID).Distinct().ToList(); //初始LU种类
foreach (var _itm1 in copyDic)
{
if (itm.Key == _itm1.Key)//相同结算分组项不计算,已初始化
{
invoiceGroupNumList.Add(itm.Key);
continue;
}
//var grouplist = dtos.Where(p => p.GroupNum == _itm1.Key).Select(p => p.LU + p.ContractDocID).Distinct().ToList();//每项LU种类
//luList.AddRange(grouplist);
//luList = luList.Distinct().ToList();
//if (luList.Count > 20)//累加零件不超过20种
//{
// continue;
//}
sum += _itm1.Value;
if (sum > 10000000)
{
break;
}
invoiceGroupNumList.Add(_itm1.Key);//所有条件都满足添加发票和结算分组对应关系
}
invoiceMap.Add(invoiceBillNum, invoiceGroupNumList);//记录发票对应关系
foreach (var rem in invoiceGroupNumList)//移除已经开票分组
{
copyDic.Remove(rem);
}
}
}
if (invoiceMap.Keys.Count > 0)
{
var groupList = new List<INVOICE_MAP_GROUP>();
var notDetialList = new List<INVOICE_NOT_SETTLE>();
var detailList = new List<INVOICE_WAIT_DETAIL>();
var invlist = new List<INVOICE_GRP>();
// string str = JsonConvert.SerializeObject(invoiceMap);
foreach (var itm in invoiceMap)//分组影响和
{
var key = itm.Key;//发票票号
var ls = itm.Value;//结算分组号列表
var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.LU, p.Price, p.ContractDocID, p.BeginDate, p.EndDate })
.Select(itm => new
{
InvGroupNum = itm.Key.InvGroupNum,
LU = itm.Key.LU,
ContactDocID = itm.Key.ContractDocID,
Price = itm.Key.Price,
Amt = itm.Sum(p => p.Amt),
Qty = itm.Sum(k => k.Qty),
BeginDate = itm.Key.BeginDate,
EndDate = itm.Key.EndDate
})
.ToList();
decimal amt = detailDtos.Sum(k => k.Amt);
decimal txtAmt = Math.Round(detailDtos.Sum(k => k.Amt) * 0.13m, 2);
var mapList = new List<INVOICE_MAP_GROUP>();
foreach (var groupnum in ls)
{
mapList.Add(new INVOICE_MAP_GROUP(
guid: GuidGenerator.Create(),
version: version,
invbillNum: key,
invGroupNum: inv.InvGroupNum,
settleGroupNum: groupnum,
amt: 0,
extend1: string.Empty,
extend2: string.Empty
)
);
}
if (mapList.Count > 0)
{
groupList.AddRange(mapList);
}
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
foreach (var detail in detailDtos)
{
_entityDetailList.Add(
new INVOICE_WAIT_DETAIL(
guid: GuidGenerator.Create(),
version: version,
invbillNum: key,
invGroupNum:inv.InvGroupNum,
lU: detail.LU,
qty: detail.Qty,
bussiessType: EnumBusinessType.JisHBPO,
amt: detail.Amt,
pRICE: detail.Price,
extend1: detail.ContactDocID,
extend2: string.Empty,
beginDate: detail.BeginDate,
endDate: detail.EndDate
));
}
if (_entityDetailList.Count > 0)
{
detailList.AddRange(_entityDetailList);
}
#region 原有新发票生成时
//var notls = notList.GroupBy(p => new { p.GroupNum, p.LU })
// .Select(p => new { GroupNum = p.Key.GroupNum, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty) });
//var innotls = new List<INVOICE_NOT_SETTLE>();
//foreach (var nitm in notls)
//{
// innotls.Add(new INVOICE_NOT_SETTLE(
// guid: GuidGenerator.Create(),
// version: main.Version,
// invGroupNum: main.InvGroupNum,
// settleGroupNum: nitm.GroupNum,
// lU: string.Empty,
// lU1: nitm.LU,
// extend1: string.Empty,
// extend2: string.Empty,
// qty: nitm.Qty
// ));
//}
//if (innotls.Count > 0)
//{
// notDetialList.AddRange(innotls);
//}
#endregion
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
invbillNum: key,
amt: amt,
taxAmt: txtAmt,
fileName: string.Empty,
businessType: EnumBusinessType.JisBBAC,
invGroupNum: inv.InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.,
tax:0,
parent:inv.InvbillNum
);
invlist.Add(invbill);
}
var notlist=await GetNotDetailAsync(p_invbillnum);
if (notlist != null && notlist.Count > 0)
{
foreach (var nitm in notlist)
if (p_invbillnum.Substring(0, 1) == "INV")//一次开票重开
{
notDetialList.Add(new INVOICE_NOT_SETTLE(
guid: GuidGenerator.Create(),
version: version,
invGroupNum: nitm.InvGroupNum,
settleGroupNum: nitm.SettleGroupNum,
lU: string.Empty,
lU1: nitm.LU,
extend1: string.Empty,
extend2: string.Empty,
qty: nitm.Qty
));
}
}
await _repository.DbContext.BulkInsertAsync(invlist);
await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
await _repository.DbContext.BulkInsertAsync(notDetialList);
}
await ReissueFirstInvoice(dtos, version, p_invbillnum);
}
else//二次开票
{
var groups1 = dtos.GroupBy(p => new { p.LU, p.ContractDocID, p.Price, p.BeginDate, p.EndDate }).Select(p => new TMEP_INV
{
BeginDate = p.Key.BeginDate,
EndDate = p.Key.EndDate,
LU = p.Key.LU,
ContractDocID = p.Key.ContractDocID,
Amt = p.Sum(itm => itm.Amt),
Qty = p.Sum(itm => itm.Qty),
Price = p.Key.Price
}).ToList();//汇总记录不出现重复值
var groups = dtos.GroupBy(p => new { p.LU, p.ContractDocID, p.Price, p.BeginDate, p.EndDate }).Select(p => new TMEP_INV
{
BeginDate = p.Key.BeginDate,
EndDate = p.Key.EndDate,
LU = p.Key.LU,
ContractDocID = p.Key.ContractDocID,
Amt = p.Sum(itm => itm.Amt),
Qty = p.Sum(itm => itm.Qty),
Price = p.Key.Price
}).ToList();//汇总记录不出现重复值
Dictionary<string, List<TMEP_INV>> invoiceMap = new Dictionary<string, List<TMEP_INV>>();//发票和发票明细关系
foreach (var group in groups)
{
int i = groups1.Count(p => p.LU == group.LU
&& p.ContractDocID == group.ContractDocID
&& p.BeginDate == group.BeginDate
&& p.EndDate == group.EndDate
);
if (i > 0)
{
string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("CINV");
List<TMEP_INV> tempList = new List<TMEP_INV>();
decimal sum = group.Amt;//初始合计金额
int partCount = 0;
foreach (var group1 in groups1)
{
if (group.LU == group1.LU && group1.ContractDocID == group.ContractDocID
&& group.BeginDate == group1.BeginDate
&& group.EndDate == group1.EndDate
)
{
tempList.Add(group1);
partCount++;//符合条件加入到零件中
continue;
}
partCount++;
if (partCount > 30)
{
continue;
}
sum += group1.Amt;
if (sum > 10000000)
{
break;
}
tempList.Add(group1);
}
invoiceMap.Add(invoiceBillNum, tempList);
var query = from itm in groups1
join itm1 in tempList
on new { itm.LU, itm.ContractDocID, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.ContractDocID, itm1.BeginDate, itm1.EndDate } into temp
from tm in temp
where tm == null
select new TMEP_INV
{
LU = itm.LU,
ContractDocID = itm.ContractDocID,
Price = itm.Price,
Amt = itm.Amt,
Qty = itm.Qty,
BeginDate = itm.BeginDate,
EndDate = itm.EndDate
};
groups1 = query.ToList();
}
}
if (invoiceMap.Count > 0)
{
var groupList = new List<INVOICE_MAP_GROUP>();
var notDetialList = new List<INVOICE_NOT_SETTLE>();
var detailList = new List<INVOICE_WAIT_DETAIL>();
var invlist = new List<INVOICE_GRP>();
foreach (var group in invoiceMap)
{
var key = group.Key;//发票票号
var ls = group.Value;//发票明细
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
foreach (var detail in ls)
{
_entityDetailList.Add(
new INVOICE_WAIT_DETAIL(
guid: GuidGenerator.Create(),
version: version,
invbillNum: key,
invGroupNum: inv.InvGroupNum,
lU: detail.LU,
qty: detail.Qty,
bussiessType: EnumBusinessType.JisBBAC,
amt: detail.Amt,
pRICE: detail.Price,
extend1: detail.ContractDocID,
extend2: string.Empty,
beginDate: detail.BeginDate,
endDate: detail.EndDate
));
}
if (_entityDetailList.Count > 0)
{
detailList.AddRange(_entityDetailList);
}
decimal amt = detailList.Sum(k => k.Amt);
decimal txtAmt = Math.Round(detailList.Sum(k => k.Amt), 2);
var contractList = ls.Select(p => p.ContractDocID).Distinct();
var _groupList = dtos.Where(p => contractList.Contains(p.ContractDocID)).GroupBy(p => new { p.GroupNum })
.Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) }).Distinct();
List<INVOICE_MAP_GROUP> group1 = new List<INVOICE_MAP_GROUP>();
foreach (var en in _groupList)
{
group1.Add(
new INVOICE_MAP_GROUP(
guid: GuidGenerator.Create(),
version: version,
invbillNum: key,
invGroupNum: inv.InvGroupNum,
settleGroupNum: en.GroupNum,
amt: en.Amt,
extend1: string.Empty,
extend2: string.Empty));
}
if (group1.Count > 0)
{
groupList.AddRange(group1);
}
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
invbillNum: key,
amt: amt,
taxAmt: txtAmt,
fileName: string.Empty,
businessType: EnumBusinessType.JisBBAC,
invGroupNum: inv.InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.,
tax: 0,
parent: inv.InvbillNum
);
invlist.Add(invbill);
}
await _repository.DbContext.BulkInsertAsync(invlist);
await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
//await _repository.DbContext.BulkInsertAsync(notDetialList);
}
await ReissueSecInvoice(dtos, version, p_invbillnum);
}
}
}
@ -511,12 +160,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
throw new BusinessException("8989", $"不存发票号:{p_invbillnum}对应的结算分组号");
}
return ApplicationConsts.SuccessStr;
}
}
}

358
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs

@ -29,6 +29,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
using Win.Abp.Snowflakes;
using Win.Sfs.SettleAccount.CommonManagers;
using Volo.Abp;
using Win.Sfs.SettleAccount.Entities.BQ.Temp;
namespace Win.Sfs.SettleAccount.Entities.BQ
{
@ -91,30 +92,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var entitys = await _bbacMng.GetDetalListAsync(input.BillNum);//可结算
var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
//var groupNumList = entitys.Select(p => new { p.GroupNum).Distinct().ToList();
var notList = _notRepository.Where(p => groupNumList.Contains(p.GroupNum)).ToList();//不能结算
var notQuery = _notRepository.Where(p => groupNumList.Contains(p.InvGroupNum)).ToList();//不能结算
var dto1s = ObjectMapper.Map<List<BBAC_CAN_SA_DETAIL>, List<BBAC_CAN_SA_DETAIL_DTO>>(entitys);
var priceList = _priceRepository.ToList();//价格单
var errorList = await CheckInvoiceGenerationRules(entitys, priceList,main.BusinessType);//校验生成规则
var inner = from d in dto1s
join p in priceList on d.LU equals p.LU
where
d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime
select d;
var left = from d in dto1s
join p in inner on new { d.LU, d.PN } equals new { p.LU, p.PN }
into temp
from tm in temp.DefaultIfEmpty()//校验错误项
where tm == null
select d;
List<ERR_EXP_DTO> errorList = new List<ERR_EXP_DTO>();
foreach (var error in left)
{
errorList.Add(new ERR_EXP_DTO() { ItemCode = error.LU, CustomCode = "业务类别BBAC", Version = main.Version.ToString(), Message = "LU:{0}PN:{1},下线日期:{2}没有对应区间销售价格表!" });
}
if (errorList.Count() > 0)
{
return await ExportErrorReportAsync(errorList);
@ -147,329 +130,30 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
if (input.BillNum.Substring(0, 1) == "C")//一次开票
{
// dtos = dtos.OrderBy(p => p.SettleDate).ToList();
var _query = dtos.GroupBy(p => new { p.GroupNum }).Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) }).OrderBy(p => p.Amt);
Dictionary<string, decimal> dic = new Dictionary<string, decimal>();//原本
Dictionary<string, decimal> copyDic = new Dictionary<string, decimal>();//变换数组副本
foreach (var itm in _query.ToList())
{
dic.Add(itm.GroupNum, itm.Amt);
copyDic.Add(itm.GroupNum, itm.Amt);
}
Dictionary<string, List<string>> invoiceMap = new Dictionary<string, List<string>>();
foreach (var itm in dic)
{
if (copyDic.ContainsKey(itm.Key) == true)//是否存在分组
{
string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("INV");
List<string> invoiceGroupNumList = new List<string>();//每个发票对应的结算分组号
List<string> List = new List<string>();
decimal sum = itm.Value;//初始分组合计金额
//List<string> luList = dtos.Where(p => p.GroupNum == itm.Key).Select(p => p.LU + p.ContractDocID).Distinct().ToList(); //初始LU种类
foreach (var _itm1 in copyDic)
var notlist = notQuery.Select(p => new TEMP_NOT_SA_DETAIL
{
if (itm.Key == _itm1.Key)//相同结算分组项不计算,已初始化
{
invoiceGroupNumList.Add(itm.Key);
continue;
}
//var grouplist = dtos.Where(p => p.GroupNum == _itm1.Key).Select(p => p.LU + p.ContractDocID).Distinct().ToList();//每项LU种类
//luList.AddRange(grouplist);
//luList = luList.Distinct().ToList();
//if (luList.Count > 20)//累加零件不超过20种
//{
// continue;
//}
sum += _itm1.Value;
if (sum > 10000000)
{
break;
}
invoiceGroupNumList.Add(_itm1.Key);//所有条件都满足添加发票和结算分组对应关系
}
invoiceMap.Add(invoiceBillNum, invoiceGroupNumList);//记录发票对应关系
foreach (var rem in invoiceGroupNumList)//移除已经开票分组
{
copyDic.Remove(rem);
}
}
}
if (invoiceMap.Keys.Count > 0)
{
var groupList = new List<INVOICE_MAP_GROUP>();
var notDetialList = new List<INVOICE_NOT_SETTLE>();
var detailList = new List<INVOICE_WAIT_DETAIL>();
var invlist = new List<INVOICE_GRP>();
// string str = JsonConvert.SerializeObject(invoiceMap);
foreach (var itm in invoiceMap)//分组影响和
{
var key = itm.Key;//发票票号
var ls = itm.Value;//结算分组号列表
var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.LU, p.Price, p.ContractDocID, p.BeginDate, p.EndDate })
.Select(itm => new
{
InvGroupNum = itm.Key.InvGroupNum,
LU = itm.Key.LU,
ContactDocID = itm.Key.ContractDocID,
Price = itm.Key.Price,
Amt = itm.Sum(p => p.Amt),
Qty = itm.Sum(k => k.Qty),
BeginDate = itm.Key.BeginDate,
EndDate = itm.Key.EndDate
})
.ToList();
decimal amt = detailDtos.Sum(k => k.Amt);
decimal txtAmt = Math.Round(detailDtos.Sum(k => k.Amt) * 0.13m, 2);
var mapList = new List<INVOICE_MAP_GROUP>();
foreach (var groupnum in ls)
{
//amt = dtos.Where(p => p.GroupNum == groupnum).Sum(p => p.Amt);
mapList.Add(new INVOICE_MAP_GROUP(
guid: GuidGenerator.Create(),
version: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
settleGroupNum: groupnum,
amt: 0,
extend1: string.Empty,
extend2: string.Empty
)
);
}
if (mapList.Count > 0)
{
groupList.AddRange(mapList);
}
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
foreach (var detail in detailDtos)
{
_entityDetailList.Add(
new INVOICE_WAIT_DETAIL(
guid: GuidGenerator.Create(),
version: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
lU: detail.LU,
qty: detail.Qty,
bussiessType: EnumBusinessType.JisBBAC,
amt: detail.Amt,
pRICE: detail.Price,
extend1: detail.ContactDocID,
extend2: string.Empty,
beginDate: detail.BeginDate,
endDate: detail.EndDate
KeyCode = p.KeyCode,
Version = p.Version,
SettleBillNum = p.SettleBillNum,
LU = p.LU,
PN = p.PN,
Site = p.Site,
Qty = p.Qty,
Price = p.Price,
BusinessType = p.BusinessType,
IsReturn = "",
InvGroupNum = p.InvGroupNum,
SettleDate = p.SettleDate,
GroupNum = p.GroupNum,
ContractDocID = string.Empty
));
}
if (_entityDetailList.Count > 0)
{
detailList.AddRange(_entityDetailList);
}
var notls = notList.GroupBy(p => new { p.GroupNum, p.LU })
.Select(p => new { GroupNum = p.Key.GroupNum, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty) });
var innotls = new List<INVOICE_NOT_SETTLE>();
foreach (var nitm in notls)
{
innotls.Add(new INVOICE_NOT_SETTLE(
guid: GuidGenerator.Create(),
version: main.Version,
invGroupNum: main.InvGroupNum,
settleGroupNum: nitm.GroupNum,
lU: string.Empty,
lU1: nitm.LU,
extend1: string.Empty,
extend2: string.Empty,
qty: nitm.Qty
));
}
if (innotls.Count > 0)
{
notDetialList.AddRange(innotls);
}
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
invbillNum: key,
amt: amt,
taxAmt: txtAmt,
fileName: string.Empty,
businessType: EnumBusinessType.JisBBAC,
invGroupNum: main.InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.,
tax: 0,
parent: string.Empty
);
invlist.Add(invbill);
}
await _repository.DbContext.BulkInsertAsync(invlist);
await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
await _repository.DbContext.BulkInsertAsync(notDetialList);
}
}).ToList();//不能结算
await FirstInvoice(dtos, notlist, main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
}
else//二次开票
{
var groups1 = dtos.GroupBy(p => new { p.LU, p.ContractDocID, p.Price, p.BeginDate, p.EndDate }).Select(p => new TMEP_INV
{
BeginDate = p.Key.BeginDate,
EndDate = p.Key.EndDate,
LU = p.Key.LU,
ContractDocID = p.Key.ContractDocID,
Amt = p.Sum(itm => itm.Amt),
Qty = p.Sum(itm => itm.Qty),
Price = p.Key.Price
}).ToList();//汇总记录不出现重复值
var groups = dtos.GroupBy(p => new { p.LU, p.ContractDocID, p.Price, p.BeginDate, p.EndDate }).Select(p => new TMEP_INV
{
BeginDate = p.Key.BeginDate,
EndDate = p.Key.EndDate,
LU = p.Key.LU,
ContractDocID = p.Key.ContractDocID,
Amt = p.Sum(itm => itm.Amt),
Qty = p.Sum(itm => itm.Qty),
Price = p.Key.Price
}).ToList();//汇总记录不出现重复值
Dictionary<string, List<TMEP_INV>> invoiceMap = new Dictionary<string, List<TMEP_INV>>();//发票和发票明细关系
foreach (var group in groups)
{
int i = groups1.Count(p => p.LU == group.LU
&& p.ContractDocID == group.ContractDocID
&& p.BeginDate == group.BeginDate
&& p.EndDate == group.EndDate
);
if (i > 0)
{
string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("CINV");
List<TMEP_INV> tempList = new List<TMEP_INV>();
decimal sum = group.Amt;//初始合计金额
int partCount = 0;
foreach (var group1 in groups1)
{
if (group.LU == group1.LU && group1.ContractDocID == group.ContractDocID
&& group.BeginDate == group1.BeginDate
&& group.EndDate == group1.EndDate
)
{
tempList.Add(group1);
partCount++;//符合条件加入到零件中
continue;
}
partCount++;
if (partCount > 30)
{
continue;
}
sum += group1.Amt;
if (sum > 10000000)
{
break;
}
tempList.Add(group1);
}
invoiceMap.Add(invoiceBillNum, tempList);
var query = from itm in groups1
join itm1 in tempList
on new { itm.LU, itm.ContractDocID, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.ContractDocID, itm1.BeginDate, itm1.EndDate } into temp
from tm in temp
where tm == null
select new TMEP_INV
{
LU = itm.LU,
ContractDocID = itm.ContractDocID,
Amt = itm.Amt,
Qty = itm.Qty,
BeginDate = itm.BeginDate,
EndDate = itm.EndDate
};
groups1 = query.ToList();
}
}
if (invoiceMap.Count > 0)
{
var groupList = new List<INVOICE_MAP_GROUP>();
var notDetialList = new List<INVOICE_NOT_SETTLE>();
var detailList = new List<INVOICE_WAIT_DETAIL>();
var invlist = new List<INVOICE_GRP>();
foreach (var group in invoiceMap)
{
var key = group.Key;//发票票号
var ls = group.Value;//发票明细
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
foreach (var detail in ls)
{
_entityDetailList.Add(
new INVOICE_WAIT_DETAIL(
guid: GuidGenerator.Create(),
version: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
lU: detail.LU,
qty: detail.Qty,
bussiessType: EnumBusinessType.JisBBAC,
amt: detail.Amt,
pRICE: detail.Price,
extend1: detail.ContractDocID,
extend2: string.Empty,
beginDate: detail.BeginDate,
endDate: detail.EndDate
));
}
if (_entityDetailList.Count > 0)
{
detailList.AddRange(_entityDetailList);
}
decimal amt = detailList.Sum(k => k.Amt);
decimal txtAmt = Math.Round(detailList.Sum(k => k.Amt), 2);
var contractList = ls.Select(p => p.ContractDocID).Distinct();
var _groupList = dtos.Where(p => contractList.Contains(p.ContractDocID)).GroupBy(p => new { p.GroupNum })
.Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) }).Distinct();
List<INVOICE_MAP_GROUP> group1 = new List<INVOICE_MAP_GROUP>();
foreach (var en in _groupList)
{
group1.Add(
new INVOICE_MAP_GROUP(
guid: GuidGenerator.Create(),
version: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
settleGroupNum: en.GroupNum,
amt: en.Amt,
extend1: string.Empty,
extend2: string.Empty));
}
if (group1.Count > 0)
{
groupList.AddRange(group1);
}
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
invbillNum: key,
amt: amt,
taxAmt: txtAmt,
fileName: string.Empty,
businessType: EnumBusinessType.JisBBAC,
invGroupNum: main.InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.,
tax: 0,
parent: string.Empty
);
invlist.Add(invbill);
}
await _repository.DbContext.BulkInsertAsync(invlist);
await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
//await _repository.DbContext.BulkInsertAsync(notDetialList);
}
await SecInvoice(dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
}
}

357
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs

@ -1,3 +1,4 @@
using DocumentFormat.OpenXml.Bibliography;
using EFCore.BulkExtensions;
using Microsoft.AspNetCore.Authorization;
@ -6,6 +7,7 @@ using SettleAccount.Domain.BQ;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
@ -18,9 +20,11 @@ using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.Entities.BQ.Temp;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.Shared.RepositoryBase;
using static System.Runtime.CompilerServices.RuntimeHelpers;
namespace Win.Sfs.SettleAccount.Entities.BQ
{
@ -41,7 +45,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
HBPO_CAN_SA_DETAIL_EXP_DTO
>
{
private readonly INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> _notRepository;
private readonly INormalEfCoreRepository<HBPO_NOT_SA_DETAIL, Guid> _notRepository;
private readonly INormalEfCoreRepository<PriceList, Guid> _priceRepository;
private readonly HBPO_CAN_SA_MNG _hbpoMng;
@ -52,7 +56,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
INormalEfCoreRepository<HBPO_CAN_SA, Guid> repository,
INormalEfCoreRepository<HBPO_CAN_SA_DETAIL, Guid> detailRepository,
INV_MNG invmng,
INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> notRepository,
INormalEfCoreRepository<HBPO_NOT_SA_DETAIL, Guid> notRepository,
INormalEfCoreRepository<PriceList, Guid> priceRepository,
HBPO_CAN_SA_MNG hbpoMng
@ -64,12 +68,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
_notRepository = notRepository;
_hbpoMng = hbpoMng;
}
/// <summary>
/// 生成发票
/// </summary>
@ -86,34 +84,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
if (await _hbpoMng.SetForwardState(main, SettleBillState.))
{
var entitys = await _hbpoMng.GetDetalListAsync(input.BillNum);
var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
var notList = _notRepository.Where(p => groupNumList.Contains(p.InvGroupNum)).ToList();//不能结算
var notQuery = _notRepository.Where(p => groupNumList.Contains(p.InvGroupNum)).ToList();
var dto1s = ObjectMapper.Map<List<HBPO_CAN_SA_DETAIL>, List<HBPO_CAN_SA_DETAIL_DTO>>(entitys);
var priceList = _priceRepository.ToList();//价格单
var inner = from d in dto1s
join p in priceList on d.LU equals p.LU
where
d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime
select d;
var left = from d in dto1s
join p in inner on new { d.LU, d.PN } equals new { p.LU, p.PN }
into temp
from tm in temp.DefaultIfEmpty()//校验错误项
where tm == null
select d;
List<ERR_EXP_DTO> errorList = new List<ERR_EXP_DTO>();
foreach (var error in left)
{
errorList.Add(new ERR_EXP_DTO() { ItemCode = error.LU, CustomCode = "业务类别HBPO", Version = main.Version.ToString(), Message = "LU:{0}PN:{1},下线日期:{2}没有对应区间销售价格表!" });
}
var errorList=await CheckInvoiceGenerationRules(entitys, priceList,main.BusinessType);//校验生成规则
if (errorList.Count() > 0)
{
return await ExportErrorReportAsync(errorList);
@ -136,7 +111,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
Qty = d.Qty,
GroupNum = d.GroupNum,
Amt = Math.Round(d.Qty * p.Price, 2),
ContractDocID="no",
BeginDate = p.BeginTime,
EndDate = p.EndTime
};
@ -145,316 +120,40 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
if (input.BillNum.Substring(0, 1) == "C")//一次开票
{
var _query = dtos.GroupBy(p => new { p.GroupNum }).Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) });
Dictionary<string, decimal> dic = new Dictionary<string, decimal>();//原本
Dictionary<string, decimal> copyDic = new Dictionary<string, decimal>();//变换数组副本
foreach (var itm in _query.ToList())
{
dic.Add(itm.GroupNum, itm.Amt);
copyDic.Add(itm.GroupNum, itm.Amt);
}
Dictionary<string, List<string>> invoiceMap = new Dictionary<string, List<string>>();
foreach (var itm in dic)
{
string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("INV");
List<string> invoiceGroupNumList = new List<string>();//每个发票对应的结算分组号
List<string> List = new List<string>();
decimal sum = itm.Value;//初始分组合计金额
List<string> luList = dtos.Where(p => p.GroupNum == itm.Key).Select(p => p.LU).Distinct().ToList(); //初始LU种类
if (copyDic.ContainsKey(itm.Key) == true)//是否存在分组
{
foreach (var _itm1 in copyDic)
{
if (itm.Key == _itm1.Key)//相同结算分组项不计算,已初始化
var notlist = notQuery.Select(p => new TEMP_NOT_SA_DETAIL
{
invoiceGroupNumList.Add(itm.Key);
continue;
}
//var grouplist = dtos.Where(p => p.GroupNum == _itm1.Key).Select(p => p.LU).Distinct().ToList();//每项LU种类
//luList.AddRange(grouplist);
//luList = luList.Distinct().ToList();
//if (luList.Count > 20)//累加零件不超过20种
//{
// continue;
//}
sum += _itm1.Value;
if (sum > 10000000)
{
break;
}
invoiceGroupNumList.Add(_itm1.Key);//所有条件都满足添加发票和结算分组对应关系
}
invoiceMap.Add(invoiceBillNum, invoiceGroupNumList);//记录发票对应关系
foreach (var rem in invoiceGroupNumList)//移除
{
copyDic.Remove(rem);
}
}
}
if (invoiceMap.Keys.Count > 0)
{
var groupList = new List<INVOICE_MAP_GROUP>();
var notDetialList = new List<INVOICE_NOT_SETTLE>();
var detailList = new List<INVOICE_WAIT_DETAIL>();
var invlist = new List<INVOICE_GRP>();
foreach (var itm in invoiceMap)//分组影响和
{
var key = itm.Key;//发票票号
var ls = itm.Value;//结算分组号列表
var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.LU, p.Price,p.BeginDate,p.EndDate })
.Select(itm => new
{
InvGroupNum = itm.Key.InvGroupNum,
LU = itm.Key.LU,
Price = itm.Key.Price,
Amt = Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),
Qty = itm.Sum(k => k.Qty),
BeginDate = itm.Key.BeginDate,
EndDate = itm.Key.EndDate
})
.ToList();
decimal amt = detailDtos.Sum(k => k.Amt);
decimal txtAmt = Math.Round(detailDtos.Sum(k => k.Amt), 2);
var mapList = new List<INVOICE_MAP_GROUP>();
foreach (var groupnum in ls)
{
mapList.Add(new INVOICE_MAP_GROUP(
guid: GuidGenerator.Create(),
version: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
settleGroupNum: groupnum,
amt: 0,
extend1: string.Empty,
extend2: string.Empty
)
);
}
if (mapList.Count > 0)
{
groupList.AddRange(mapList);
}
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
foreach (var detail in detailDtos)
{
_entityDetailList.Add(
new INVOICE_WAIT_DETAIL(
guid: GuidGenerator.Create(),
version: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
lU: detail.LU,
qty: detail.Qty,
bussiessType: EnumBusinessType.JisHBPO,
amt: detail.Amt,
pRICE: detail.Price,
extend1: string.Empty,
extend2: string.Empty,
beginDate:detail.BeginDate,
endDate:detail.EndDate
));
}
if (_entityDetailList.Count > 0)
{
detailList.AddRange(_entityDetailList);
}
KeyCode = p.KeyCode,
Version = p.Version,
SettleBillNum = p.SettleBillNum,
LU = p.LU,
PN = p.PN,
Site = p.Site,
Qty = p.Qty,
Price = p.Price,
BusinessType = p.BusinessType,
IsReturn = "",
InvGroupNum = p.InvGroupNum,
SettleDate = p.SettleDate,
GroupNum = p.GroupNum,
ContractDocID = string.Empty
var notls = notList.GroupBy(p => new { p.GroupNum, p.LU }).Select(p => new { GroupNum = p.Key.GroupNum, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty) });
var innotls = new List<INVOICE_NOT_SETTLE>();
foreach (var nitm in notls)
{
innotls.Add(new INVOICE_NOT_SETTLE(
guid: GuidGenerator.Create(),
version: main.Version,
invGroupNum: main.InvGroupNum,
settleGroupNum: nitm.GroupNum,
lU: string.Empty,
lU1: nitm.LU,
extend1: string.Empty,
extend2: string.Empty,
qty: nitm.Qty
));
}
if (innotls.Count > 0)
{
notDetialList.AddRange(innotls);
}
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
invbillNum: key,
amt: amt,
taxAmt: txtAmt,
fileName: string.Empty,
businessType: EnumBusinessType.JisHBPO,
invGroupNum: main.InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.,
tax: 0,
parent: string.Empty
);
invlist.Add(invbill);
}
await _repository.DbContext.BulkInsertAsync(invlist);
await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
await _repository.DbContext.BulkInsertAsync(notDetialList);
}
}).ToList();//不能结算
await FirstInvoice(dtos, notlist, main.Version, main.InvGroupNum, string.Empty,main.BusinessType);
}
else//二次开票
{
var groups1 = dtos.GroupBy(p => new { p.LU, p.Price,p.BeginDate,p.EndDate }).Select(p => new TMEP_INV
{
LU = p.Key.LU,
Amt = p.Sum(itm => itm.Amt),
Qty = p.Sum(itm => itm.Qty),
Price = p.Key.Price,
BeginDate=p.Key.BeginDate,
EndDate=p.Key.EndDate
}).ToList();//汇总记录不出现重复值
var groups = dtos.GroupBy(p => new { p.LU, p.Price, p.BeginDate, p.EndDate }).Select(p => new TMEP_INV
{
LU = p.Key.LU,
Amt = p.Sum(itm => itm.Amt),
Qty = p.Sum(itm => itm.Qty),
Price = p.Key.Price,
BeginDate = p.Key.BeginDate,
EndDate = p.Key.EndDate
}).ToList();//汇总记录不出现重复值
Dictionary<string, List<TMEP_INV>> invoiceMap = new Dictionary<string, List<TMEP_INV>>();//发票和发票明细关系
foreach (var group in groups)
{
int i = groups1.Count(p => p.LU == group.LU &&p.BeginDate==group.BeginDate && p.EndDate==group.EndDate );
if (i > 0)
{
string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("CINV");
List<TMEP_INV> tempList = new List<TMEP_INV>();
decimal sum = group.Amt;//初始合计金额
int partCount = 0;
foreach (var group1 in groups1)
{
if (group.LU == group1.LU && group.BeginDate == group1.BeginDate && group.EndDate == group1.EndDate)
{
tempList.Add(group1);
partCount++;//符合条件加入到零件中
continue;
await SecInvoice(dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
}
partCount++;
if (partCount > 30)
{
continue;
}
if (sum > 10000000)
{
break;
}
sum += group1.Amt;
tempList.Add(group1);
}
invoiceMap.Add(invoiceBillNum, tempList);
var query = from itm in groups1
join itm1 in tempList
on new { itm.LU, itm.BeginDate,itm.EndDate} equals new { itm1.LU, itm1.BeginDate, itm1.EndDate } into temp
from tm in temp where tm==null
select new TMEP_INV { LU = itm.LU, Amt = itm.Amt, Qty = itm.Qty ,BeginDate=itm.BeginDate,EndDate=itm.EndDate };
groups1 = query.ToList();
}
}
if (invoiceMap.Count > 0)
{
var groupList = new List<INVOICE_MAP_GROUP>();
var notDetialList = new List<INVOICE_NOT_SETTLE>();
var detailList = new List<INVOICE_WAIT_DETAIL>();
var invlist = new List<INVOICE_GRP>();
foreach (var group in invoiceMap)
{
var key = group.Key;//发票票号
var ls = group.Value;//发票明细
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
foreach (var detail in ls)
{
_entityDetailList.Add(
new INVOICE_WAIT_DETAIL(
guid: GuidGenerator.Create(),
version: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
lU: detail.LU,
qty: detail.Qty,
bussiessType: EnumBusinessType.JisBBAC,
amt: detail.Amt,
pRICE: detail.Price,
extend1: string.Empty,
extend2: string.Empty,
beginDate: detail.BeginDate,
endDate: detail.EndDate
));
}
if (_entityDetailList.Count > 0)
{
detailList.AddRange(_entityDetailList);
}
decimal amt = detailList.Sum(k => k.Amt);
decimal txtAmt = Math.Round(detailList.Sum(k => k.Amt), 2);
var contractList = ls.Select(p => p.ContractDocID).Distinct();
var _groupList = dtos.GroupBy(p => new { p.GroupNum })
.Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) }).Distinct();
List<INVOICE_MAP_GROUP> group1 = new List<INVOICE_MAP_GROUP>();
foreach (var en in _groupList)
{
group1.Add(
new INVOICE_MAP_GROUP(
guid: GuidGenerator.Create(),
version: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
settleGroupNum: en.GroupNum,
amt: en.Amt,
extend1: string.Empty,
extend2: string.Empty));
}
if (group1.Count > 0)
{
groupList.AddRange(group1);
return ApplicationConsts.SuccessStr;
}
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
invbillNum: key,
amt: amt,
taxAmt: txtAmt,
fileName: string.Empty,
businessType: EnumBusinessType.JisHBPO,
invGroupNum: main.InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.,
tax: 0,
parent: string.Empty
);
invlist.Add(invbill);
}
await _repository.DbContext.BulkInsertAsync(invlist);
await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
//await _repository.DbContext.BulkInsertAsync(notDetialList);
}
}
}
}
}
return ApplicationConsts.SuccessStr;
}
}

13
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobHostdService.cs

@ -78,10 +78,11 @@ public class JobHostdService : BackgroundService, IApplicationService
if (!jobItem.IsRunning)
{
jobLogId = this.JobItemStart(job.Id);
}
if (jobLogId.HasValue)
{
try
{
jobService.Invoke();
await jobService.Invoke().ConfigureAwait(false);
this.JobItemSuccess(job.Id, jobLogId.Value);
Debug.WriteLine($"{job.Name} 定时任务执行成功");
}
@ -94,6 +95,8 @@ public class JobHostdService : BackgroundService, IApplicationService
}
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
@ -105,8 +108,10 @@ public class JobHostdService : BackgroundService, IApplicationService
{
Console.WriteLine(ex.ToString());
}
});
thread.IsBackground = true;
})
{
IsBackground = true
};
if (this.Jobs.TryAdd(job, new Tuple<CancellationTokenSource, Thread>(source, thread)))
{
thread.Start();

14
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/JobItemAppService.cs

@ -4,7 +4,9 @@ using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using Omu.ValueInjecter;
using SettleAccount.Job.SignalR;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.DependencyInjection;
@ -19,11 +21,13 @@ public class JobItemAppService : ApplicationService, ITransientDependency
{
private readonly INormalEfCoreRepository<JobItem, Guid> _repository;
private readonly JobHostdService _jobHostdService;
private readonly IHubContext<PageHub> _hubContext;
public JobItemAppService(INormalEfCoreRepository<JobItem, Guid> repository, JobHostdService jobHostdService)
public JobItemAppService(INormalEfCoreRepository<JobItem, Guid> repository, JobHostdService jobHostdService, IHubContext<PageHub> hubContext)
{
this._repository = repository;
this._jobHostdService = jobHostdService;
this._hubContext = hubContext;
}
[HttpPost]
@ -31,6 +35,7 @@ public class JobItemAppService : ApplicationService, ITransientDependency
{
var entity = await _repository.InsertAsync(input).ConfigureAwait(false);
this._jobHostdService.AddJob(entity);
this.Notify();
return entity;
}
@ -43,6 +48,7 @@ public class JobItemAppService : ApplicationService, ITransientDependency
await _repository.DeleteAsync(item).ConfigureAwait(false);
this._jobHostdService.RemoveJob(item);
}
this.Notify();
return entites.Count > 0;
}
@ -73,8 +79,14 @@ public class JobItemAppService : ApplicationService, ITransientDependency
this._jobHostdService.RemoveJob(entity);
this._jobHostdService.AddJob(entity);
}
this.Notify();
return input;
}
private void Notify()
{
this._hubContext.Clients.All.ServerToClient("JobItem", "refresh", "");
}
}
[Route("api/settleaccount/[controller]/[action]")]

330
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs

@ -13,6 +13,7 @@ using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.Entities.BQ.Temp;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.Shared.RepositoryBase;
@ -70,7 +71,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
var entitys = await _pubMng.GetDetalListAsync(input.BillNum);
var groupNumList = entitys.Select(p => p.GroupNum).Distinct().ToList();
List<ERR_EXP_DTO> errorList = new List<ERR_EXP_DTO>();
var dto1s = ObjectMapper.Map<List<PUB_CAN_SA_DETAIL>, List<PUB_CAN_SA_DETAIL_DTO>>(entitys);
List<PriceList> priceList=new List<PriceList>();
if (main.BusinessType == EnumBusinessType.BeiJian)
@ -85,25 +86,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
priceList = _priceRepository.ToList();//价格单
}
var inner = from d in dto1s
join p in priceList on d.LU equals p.LU
where
d.SettleDate >= p.BeginTime && d.SettleDate <= p.EndTime
select d;
var left = from d in dto1s
join p in inner on new { d.LU, d.PN } equals new { p.LU, p.PN }
into temp
from tm in temp.DefaultIfEmpty()//校验错误项
where tm == null
select d;
foreach (var error in left)
var errorList = await CheckInvoiceGenerationRules(entitys, priceList,main.BusinessType);//校验生成规则
if (errorList.Count() > 0)
{
errorList.Add(new ERR_EXP_DTO() { ItemCode = error.LU, CustomCode = "", Version = main.Version.ToString(), Message = "LU:{0}PN:{1},下线日期:{2}没有对应区间销售价格表!" });
return await ExportErrorReportAsync(errorList);
}
if (errorList.Count() > 0)
{
return await ExportErrorReportAsync(errorList);
@ -127,7 +114,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
Qty = d.Qty,
GroupNum = d.GroupNum,
Amt = Math.Round(d.Qty * p.Price, 2),
ContractDocID="no",
BeginDate = p.BeginTime,
EndDate = p.EndTime
};
@ -135,315 +122,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
if (dtos != null && dtos.Count > 0)
{
if (input.BillNum.Substring(0, 1) == "C")//一次开票
{
var _query = dtos.GroupBy(p => new { p.GroupNum }).Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) });
Dictionary<string, decimal> dic = new Dictionary<string, decimal>();//原本
Dictionary<string, decimal> copyDic = new Dictionary<string, decimal>();//变换数组副本
foreach (var itm in _query.ToList())
{
dic.Add(itm.GroupNum, itm.Amt);
copyDic.Add(itm.GroupNum, itm.Amt);
}
Dictionary<string, List<string>> invoiceMap = new Dictionary<string, List<string>>();
foreach (var itm in dic)
{
string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("INV");
List<string> invoiceGroupNumList = new List<string>();//每个发票对应的结算分组号
List<string> List = new List<string>();
decimal sum = itm.Value;//初始分组合计金额
List<string> luList = dtos.Where(p => p.GroupNum == itm.Key).Select(p => p.LU).Distinct().ToList(); //初始LU种类
if (copyDic.ContainsKey(itm.Key) == true)//是否存在分组
{
foreach (var _itm1 in copyDic)
{
if (itm.Key == _itm1.Key)//相同结算分组项不计算,已初始化
{
invoiceGroupNumList.Add(itm.Key);
continue;
}
//var grouplist = dtos.Where(p => p.GroupNum == _itm1.Key).Select(p => p.LU).Distinct().ToList();//每项LU种类
//luList.AddRange(grouplist);
//luList = luList.Distinct().ToList();
//if (luList.Count > 20)//累加零件不超过20种
//{
// continue;
//}
sum += _itm1.Value;
if (sum > 10000000)
{
break;
}
invoiceGroupNumList.Add(_itm1.Key);//所有条件都满足添加发票和结算分组对应关系
}
invoiceMap.Add(invoiceBillNum, invoiceGroupNumList);//记录发票对应关系
foreach (var rem in invoiceGroupNumList)//移除
{
copyDic.Remove(rem);
}
}
}
if (invoiceMap.Keys.Count > 0)
{
var groupList = new List<INVOICE_MAP_GROUP>();
var notDetialList = new List<INVOICE_NOT_SETTLE>();
var detailList = new List<INVOICE_WAIT_DETAIL>();
var invlist = new List<INVOICE_GRP>();
foreach (var itm in invoiceMap)//分组影响和
{
var key = itm.Key;//发票票号
var ls = itm.Value;//结算分组号列表
var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.LU, p.Price, p.BeginDate, p.EndDate })
.Select(itm => new
{
InvGroupNum = itm.Key.InvGroupNum,
LU = itm.Key.LU,
Price = itm.Key.Price,
Amt = Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),
Qty = itm.Sum(k => k.Qty),
BeginDate = itm.Key.BeginDate,
EndDate = itm.Key.EndDate
})
.ToList();
decimal amt = detailDtos.Sum(k => k.Amt);
decimal txtAmt = Math.Round(detailDtos.Sum(k => k.Amt), 2);
var mapList = new List<INVOICE_MAP_GROUP>();
foreach (var groupnum in ls)
{
mapList.Add(new INVOICE_MAP_GROUP(
guid: GuidGenerator.Create(),
version: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
settleGroupNum: groupnum,
amt: 0,
extend1: string.Empty,
extend2: string.Empty
)
);
}
if (mapList.Count > 0)
{
groupList.AddRange(mapList);
}
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
foreach (var detail in detailDtos)
{
_entityDetailList.Add(
new INVOICE_WAIT_DETAIL(
guid: GuidGenerator.Create(),
version: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
lU: detail.LU,
qty: detail.Qty,
bussiessType: EnumBusinessType.JisHBPO,
amt: detail.Amt,
pRICE: detail.Price,
extend1: string.Empty,
extend2: string.Empty,
beginDate: detail.BeginDate,
endDate: detail.EndDate
));
}
if (_entityDetailList.Count > 0)
{
detailList.AddRange(_entityDetailList);
}
// var notls = notList.GroupBy(p => new { p.GroupNum, p.LU }).Select(p => new { GroupNum = p.Key.GroupNum, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty) });
//var innotls = new List<INVOICE_NOT_SETTLE>();
//foreach (var nitm in notls)
//{
// innotls.Add(new INVOICE_NOT_SETTLE(
// guid: GuidGenerator.Create(),
// version: main.Version,
// invGroupNum: main.InvGroupNum,
// settleGroupNum: nitm.GroupNum,
// lU: string.Empty,
// lU1: nitm.LU,
// extend1: string.Empty,
// extend2: string.Empty,
// qty: nitm.Qty
// ));
//}
//if (innotls.Count > 0)
//{
// notDetialList.AddRange(innotls);
//}
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
invbillNum: key,
amt: amt,
taxAmt: txtAmt,
fileName: string.Empty,
businessType: EnumBusinessType.JisHBPO,
invGroupNum: main.InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.,
tax:0,
parent:string.Empty
);
invlist.Add(invbill);
}
await _repository.DbContext.BulkInsertAsync(invlist);
await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
await _repository.DbContext.BulkInsertAsync(notDetialList);
}
await FirstInvoice(dtos,new List<TEMP_NOT_SA_DETAIL>(), main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
}
else//二次开票
{
var groups1 = dtos.GroupBy(p => new { p.LU, p.Price, p.BeginDate, p.EndDate }).Select(p => new TMEP_INV
{
LU = p.Key.LU,
Amt = p.Sum(itm => itm.Amt),
Qty = p.Sum(itm => itm.Qty),
Price = p.Key.Price,
BeginDate = p.Key.BeginDate,
EndDate = p.Key.EndDate
}).ToList();//汇总记录不出现重复值
var groups = dtos.GroupBy(p => new { p.LU, p.Price, p.BeginDate, p.EndDate }).Select(p => new TMEP_INV
{
LU = p.Key.LU,
Amt = p.Sum(itm => itm.Amt),
Qty = p.Sum(itm => itm.Qty),
Price = p.Key.Price,
BeginDate = p.Key.BeginDate,
EndDate = p.Key.EndDate
}).ToList();//汇总记录不出现重复值
Dictionary<string, List<TMEP_INV>> invoiceMap = new Dictionary<string, List<TMEP_INV>>();//发票和发票明细关系
foreach (var group in groups)
{
int i = groups1.Count(p => p.LU == group.LU && p.BeginDate == group.BeginDate && p.EndDate == group.EndDate);
if (i > 0)
{
string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("CINV");
List<TMEP_INV> tempList = new List<TMEP_INV>();
decimal sum = group.Amt;//初始合计金额
int partCount = 0;
foreach (var group1 in groups1)
{
if (group.LU == group1.LU && group.BeginDate == group1.BeginDate && group.EndDate == group1.EndDate)
{
tempList.Add(group1);
partCount++;//符合条件加入到零件中
continue;
}
partCount++;
if (partCount > 30)
{
continue;
}
if (sum > 10000000)
{
break;
}
sum += group1.Amt;
tempList.Add(group1);
}
invoiceMap.Add(invoiceBillNum, tempList);
var query = from itm in groups1
join itm1 in tempList
on new { itm.LU, itm.BeginDate, itm.EndDate } equals new { itm1.LU, itm1.BeginDate, itm1.EndDate } into temp
from tm in temp
where tm == null
select new TMEP_INV { LU = itm.LU, Amt = itm.Amt, Qty = itm.Qty, BeginDate = itm.BeginDate, EndDate = itm.EndDate };
groups1 = query.ToList();
}
await SecInvoice(dtos, main.Version, main.InvGroupNum, string.Empty, main.BusinessType);
}
if (invoiceMap.Count > 0)
{
var groupList = new List<INVOICE_MAP_GROUP>();
var notDetialList = new List<INVOICE_NOT_SETTLE>();
var detailList = new List<INVOICE_WAIT_DETAIL>();
var invlist = new List<INVOICE_GRP>();
foreach (var group in invoiceMap)
{
var key = group.Key;//发票票号
var ls = group.Value;//发票明细
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
foreach (var detail in ls)
{
_entityDetailList.Add(
new INVOICE_WAIT_DETAIL(
guid: GuidGenerator.Create(),
version: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
lU: detail.LU,
qty: detail.Qty,
bussiessType: EnumBusinessType.JisBBAC,
amt: detail.Amt,
pRICE: detail.Price,
extend1: string.Empty,
extend2: string.Empty,
beginDate: detail.BeginDate,
endDate: detail.EndDate
));
}
if (_entityDetailList.Count > 0)
{
detailList.AddRange(_entityDetailList);
}
decimal amt = detailList.Sum(k => k.Amt);
decimal txtAmt = Math.Round(detailList.Sum(k => k.Amt), 2);
var contractList = ls.Select(p => p.ContractDocID).Distinct();
var _groupList = dtos.GroupBy(p => new { p.GroupNum })
.Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) }).Distinct();
List<INVOICE_MAP_GROUP> group1 = new List<INVOICE_MAP_GROUP>();
foreach (var en in _groupList)
{
group1.Add(
new INVOICE_MAP_GROUP(
guid: GuidGenerator.Create(),
version: main.Version,
invbillNum: key,
invGroupNum: main.InvGroupNum,
settleGroupNum: en.GroupNum,
amt: en.Amt,
extend1: string.Empty,
extend2: string.Empty));
}
if (group1.Count > 0)
{
groupList.AddRange(group1);
}
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
invbillNum: key,
amt: amt,
taxAmt: txtAmt,
fileName: string.Empty,
businessType: EnumBusinessType.JisHBPO,
invGroupNum: main.InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.,
tax:0,
parent:string.Empty
);
invlist.Add(invbill);
}
await _repository.DbContext.BulkInsertAsync(invlist);
await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
//await _repository.DbContext.BulkInsertAsync(notDetialList);
}
}
}
}
}

14
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
@ -13,11 +12,13 @@ using InfluxDB.LineProtocol.Client;
using Magicodes.ExporterAndImporter.Core.Extension;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.Extensions.Configuration;
using Microsoft.OpenApi.Extensions;
using SettleAccount.Job.SignalR;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.BlobStoring;
@ -51,18 +52,21 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
private readonly INormalEfCoreRepository<VmiLog, Guid> _logRepository;
private readonly INormalEfCoreRepository<VmiSnapshot, Guid> _snapshotRepository;
private readonly IBlobContainer<MyFileContainer> _fileContainer;
private readonly IHubContext<PageHub> _hubContext;
public VmiAppService(IConfiguration cfg,
INormalEfCoreRepository<VmiBalance, Guid> balanceRepository,
INormalEfCoreRepository<VmiLog, Guid> logRepository,
INormalEfCoreRepository<VmiSnapshot, Guid> snapshotRepository,
IBlobContainer<MyFileContainer> fileContainer)
IBlobContainer<MyFileContainer> fileContainer,
IHubContext<PageHub> hubContext)
{
this._cfg = cfg;
this._balanceRepository = balanceRepository;
this._logRepository = logRepository;
this._snapshotRepository = snapshotRepository;
this._fileContainer = fileContainer;
this._hubContext = hubContext;
}
/// <summary>
@ -70,8 +74,9 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
/// </summary>
[HttpPost]
[UnitOfWork]
public void Invoke()
public virtual Task Invoke()
{
this._hubContext.Clients.All.ServerToClient("JobItem", "refresh", "");
Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/files/vmi"));
var date = DateTime.Now.ToString("yyyyMMddHH");
var connectionString = $"Data Source=wwwroot/files/vmi/{date}.db";
@ -87,7 +92,8 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
var snapshot = new VmiSnapshot { Name = date, Path = connectionString };
this._snapshotRepository.InsertAsync(snapshot).Wait();
}
Debug.WriteLine($"{nameof(VmiAppService)}:{DateTime.Now}");
this._hubContext.Clients.All.ServerToClient("JobItem", "refresh", "");
return Task.CompletedTask;
}
/// <summary>

4
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_CAN_SA_MNG.cs

@ -51,9 +51,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
/// <summary>
/// 向前流程
/// </summary>
@ -209,7 +206,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
public virtual async Task<bool> SetNewState(BBAC_CAN_SA p_entiy)
{
return await SetNewState(p_entiy.BillNum);
}

464
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs

@ -1,6 +1,7 @@
using EFCore.BulkExtensions;
using Hangfire;
using Microsoft.AspNetCore.SignalR;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.EntityFrameworkCore;
using NPOI.SS.Formula.Functions;
using SettleAccount.Bases;
@ -14,6 +15,9 @@ using Volo.Abp;
using Volo.Abp.Auditing;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Domain.Services;
using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.Entities.BQ.Temp;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
@ -36,9 +40,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
PUB_CAN_SA_MNG pubMng,
BBAC_CAN_SA_MNG bbacMng,
HBPO_CAN_SA_MNG hbpoMng,
INormalEfCoreRepository<INVOICE_GRP, Guid> repository,
INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> groupRepository,
INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> detailRepository,
@ -133,12 +134,18 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
/// <exception cref="BusinessException"></exception>
public virtual async Task<bool> SetForwardState(INVOICE_GRP p_entiy, SettleBillState p_State)
{
if (p_entiy.InvoiceState == InvoiceBillState.)
{
throw new BusinessException("8989", "当前发票已报废不能进行操作");
}
var state = p_State;
switch (p_State)
{
case SettleBillState.:
if (p_entiy.State == SettleBillState.)
{
p_entiy.State = state;
}
else
@ -167,8 +174,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
break;
}
var flag = await SetSettleState(p_entiy, p_State, true);
if (flag == true)
{
@ -242,9 +247,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
/// </summary>
/// <param name="p_billNum"></param>
/// <returns></returns>
public virtual async Task<INVOICE_GRP> GetMainAsync(string p_groupbillNum)
public virtual async Task<INVOICE_GRP> GetMainAsync(string p_invbillNum)
{
return await _repository.Where(p => p.InvbillNum == p_groupbillNum).FirstOrDefaultAsync();
return await _repository.Where(p => p.InvbillNum == p_invbillNum).FirstOrDefaultAsync();
}
/// <summary>
@ -431,12 +436,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
/// <returns></returns>
public virtual async Task<bool> Reject(string groupbillNum)
{
var _ls=await _repository.Where(p => p.InvGroupNum == groupbillNum).ToListAsync();
if (_ls != null && _ls.Count > 0)
var ls = await _repository.Where(p => p.InvGroupNum == groupbillNum).ToListAsync();
if (ls != null && ls.Count > 0)
{
foreach (var p_entity in _ls)
var first = ls.FirstOrDefault();
if(first.State==SettleBillState. || first.State== SettleBillState.)
{
throw new BusinessException("8989",$"发票分组{groupbillNum}客户已经是客户已收票或已扣减状态不能退回");
}
foreach (var p_entity in ls)
{
if (p_entity.State == SettleBillState.
|| p_entity.State == SettleBillState. || p_entity.State == SettleBillState.)
@ -445,26 +453,30 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
var groupList = _groupRepository.Where(p => p.InvGroupNum == p_entity.InvGroupNum).ToList();
var notList = _notRepository.Where(p => p.InvGroupNum == p_entity.InvGroupNum).ToList();
var detailList = _detailRepository.Where(p => p.InvGroupNum == p_entity.InvGroupNum).ToList();
//var canList = _canRepository.Where(p => p.InvGroupNum == p_entity.InvGroupNum).ToList();
//foreach (var itm in canList)
//{
// itm.State = SettleBillState.未结状态;
//}
await _repository.DbContext.BulkDeleteAsync(entList);
await _repository.DbContext.BulkDeleteAsync(groupList);
await _repository.DbContext.BulkDeleteAsync(notList);
await _repository.DbContext.BulkDeleteAsync(detailList);
//await _repository.DbContext.BulkUpdateAsync(canList);
if (first.BusinessType == EnumBusinessType.JisBBAC)
{
await _bbacMng.SetNewState(groupbillNum);
}
if (p_entity.State == SettleBillState.)
else if (first.BusinessType == EnumBusinessType.JisHBPO)
{
await _hbpoMng.SetNewState(groupbillNum);
}
else
{
await _pubMng.SetNewState(groupbillNum);
}
//await _repository.DbContext.BulkUpdateAsync(canList);
}
}
}
else
{
throw new BusinessException("8989",$"查询不到发票分组号为{groupbillNum}发票分组");
}
return true;
}
@ -533,11 +545,421 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
/// <summary>
/// hbpo、jit、备件等
/// </summary>
/// <param name="dtos">可结算明细列表</param>
/// <param name="p_version">版本号</param>
/// <param name="p_InvGroupNum">发票分组</param>
/// <param name="p_parentInvBillNum">原发票号</param>
public async Task<bool> SecInvoice(List<TEMP_CAN_SA_DETAIL> dtos, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType)
{
var groups1 = dtos.GroupBy(p => new { p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV
{
LU = p.Key.LU,
Amt = p.Sum(itm => itm.Amt),
Qty = p.Sum(itm => itm.Qty),
ContractDocID = p.Key.ContractDocID,
Price = p.Key.Price,
BeginDate = p.Key.BeginDate,
EndDate = p.Key.EndDate
}).ToList();//汇总记录不出现重复值
var groups = dtos.GroupBy(p => new { p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID }).Select(p => new TMEP_INV
{
LU = p.Key.LU,
Amt = p.Sum(itm => itm.Amt),
Qty = p.Sum(itm => itm.Qty),
Price = p.Key.Price,
BeginDate = p.Key.BeginDate,
EndDate = p.Key.EndDate
}).ToList();//汇总记录不出现重复值
Dictionary<string, List<TMEP_INV>> invoiceMap = new Dictionary<string, List<TMEP_INV>>();//发票和发票明细关系
foreach (var group in groups)
{
int i = groups1.Count(p => p.LU == group.LU
&& p.BeginDate == group.BeginDate
&& p.EndDate == group.EndDate
&& p.ContractDocID == group.ContractDocID
);
if (i > 0)
{
string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("CINV");
List<TMEP_INV> tempList = new List<TMEP_INV>();
decimal sum = group.Amt;//初始合计金额
int partCount = 0;
foreach (var group1 in groups1)
{
if (group.LU == group1.LU
&& group.BeginDate == group1.BeginDate
&& group.EndDate == group1.EndDate
&& group1.ContractDocID == group.ContractDocID
)
{
tempList.Add(group1);
partCount++;//符合条件加入到零件中
continue;
}
partCount++;
if (partCount > 30)
{
continue;
}
if (sum > 10000000)
{
break;
}
sum += group1.Amt;
tempList.Add(group1);
}
invoiceMap.Add(invoiceBillNum, tempList);
var query = from itm in groups1
join itm1 in tempList
on new { itm.LU, itm.BeginDate, itm.EndDate, itm.ContractDocID }
equals new { itm1.LU, itm1.BeginDate, itm1.EndDate, itm1.ContractDocID } into temp
from tm in temp
where tm == null
select new TMEP_INV
{
LU = itm.LU,
Amt = itm.Amt,
Qty = itm.Qty,
BeginDate = itm.BeginDate,
ContractDocID = itm.ContractDocID,
EndDate = itm.EndDate
};
groups1 = query.ToList();
}
}
if (invoiceMap.Count > 0)
{
var groupList = new List<INVOICE_MAP_GROUP>();
var notDetialList = new List<INVOICE_NOT_SETTLE>();
var detailList = new List<INVOICE_WAIT_DETAIL>();
var invlist = new List<INVOICE_GRP>();
foreach (var group in invoiceMap)
{
var key = group.Key;//发票票号
var ls = group.Value;//发票明细
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
foreach (var detail in ls)
{
_entityDetailList.Add(
new INVOICE_WAIT_DETAIL(
guid: GuidGenerator.Create(),
version: p_version,
invbillNum: key,
invGroupNum: p_InvGroupNum,
lU: detail.LU,
qty: detail.Qty,
bussiessType: businessType,
amt: detail.Amt,
pRICE: detail.Price,
extend1: string.Empty,
extend2: string.Empty,
beginDate: detail.BeginDate,
endDate: detail.EndDate
));
}
if (_entityDetailList.Count > 0)
{
detailList.AddRange(_entityDetailList);
}
decimal amt = detailList.Sum(k => k.Amt);
decimal txtAmt = Math.Round(detailList.Sum(k => k.Amt), 2);
var contractList = ls.Select(p => p.ContractDocID).Distinct();
var _groupList = dtos.Where(p => contractList.Contains(p.ContractDocID)).GroupBy(p => new { p.GroupNum })
.Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) }).Distinct();
//var _groupList = dtos.GroupBy(p => new { p.GroupNum })
// .Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) }).Distinct();
List<INVOICE_MAP_GROUP> group1 = new List<INVOICE_MAP_GROUP>();
foreach (var en in _groupList)
{
group1.Add(
new INVOICE_MAP_GROUP(
guid: GuidGenerator.Create(),
version: p_version,
invbillNum: key,
invGroupNum: p_InvGroupNum,
settleGroupNum: en.GroupNum,
amt: en.Amt,
extend1: string.Empty,
extend2: string.Empty));
}
if (group1.Count > 0)
{
groupList.AddRange(group1);
}
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
invbillNum: key,
amt: amt,
taxAmt: txtAmt,
fileName: string.Empty,
businessType: businessType,
invGroupNum: p_InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.,
tax: 0,
parent: p_parentInvBillNum
);
invlist.Add(invbill);
}
await _repository.DbContext.BulkInsertAsync(invlist);
await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
//await _repository.DbContext.BulkInsertAsync(notDetialList);
return true;
}
return false;
}
/// <summary>
/// 第一次开票
/// </summary>
/// <param name="dtos"></param>
/// <param name="p_notlist"></param>
/// <param name="p_version"></param>
/// <param name="p_InvGroupNum"></param>
/// <param name="p_parentInvBillNum"></param>
/// <param name="businessType"></param>
/// <returns></returns>
public async Task<bool> FirstInvoice(List<TEMP_CAN_SA_DETAIL> dtos, List<TEMP_NOT_SA_DETAIL> p_notlist, int p_version, string p_InvGroupNum, string p_parentInvBillNum, EnumBusinessType businessType)
{
var _query = dtos.GroupBy(p => new { p.GroupNum }).Select(p => new { GroupNum = p.Key.GroupNum, Amt = p.Sum(itm => itm.Amt) });
Dictionary<string, decimal> dic = new Dictionary<string, decimal>();//原本
Dictionary<string, decimal> copyDic = new Dictionary<string, decimal>();//变换数组副本
foreach (var itm in _query.ToList())
{
dic.Add(itm.GroupNum, itm.Amt);
copyDic.Add(itm.GroupNum, itm.Amt);
}
Dictionary<string, List<string>> invoiceMap = new Dictionary<string, List<string>>();
foreach (var itm in dic)
{
string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("INV");
List<string> invoiceGroupNumList = new List<string>();//每个发票对应的结算分组号
List<string> List = new List<string>();
decimal sum = itm.Value;//初始分组合计金额
// List<string> luList = dtos.Where(p => p.GroupNum == itm.Key).Select(p => p.LU).Distinct().ToList(); //初始LU种类
if (copyDic.ContainsKey(itm.Key) == true)//是否存在分组
{
foreach (var _itm1 in copyDic)
{
if (itm.Key == _itm1.Key)//相同结算分组项不计算,已初始化
{
invoiceGroupNumList.Add(itm.Key);
continue;
}
//var grouplist = dtos.Where(p => p.GroupNum == _itm1.Key).Select(p => p.LU).Distinct().ToList();//每项LU种类
//luList.AddRange(grouplist);
//luList = luList.Distinct().ToList();
//if (luList.Count > 20)//累加零件不超过20种
//{
// continue;
//}
sum += _itm1.Value;
if (sum > 10000000)
{
break;
}
invoiceGroupNumList.Add(_itm1.Key);//所有条件都满足添加发票和结算分组对应关系
}
invoiceMap.Add(invoiceBillNum, invoiceGroupNumList);//记录发票对应关系
foreach (var rem in invoiceGroupNumList)//移除
{
copyDic.Remove(rem);
}
}
}
if (invoiceMap.Keys.Count > 0)
{
var groupList = new List<INVOICE_MAP_GROUP>();
var notDetialList = new List<INVOICE_NOT_SETTLE>();
var detailList = new List<INVOICE_WAIT_DETAIL>();
var invlist = new List<INVOICE_GRP>();
foreach (var itm in invoiceMap)//分组影响和
{
var key = itm.Key;//发票票号
var ls = itm.Value;//结算分组号列表
var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.LU, p.Price, p.BeginDate, p.EndDate, p.ContractDocID })
.Select(itm => new
{
InvGroupNum = itm.Key.InvGroupNum,
LU = itm.Key.LU,
ContactDocID = itm.Key.ContractDocID,
Price = itm.Key.Price,
Amt = Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),
Qty = itm.Sum(k => k.Qty),
BeginDate = itm.Key.BeginDate,
EndDate = itm.Key.EndDate
})
.ToList();
decimal amt = detailDtos.Sum(k => k.Amt);
decimal txtAmt = Math.Round(detailDtos.Sum(k => k.Amt), 2);
var mapList = new List<INVOICE_MAP_GROUP>();
foreach (var groupnum in ls)
{
mapList.Add(new INVOICE_MAP_GROUP(
guid: GuidGenerator.Create(),
version: p_version,
invbillNum: key,
invGroupNum: p_InvGroupNum,
settleGroupNum: groupnum,
amt: 0,
extend1: string.Empty,
extend2: string.Empty
)
);
}
if (mapList.Count > 0)
{
groupList.AddRange(mapList);
}
List<INVOICE_WAIT_DETAIL> _entityDetailList = new List<INVOICE_WAIT_DETAIL>();
foreach (var detail in detailDtos)
{
_entityDetailList.Add(
new INVOICE_WAIT_DETAIL(
guid: GuidGenerator.Create(),
version: p_version,
invbillNum: key,
invGroupNum: p_InvGroupNum,
lU: detail.LU,
qty: detail.Qty,
bussiessType: businessType,
amt: detail.Amt,
pRICE: detail.Price,
extend1: string.Empty,
extend2: string.Empty,
beginDate: detail.BeginDate,
endDate: detail.EndDate
));
}
if (_entityDetailList.Count > 0)
{
detailList.AddRange(_entityDetailList);
}
var innotls = new List<INVOICE_NOT_SETTLE>();
if (p_notlist != null && p_notlist.Count > 0)
{
var notls = p_notlist.GroupBy(p => new { p.GroupNum, p.LU }).Select(p => new { GroupNum = p.Key.GroupNum, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty) });
foreach (var nitm in notls)
{
innotls.Add(new INVOICE_NOT_SETTLE(
guid: GuidGenerator.Create(),
version: p_version,
invGroupNum: p_InvGroupNum,
settleGroupNum: nitm.GroupNum,
lU: string.Empty,
lU1: nitm.LU,
extend1: string.Empty,
extend2: string.Empty,
qty: nitm.Qty
));
}
if (innotls.Count > 0)
{
notDetialList.AddRange(innotls);
}
}
var invbill = new INVOICE_GRP
(guid: GuidGenerator.Create(),
realnvBillNum: string.Empty,
invbillNum: key,
amt: amt,
taxAmt: txtAmt,
fileName: string.Empty,
businessType: businessType,
invGroupNum: p_InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.,
tax: 0,
parent: string.Empty
);
invlist.Add(invbill);
}
await _repository.DbContext.BulkInsertAsync(invlist);
await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
if (notDetialList.Count > 0)
{
await _repository.DbContext.BulkInsertAsync(notDetialList);
}
}
return true;
}
/// <summary>
///
/// </summary>
/// <param name="dtos"></param>
/// <param name="p_OldInvBillNum"></param>
/// <param name="p_version"></param>
/// <returns></returns>
/// <exception cref="BusinessException"></exception>
public async Task<bool> ReissueFirstInvoice(List<TEMP_CAN_SA_DETAIL> dtos, string p_OldInvBillNum, int p_version)
{
if (!string.IsNullOrEmpty(p_OldInvBillNum))
{
var inv = await GetInvoiceAsync(p_OldInvBillNum);
if (inv == null)
{
throw new BusinessException("8989", $"找不到选择要重开发票号{p_OldInvBillNum}不能重开");
}
if (inv.InvoiceState == InvoiceBillState.)
{
throw new BusinessException("8989", $"选择要重开发票号{p_OldInvBillNum}已经作废不能重开");
}
inv.InvoiceState = InvoiceBillState.;
await FirstInvoice(dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType);
_repository.DbContext.BulkUpdate(new List<INVOICE_GRP> { inv });
return true;
}
return false;
}
/// <summary>
///
/// </summary>
/// <param name="dtos"></param>
/// <param name="p_OldInvBillNum"></param>
/// <param name="p_version"></param>
/// <returns></returns>
/// <exception cref="BusinessException"></exception>
public async Task<bool> ReissueSecInvoice(List<TEMP_CAN_SA_DETAIL> dtos, string p_OldInvBillNum, int p_version)
{
if (!string.IsNullOrEmpty(p_OldInvBillNum))
{
var inv = await GetInvoiceAsync(p_OldInvBillNum);
if (inv == null)
{
throw new BusinessException("8989", $"找不到选择要重开发票号{p_OldInvBillNum}不能重开");
}
if (inv.InvoiceState == InvoiceBillState.)
{
throw new BusinessException("8989", $"选择要重开发票号{p_OldInvBillNum}已经作废不能重开");
}
inv.InvoiceState = InvoiceBillState.;
await FirstInvoice(dtos, new List<TEMP_NOT_SA_DETAIL>(), p_version, inv.InvGroupNum, inv.InvbillNum, inv.BusinessType);
_repository.DbContext.BulkUpdate(new List<INVOICE_GRP> { inv });
return true;
}
return false;
}
}
}

183
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Temp/TempClass.cs

@ -0,0 +1,183 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SettleAccount.Bases;
namespace Win.Sfs.SettleAccount.Entities.BQ.Temp;
public class TMEP_INV
{
public string LU { set; get; }
public string ContractDocID { set; get; }
public decimal Amt { set; get; }
public decimal Qty { set; get; }
public decimal Price { set; get; }
/// <summary>
/// 开始日期
/// </summary>
public DateTime BeginDate { get; set; }
/// <summary>
/// 结束日期
/// </summary>
public DateTime EndDate { get; set; }
}
public class TEMP_CAN_SA_DETAIL
{
/// <summary>
///关联结算单号
/// </summary>
public string SettleBillNum { get; set; }
/// <summary>
///工厂地点
/// </summary>
public string Site { get; set; }
/// <summary>
/// 版本
/// </summary>
public int Version { get; set; }
/// <summary>
/// 单价
/// </summary>
public decimal Price { get; set; }
/// <summary>
/// 结算单号(发票分组号)
/// </summary>
public string BillNum { get; set; }
/// <summary>
/// 结算日期
/// </summary>
public DateTime SettleDate { get; set; }
/// <summary>
///发票组号
/// </summary>
public string InvGroupNum { get; set; }
/// <summary>
/// 零件号
/// </summary>
public string LU { get; set; }
/// <summary>
/// 物料描述
/// </summary>
public string MaterialDesc { get; set; }
/// <summary>
/// 生产号
/// </summary>
public string PN { get; set; }
/// <summary>
/// 结算数量
/// </summary>
public decimal Qty { get; set; }
/// <summary>
/// 结算分组号
/// </summary>
public string GroupNum { get; set; }
/// <summary>
/// 金额
/// </summary>
public decimal Amt { get; set; }
/// <summary>
/// 合同号
/// </summary>
public string ContractDocID { set; get; }
/// <summary>
/// 开始日期
/// </summary>
public DateTime BeginDate { get; set; }
/// <summary>
/// 结束日期
/// </summary>
public DateTime EndDate { get; set; }
}
public class TEMP_NOT_SA_DETAIL : SA_NOT_BASE
{
///// <summary>
///// 对应字段(Material+ExternalCalNumber)
///// </summary>
//[Display(Name = "LU+生产码")]
//public string KeyCode { get; set; } = null!;
///// <summary>
///// 期间
///// </summary>
//[Display(Name = "期间")]
//public int Version { get; set; }
///// <summary>
///// 结算单号
///// </summary>
//[Display(Name = "结算单号")]
//public string SettleBillNum { get; set; } = null!;
///// <summary>
///// 对应字段Material
///// </summary>
//[Display(Name = "零件号")]
//public string LU { get; set; } = null!;
///// <summary>
///// 对应字段ExternalCalNumber
///// </summary>
//[Display(Name = "生产码")]
//public string PN { get; set; } = null!;
/// <summary>
/// 选择工厂导入
/// </summary>
[Display(Name = "工厂地点")]
public string Site { get; set; } = null!;
/// <summary>
/// 对应字段Quantity
/// </summary>
//[Display(Name = "结算数量")]
//public decimal Qty { get; set; }
///// <summary>
///// 匹配价格表对应区间对应地点带出
///// </summary>
//[Display(Name = "单价")]
//public decimal Price { get; set; }
/// <summary>
/// ExternalCallNumber包含(R0)为买单件 1为JIS 2.为买单件
/// </summary>
[Display(Name = "业务类别")]
public EnumBusinessType BusinessType { get; set; }
/// <summary>
/// 对应字段MovementType,996正常,997为退货
/// </summary>
[Display(Name = "是否退货")]
public string IsReturn { get; set; } = null!;
//[Display(Name = "发票分组号")]
//public string InvGroupNum { get; set; } = null!;
///// <summary>
///// 对应字段PostingDate
///// </summary>
//[Display(Name = "结算日期(收货日期)")]
//public DateTime SettleDate { get; set; }
/// <summary>
/// 对应字段Reference
/// </summary>
//[Display(Name = "结算分组")]
//public string GroupNum { get; set; } = null!;
[Display(Name = "合同号")]
public string ContractDocID { get; set; }
}

4
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/IJobService.cs

@ -1,6 +1,8 @@
using System.Threading.Tasks;
namespace Win.Sfs.SettleAccount.Entities.BQ.Vmi;
public interface IJobService
{
void Invoke();
Task Invoke();
}

2
code/src/Modules/SettleAccount/src/SettleAccount.Domain/EnumBillState.cs

@ -35,7 +35,7 @@ namespace Win.Sfs.SettleAccount
public enum InvoiceBillState
{
[Description("正常")]
[Description("在用")]
= 1,
[Description("报废")]
= 2,

Loading…
Cancel
Save