增加采购汇总 查询的 明细

This commit is contained in:
杰 朱
2021-05-25 11:59:26 +08:00
parent 0929b0e37d
commit 9f8d2a177a
5 changed files with 329 additions and 42 deletions

View File

@@ -16,8 +16,15 @@ namespace NX.ERP.Model.Request
public string cpersonname { get; set; } public string cpersonname { get; set; }
public int cday { get; set; } public int cday { get; set; }
public int mouth { get; set; }
public DateTime? BeginDate { get; set; }
public DateTime? EndDate { get; set; }
public DateTime? BeginDate2 { get; set; }
public DateTime? EndDate2 { get; set; }

View File

@@ -200,10 +200,10 @@ namespace NX.ERP.U8.Purchase
} }
} }
public IEnumerable<object> Purchasesum() public IEnumerable<object> Purchasesum(NX.ERP.Model.Request.PurchasesumRequest info)
{ {
string sql = $@" string sql = $@"
DECLARE @RdRecord table( DECLARE @RdRecord table(
cPsn_Num nvarchar(30), cPsn_Num nvarchar(30),
cpersonname nvarchar(30), cpersonname nvarchar(30),
puappnumall int, puappnumall int,
@@ -318,7 +318,7 @@ namespace NX.ERP.U8.Purchase
mom_morder mor WITH (NOLOCK) ON ma.MoDId= mor.MoDId mom_morder mor WITH (NOLOCK) ON ma.MoDId= mor.MoDId
WHERE md.Status <> 4 AND ma.Qty - ISNULL(ma.IssQty, 0) > 0 and WHERE md.Status <> 4 AND ma.Qty - ISNULL(ma.IssQty, 0) > 0 and
convert(varchar,mor.DueDate,112) < convert(varchar,dateadd(day,-day(getdate()),dateadd(month,3,getdate())),112) mor.DueDate between @beginDate and @endDate
GROUP BY ma.InvCode GROUP BY ma.InvCode
) a left join ) a left join
CurrentStock cur WITH (NOLOCK) ON cur.cInvCode = a.InvCode where (cur.iQuantity -iqty) <0) OM CurrentStock cur WITH (NOLOCK) ON cur.cInvCode = a.InvCode where (cur.iQuantity -iqty) <0) OM
@@ -337,8 +337,8 @@ namespace NX.ERP.U8.Purchase
update a set a.mommouth02=b.puappnumall From @RdRecord a left join @RdRecord4 b on a.cpersonname =b.cpersonname update a set a.mommouth02=b.puappnumall From @RdRecord a left join @RdRecord4 b on a.cpersonname =b.cpersonname
update a set a.mommouth02= a.puappnumall +b.puappnumall From @RdRecord a left join ( update a set a.mommouth02= a.mommouth02 +b.mommouth02 From @RdRecord a left join (
select '其他' as cpersonname ,sum(puappnumall) as puappnumall from @RdRecord4 where cpersonname not in (select cpersonname From @RdRecord) )b on a.cpersonname =b.cpersonname select '其他' as cpersonname ,sum(puappnumall) as mommouth02 from @RdRecord4 where cpersonname not in (select cpersonname From @RdRecord) )b on a.cpersonname =b.cpersonname
where a.cpersonname='其他' where a.cpersonname='其他'
@@ -355,7 +355,7 @@ namespace NX.ERP.U8.Purchase
mom_morder mor WITH (NOLOCK) ON ma.MoDId= mor.MoDId mom_morder mor WITH (NOLOCK) ON ma.MoDId= mor.MoDId
WHERE md.Status <> 4 AND ma.Qty - ISNULL(ma.IssQty, 0) > 0 and WHERE md.Status <> 4 AND ma.Qty - ISNULL(ma.IssQty, 0) > 0 and
convert(varchar,mor.DueDate,112) < convert(varchar,dateadd(day,-day(getdate()),dateadd(month,5,getdate())),112) mor.DueDate between @beginDate2 and @endDate2
GROUP BY ma.InvCode GROUP BY ma.InvCode
) a left join ) a left join
CurrentStock cur WITH (NOLOCK) ON cur.cInvCode = a.InvCode where (cur.iQuantity -iqty) <0) OM CurrentStock cur WITH (NOLOCK) ON cur.cInvCode = a.InvCode where (cur.iQuantity -iqty) <0) OM
@@ -376,8 +376,8 @@ namespace NX.ERP.U8.Purchase
update a set a.mommouth04=b.puappnumall From @RdRecord a left join @RdRecord5 b on a.cpersonname =b.cpersonname update a set a.mommouth04=b.puappnumall From @RdRecord a left join @RdRecord5 b on a.cpersonname =b.cpersonname
update a set a.mommouth04= a.puappnumall +b.puappnumall From @RdRecord a left join ( update a set a.mommouth04= a.mommouth04 +b.mommouth04 From @RdRecord a left join (
select '其他' as cpersonname ,sum(puappnumall) as puappnumall from @RdRecord5 where cpersonname not in (select cpersonname From @RdRecord) )b on a.cpersonname =b.cpersonname select '其他' as cpersonname ,sum(puappnumall) as mommouth04 from @RdRecord5 where cpersonname not in (select cpersonname From @RdRecord) )b on a.cpersonname =b.cpersonname
where a.cpersonname='其他' where a.cpersonname='其他'
@@ -385,14 +385,13 @@ namespace NX.ERP.U8.Purchase
"; ";
using (var conn = new System.Data.SqlClient.SqlConnection("Data Source =127.0.0.1;Initial Catalog =UFDATA_002_2019;User Id = sa;Password =123;")) using (var conn = NX.ERP.U8.U8LoginContext.Instance.Connection)
{ {
return conn.Query<object>(sql, new { }); return conn.Query<object>(sql, new { info.BeginDate, info.EndDate, info.BeginDate2, info.EndDate2 });
} }
} }
@@ -421,7 +420,7 @@ namespace NX.ERP.U8.Purchase
} }
if (info.InvCodes != null) if (info.InvCodes != null)
{ {
where.Add(" puu.cInvCode = @InvCodes"); where.Add(" puu.cInvCode in @InvCodes");
} }
if (info.cday > 0) if (info.cday > 0)
{ {
@@ -435,11 +434,59 @@ namespace NX.ERP.U8.Purchase
} }
using (var conn = new System.Data.SqlClient.SqlConnection("Data Source =127.0.0.1;Initial Catalog =UFDATA_002_2019;User Id = sa;Password =123;")) using (var conn = NX.ERP.U8.U8LoginContext.Instance.Connection)
{ {
return conn.Query<object>(sql, new { info.cpersonname, info.InvCodes, info.cday }); return conn.Query<object>(sql, new { info.cpersonname, info.InvCodes, info.cday });
} }
} }
public IEnumerable<object> Purchasesummom(NX.ERP.Model.Request.PurchasesumRequest info)
{
string sql = $@"
select *from (
select a.*,isnull(f.cMaker,'其他') as cpersonname ,inv.cInvName,inv.cInvStd from (
select a.InvCode as CINVCODE ,1 as RQTY , iqty,cur.iQuantity, (cur.iQuantity-iqty) as bull From (
SELECT ma.invcode, SUM(isnull(ma.qty, 0) - isnull(issqty, 0)) iqty
FROM mom_moallocate ma WITH (NOLOCK) INNER JOIN
mom_orderdetail md WITH (NOLOCK) ON ma.MoDId = md.MoDId left join
mom_morder mor WITH (NOLOCK) ON ma.MoDId= mor.MoDId
WHERE md.Status <> 4 AND ma.Qty - ISNULL(ma.IssQty, 0) > 0 and
mor.DueDate between @beginDate and @endDate
GROUP BY ma.InvCode
) a left join
CurrentStock cur WITH (NOLOCK) ON cur.cInvCode = a.InvCode where (cur.iQuantity -iqty) <0
) a left join
(select cInvCode,cMaker from ( select cInvCode,ROW_NUMBER() over( partition by b.cInvCode order by a.poid desc) as rownumber ,a.cMaker from PO_Pomain a WITH (NOLOCK), PO_Podetails b WITH (NOLOCK) where a.poid=b.poid)
as c where c.rownumber=1) f on a.CINVCODE=f.cInvCode
left join Inventory inv WITH (NOLOCK) on a.CINVCODE=inv.cInvCode )pumo
";
List<string> where = new List<string>();
if (!string.IsNullOrEmpty(info.cpersonname))
{
where.Add(" pumo.cpersonname = @cpersonname");
}
if (info.InvCodes != null)
{
where.Add(" pumo.cInvCode = @InvCodes");
}
var aa = string.Join(" and ", where.ToArray());
if (!string.IsNullOrEmpty(aa))
{
sql += "where " + aa;
}
using (var conn = NX.ERP.U8.U8LoginContext.Instance.Connection)
{
return conn.Query<object>(sql, new { info.cpersonname, info.InvCodes, info.cday, info.BeginDate, info.EndDate });
}
}
} }
} }

View File

@@ -23,10 +23,10 @@ namespace NX.ERP.WebAPi.Controllers
[HttpPost] [HttpPost]
[Route("api/Purchase/Purchasesum")] [Route("api/Purchase/Purchasesum")]
public IEnumerable<object> Purchasesum() public IEnumerable<object> Purchasesum(NX.ERP.Model.Request.PurchasesumRequest info)
{ {
var PurchaseQuery = new NX.ERP.U8.Purchase.PurchaseQuery(); var PurchaseQuery = new NX.ERP.U8.Purchase.PurchaseQuery();
return PurchaseQuery.Purchasesum(); return PurchaseQuery.Purchasesum( info);
} }
[HttpPost] [HttpPost]
@@ -37,6 +37,14 @@ namespace NX.ERP.WebAPi.Controllers
return PurchaseQuery.Purchasesumpuapp(info); return PurchaseQuery.Purchasesumpuapp(info);
} }
[HttpPost]
[Route("api/Purchase/Purchasesummom")]
public IEnumerable<object> Purchasesummom(NX.ERP.Model.Request.PurchasesumRequest info)
{
var PurchaseQuery = new NX.ERP.U8.Purchase.PurchaseQuery();
return PurchaseQuery.Purchasesummom(info);
}
} }

View File

@@ -17,3 +17,7 @@ export const Purchasesumpuapp = (info) => {
return axios.post('/api/Purchase/Purchasesumpuapp', info) return axios.post('/api/Purchase/Purchasesumpuapp', info)
} }
export const Purchasesummom = (info) => {
return axios.post('/api/Purchase/Purchasesummom', info)
}

View File

@@ -3,18 +3,17 @@
<h4>采购查询汇总</h4> <h4>采购查询汇总</h4>
<div> <div>
<Row :gutter="16"> <Row :gutter="16">
<Col span="20"> <Col span="3">
<Modal width="1366" v-model="modal1" title="详情" @on-cancel="cancel"> <label>生产订单期间1</label>
<Table <div>
style="margin-top: 20px" <DatePicker v-model="filter.dates" type="daterange"></DatePicker>
height="768" </div>
size="small" </Col>
border <Col span="3">
:columns="columnsDetail" <label>生产订单期间2</label>
:data="dataDetail" <div>
> <DatePicker v-model="filter.dates2" type="daterange"></DatePicker>
</Table> </div>
</Modal>
</Col> </Col>
<Col span="4"> <Col span="4">
<Button <Button
@@ -28,12 +27,51 @@
>导出</Button >导出</Button
> >
</Col> </Col>
<Col span="10">
<Modal
width="1366"
v-model="modal1"
title="请购详情"
@on-cancel="cancel"
>
<Table
style="margin-top: 20px"
height="768"
size="small"
border
:columns="columnsDetail"
:data="dataDetail"
>
</Table>
</Modal>
</Col>
<Col span="20">
<Modal
width="1366"
v-model="modal2"
title="缺件详情"
@on-cancel="cancel"
>
<Table
style="margin-top: 20px"
height="768"
size="small"
border
:columns="columnsDetail2"
:data="dataDetail2"
>
</Table>
</Modal>
</Col>
</Row> </Row>
</div> </div>
<Table <Table
style="margin-top: 20px" style="margin-top: 20px"
size="small" size="small"
show-summary
border border
:loading="loading" :loading="loading"
:columns="columns" :columns="columns"
@@ -58,7 +96,7 @@
</template> </template>
<script> <script>
import { Purchasesum,Purchasesumpuapp } from "@/api/Purchase"; import { Purchasesum, Purchasesumpuapp, Purchasesummom } from "@/api/Purchase";
import { import {
pageingData, pageingData,
export_col_to_excel, export_col_to_excel,
@@ -73,19 +111,21 @@ export default {
PageSizeOpts: [10, 15, 20, 30], PageSizeOpts: [10, 15, 20, 30],
pageNo: 1, pageNo: 1,
modal1: false, modal1: false,
modal2: false,
loading: false, loading: false,
strfilter: "", strfilter: "",
multiple: false, multiple: false,
pageSize: 15, pageSize: 15,
dataDetail : [], dataDetail: [],
dataDetail2: [],
datas: [], datas: [],
filter: { filter: {
inv_codes: "", inv_codes: "",
inv_std: "", inv_std: "",
po_codes: "", po_codes: "",
app_codes: "", app_codes: "",
dates: [getMonth("s", -6), getMonth("e", 0)], dates: [getMonth("s", -1), getMonth("e", 0)],
dates2: [getMonth("s", -6), getMonth("e", 2)], dates2: [getMonth("s", -1), getMonth("e", 1)],
by_finish: false, by_finish: false,
}, },
columnsDetail: [ columnsDetail: [
@@ -99,7 +139,7 @@ export default {
align: "center", align: "center",
key: "ccode", key: "ccode",
}, },
{ {
title: "请购日期", title: "请购日期",
align: "center", align: "center",
key: "dDatel", key: "dDatel",
@@ -125,6 +165,43 @@ export default {
key: "RQTY", key: "RQTY",
}, },
], ],
columnsDetail2: [
{
title: "业务员",
align: "center",
key: "cpersonname",
},
{
title: "存货编码",
align: "center",
key: "CINVCODE",
},
{
title: "存货名称",
align: "center",
key: "cInvName",
},
{
title: "规格型号",
align: "center",
key: "cInvStd",
},
{
title: "需求数量",
align: "center",
key: "iqty",
},
{
title: "现存量",
align: "center",
key: "iQuantity",
},
{
title: "补料量",
align: "center",
key: "bull",
},
],
columns: [ columns: [
{ {
title: "业务员", title: "业务员",
@@ -132,7 +209,7 @@ export default {
key: "cpersonname", key: "cpersonname",
}, },
{ {
title: "未下单记录", title: "请购未下单记录",
align: "center", align: "center",
key: "puappnumall", key: "puappnumall",
@@ -165,7 +242,7 @@ export default {
title: "请购三天后未下单记录", title: "请购三天后未下单记录",
align: "center", align: "center",
key: "puappnum03", key: "puappnum03",
render: (h, params) => { render: (h, params) => {
return h("div", [ return h("div", [
h( h(
"a", "a",
@@ -193,11 +270,57 @@ export default {
title: "两个月内计划工单缺品种数", title: "两个月内计划工单缺品种数",
align: "center", align: "center",
key: "mommouth02", key: "mommouth02",
render: (h, params) => {
return h("div", [
h(
"a",
{
props: {
type: "primary",
size: "small",
},
style: { color: "#2db7f5" },
domProps: {
title: params.row.mommouth02, //添加title属性
},
on: {
click: () => {
this.handleShow3(params.row.cpersonname); //点击事件
},
},
},
params.row.mommouth02
),
]);
},
}, },
{ {
title: "四个月内计划工单缺品种数", title: "四个月内计划工单缺品种数",
align: "center", align: "center",
key: "mommouth04", key: "mommouth04",
render: (h, params) => {
return h("div", [
h(
"a",
{
props: {
type: "primary",
size: "small",
},
style: { color: "#2db7f5" },
domProps: {
title: params.row.mommouth04, //添加title属性
},
on: {
click: () => {
this.handleShow4(params.row.cpersonname); //点击事件
},
},
},
params.row.mommouth04
),
]);
},
}, },
], ],
}; };
@@ -222,33 +345,131 @@ export default {
this.loadData(); this.loadData();
}, },
async handleShow(h) { async handleShow(h) {
let _filert2 = { let _filert2 = {
cpersonname: h, cpersonname: h,
cInvCode: null, cInvCode: null,
cday:0 cday: 0,
}; };
let respd = await Purchasesumpuapp(_filert2); let respd = await Purchasesumpuapp(_filert2);
this.dataDetail = sortByKey(respd.data.data, "ccode"); this.dataDetail = sortByKey(respd.data.data, "ccode");
this.modal1 = true; this.modal1 = true;
}, },
async handleShow2(h) { async handleShow2(h) {
let _filert2 = { let _filert2 = {
cpersonname: h, cpersonname: h,
cInvCode: null, cInvCode: null,
cday:3 cday: 3,
}; };
let respd = await Purchasesumpuapp(_filert2); let respd = await Purchasesumpuapp(_filert2);
this.dataDetail = sortByKey(respd.data.data, "ccode"); this.dataDetail = sortByKey(respd.data.data, "ccode");
this.modal1 = true; this.modal1 = true;
}, },
async handleShow3(h) {
let _beginDate = null;
let _endDate = null;
let _beginDate2 = null;
let _endDate2 = null;
if (
this.filter.dates.length == 2 &&
this.filter.dates[0] !== "" &&
this.filter.dates[0] !== ""
) {
_beginDate = this.filter.dates[0];
_endDate = this.filter.dates[1];
}
if (
this.filter.dates2.length == 2 &&
this.filter.dates2[0] !== "" &&
this.filter.dates2[0] !== ""
) {
_beginDate2 = this.filter.dates2[0];
_endDate2 = this.filter.dates2[1];
}
let _filert = {
cpersonname: h,
cInvCode: null,
begin_date: _beginDate,
end_date: _endDate,
};
let respd = await Purchasesummom(_filert);
this.dataDetail2 = sortByKey(respd.data.data, "CINVCODE");
this.modal2 = true;
},
async handleShow4(h) {
let _beginDate = null;
let _endDate = null;
let _beginDate2 = null;
let _endDate2 = null;
if (
this.filter.dates.length == 2 &&
this.filter.dates[0] !== "" &&
this.filter.dates[0] !== ""
) {
_beginDate = this.filter.dates[0];
_endDate = this.filter.dates[1];
}
if (
this.filter.dates2.length == 2 &&
this.filter.dates2[0] !== "" &&
this.filter.dates2[0] !== ""
) {
_beginDate2 = this.filter.dates2[0];
_endDate2 = this.filter.dates2[1];
}
let _filert = {
cpersonname: h,
cInvCode: null,
begin_date: _beginDate2,
end_date: _endDate2,
};
let respd = await Purchasesummom(_filert);
this.dataDetail2 = sortByKey(respd.data.data, "CINVCODE");
this.modal2 = true;
},
cancel() { cancel() {
this.dataDetail = []; this.dataDetail = [];
this.dataDetail2 = [];
this.modal1 = false; this.modal1 = false;
this.modal2 = false;
}, },
async loadData() { async loadData() {
let _beginDate = null;
let _endDate = null;
let _beginDate2 = null;
let _endDate2 = null;
if (
this.filter.dates.length == 2 &&
this.filter.dates[0] !== "" &&
this.filter.dates[0] !== ""
) {
_beginDate = this.filter.dates[0];
_endDate = this.filter.dates[1];
}
if (
this.filter.dates2.length == 2 &&
this.filter.dates2[0] !== "" &&
this.filter.dates2[0] !== ""
) {
_beginDate2 = this.filter.dates2[0];
_endDate2 = this.filter.dates2[1];
}
let _filert = {
begin_date: _beginDate,
end_date: _endDate,
begin_date2: _beginDate2,
end_date2: _endDate2,
};
try { try {
this.loading = true; this.loading = true;
let resp = await Purchasesum(); let resp = await Purchasesum(_filert);
this.pageNo = 1; this.pageNo = 1;
this.datas = resp.data.data; this.datas = resp.data.data;
// this.datas = sortByKey(resp.data.data, "cordercode"); // this.datas = sortByKey(resp.data.data, "cordercode");