逐日消耗专用账册1查询添加入库数量,修改原来查的出库数量

This commit is contained in:
maqiao 2024-12-03 11:38:19 +08:00
parent 6900ea8ba1
commit 9fcf388571
2 changed files with 66 additions and 22 deletions

View File

@ -368,14 +368,25 @@ namespace DM_Weight.Report
GridppReport Report = new GridppReport();
string SQL = string.Empty;
string machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
SQL = $@"SELECT mr.drug_id as drugId,'test' InTotal,YEAR(mr.`operation_time`) as DMYear,MONTH(mr.`operation_time`) as DMMonth,
DAY(mr.`operation_time`) as DMDay,manu_no as manuNo,operation_time as operationTime,return_quantity1 as inQuantity,return_quantity2 as outQuantity,
manunoQuantity as stockQuantity,u1.user_name as operatorName,u2.user_name as reviewerName,di.`drug_name` AS `drugName`,
di.`drug_spec` AS `drugSpec`, di.`pack_unit` AS `packUnit`,di.big_unit as bigUnit, di.`dosage` AS `dosage`, di.`manufactory` AS `manufactory`
FROM dm_machine_record mr INNER JOIN DRUG_INFO di ON mr.drug_id=di.drug_id LEFT JOIN user_list u1 ON mr.`operator` = u1.`id`LEFT JOIN user_list u2 ON mr.`reviewer` = u2.`id`
WHERE mr.`machine_id` = '{machine_id}' and type=5 and DATE_FORMAT(operation_time,'%Y-%m')='{strDate}' ORDER BY mr.drug_id,operation_time";
// SQL = $@"SELECT mr.drug_id as drugId,'test' InTotal,YEAR(mr.`operation_time`) as DMYear,MONTH(mr.`operation_time`) as DMMonth,
// DAY(mr.`operation_time`) as DMDay,manu_no as manuNo,operation_time as operationTime,return_quantity1 as inQuantity,return_quantity2 as outQuantity,
// manunoQuantity as stockQuantity,u1.user_name as operatorName,u2.user_name as reviewerName,di.`drug_name` AS `drugName`,
// di.`drug_spec` AS `drugSpec`, di.`pack_unit` AS `packUnit`,di.big_unit as bigUnit, di.`dosage` AS `dosage`, di.`manufactory` AS `manufactory`
//FROM dm_machine_record mr INNER JOIN DRUG_INFO di ON mr.drug_id=di.drug_id LEFT JOIN user_list u1 ON mr.`operator` = u1.`id`LEFT JOIN user_list u2 ON mr.`reviewer` = u2.`id`
//WHERE mr.`machine_id` = '{machine_id}' and type=5 and DATE_FORMAT(operation_time,'%Y-%m')='{strDate}' ORDER BY mr.drug_id,operation_time";
SQL = $@"SELECT t.drugId,t.DMYear,t.DMMonth,t.DMDay,t.manuNo,t.operationTime,t.inQuantity as inQuantity,t.outQuantity AS outQuantity,dmr.manunoQuantity AS stockQuantity,t.operatorName,t.reviewerName,
t.drugName,t.drugSpec,t.packUnit,t.bigUnit,t.dosage,t.manufactory from dm_machine_record dmr inner join
(SELECT max(mr.id) id, mr.drug_id as drugId,'test' InTotal,YEAR(mr.`operation_time`) as DMYear,MONTH(mr.`operation_time`) as DMMonth,
DAY(mr.`operation_time`) as DMDay,manu_no as manuNo,operation_time as operationTime,
SUM(IF(mr.`type` IN (1, 31), mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` > 0, mr.`quantity`, 0)) ) AS `inQuantity`,
SUM(IF(mr.`type` = 2, mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` < 0, (0 - mr.`quantity`), 0))) AS `outQuantity`,
manunoQuantity as stockQuantity,u1.user_name as operatorName,u2.user_name as reviewerName,di.`drug_name` AS `drugName`,
di.`drug_spec` AS `drugSpec`, di.`pack_unit` AS `packUnit`,di.big_unit as bigUnit, di.`dosage` AS `dosage`, di.`manufactory` AS `manufactory`
FROM dm_machine_record mr INNER JOIN DRUG_INFO di ON mr.drug_id=di.drug_id LEFT JOIN user_list u1 ON mr.`operator` = u1.`id`LEFT JOIN user_list u2 ON mr.`reviewer` = u2.`id`
WHERE mr.`machine_id` = '{machine_id}' and type in(1,2,31,4,5) and DATE_FORMAT(operation_time,'%Y-%m')='{strDate}'and IF(mr.`type` = 4 AND mr.`quantity` = 0, 99999, mr.`quantity`) <>99999
GROUP BY drugId,DMYear,DMMonth,DMDay,manuNo ORDER BY mr.drug_id,operation_time) t on dmr.id=t.id";
List<Dictionary<string, object>> tableList = SqlSugarHelper.Db.SqlQueryable<dynamic>(SQL).ToDictionaryList();
for (int i = 0; i < tableList.Count; i++)
{
@ -389,21 +400,21 @@ namespace DM_Weight.Report
//查询药品id对应的上月结存数量及批号
string strValue = kvp.Value.ToString();
string inQuantitySQL = $@"SELECT GROUP_CONCAT(SumInQuantity) as StrTotalQuantity,GROUP_CONCAT(manu_no) as StrTotalManuNo from
(SELECT sum(return_quantity1) as SumInQuantity,manu_no
from dm_machine_record where drug_id='{strValue}' and machine_id='{machine_id}' and type=5
and DATE_FORMAT(operation_time,'%Y-%m')='{strDate}'GROUP BY drug_id,manu_no ORDER BY drug_id,operation_time) as t";
(SELECT sum(IF(mr.`type` IN (1, 31), mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` > 0, mr.`quantity`, 0))) as SumInQuantity,manu_no
from dm_machine_record mr where drug_id='{strValue}' and machine_id='{machine_id}' and type in(1,2,31,4,5)
and DATE_FORMAT(operation_time,'%Y-%m')='{strDate}'and IF(mr.`type` = 4 AND mr.`quantity` = 0, 99999, mr.`quantity`) <>99999 GROUP BY drug_id,manu_no ORDER BY drug_id,operation_time) as t";
InTotalModel = SqlSugarHelper.Db.SqlQueryable<LastMonthModel>(inQuantitySQL).First();
string outQuantitySQL = $@"SELECT GROUP_CONCAT(SumInQuantity) as StrTotalQuantity,GROUP_CONCAT(manu_no) as StrTotalManuNo from
(SELECT sum(return_quantity2) as SumInQuantity ,manu_no
from dm_machine_record where drug_id='{strValue}' and machine_id='{machine_id}' and type=5
and DATE_FORMAT(operation_time,'%Y-%m')='{strDate}' GROUP BY drug_id,manu_no ORDER BY drug_id,operation_time) as t";
(SELECT sum(IF(mr.`type` = 2, mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` < 0, (0 - mr.`quantity`), 0))) as SumInQuantity ,manu_no
from dm_machine_record mr where drug_id='{strValue}' and machine_id='{machine_id}' and type in(1,2,31,4,5)
and DATE_FORMAT(operation_time,'%Y-%m')='{strDate}' and IF(mr.`type` = 4 AND mr.`quantity` = 0, 99999, mr.`quantity`) <>99999 GROUP BY drug_id,manu_no ORDER BY drug_id,operation_time) as t";
OutTotalModel = SqlSugarHelper.Db.SqlQueryable<LastMonthModel>(outQuantitySQL).First();
string stockQuantitySQL = $@"SELECT GROUP_CONCAT(a.Manu_No) as StrTotalManuNo,GROUP_CONCAT(a.manunoQuantity) as StrTotalQuantity from dm_machine_record a inner join
(select drug_id,manu_no,max(operation_time) as latest_date,stock_quantity from dm_machine_record
WHERE DATE_FORMAT(operation_time,'%Y-%m')='{strDate}' and machine_id='{machine_id}' GROUP BY drug_id,manu_no ) b on a.drug_id=b.drug_id and a.manu_no=b.manu_no
and a.operation_time=b.latest_date and machine_id='{machine_id}' WHERE a.drug_id='{strValue}' and DATE_FORMAT(operation_time,'%Y-%m')='{strDate}'";
WHERE DATE_FORMAT(operation_time,'%Y-%m')='{strDate}' and machine_id='{machine_id}' and Type<>32 GROUP BY drug_id,manu_no ) b on a.drug_id=b.drug_id and a.manu_no=b.manu_no
and a.operation_time=b.latest_date and machine_id='{machine_id}' WHERE a.drug_id='{strValue}' and Type<>32 and DATE_FORMAT(operation_time,'%Y-%m')='{strDate}'";
StackTotalModel = SqlSugarHelper.Db.SqlQueryable<LastMonthModel>(stockQuantitySQL).First();
}
}

View File

@ -119,6 +119,9 @@
"Name":"Column2",
"Width":4.81542
},
{
"Name":"Column8"
},
{
"Name":"Column3",
"Width":2.03729
@ -164,6 +167,11 @@
"TextAlign":"MiddleCenter",
"DataField":"批号"
},
{
"Column":"Column8",
"TextAlign":"MiddleCenter",
"DataField":"入库数量"
},
{
"Column":"Column3",
"TextAlign":"MiddleCenter",
@ -224,6 +232,18 @@
"TextAlign":"MiddleCenter",
"Text":"批号"
},
{
"GroupTitle":false,
"Column":"Column8",
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"入库数量"
},
{
"GroupTitle":false,
"Column":"Column3",
@ -646,7 +666,7 @@
"Type":"StaticBox",
"Name":"StaticBox4",
"AlignColumn":"Column3",
"Left":10.1865,
"Left":13.1763,
"Width":2.03729,
"Height":1.00542,
"Border":{
@ -659,7 +679,7 @@
"Type":"StaticBox",
"Name":"StaticBox5",
"AlignColumn":"Column4",
"Left":12.2238,
"Left":15.2135,
"Width":1.5875,
"Height":1.00542,
"Border":{
@ -672,7 +692,7 @@
"Type":"StaticBox",
"Name":"StaticBox6",
"AlignColumn":"Column5",
"Left":13.8113,
"Left":16.801,
"Width":4.7625,
"Height":1.00542,
"Border":{
@ -685,7 +705,7 @@
"Type":"StaticBox",
"Name":"StaticBox22",
"AlignColumn":"Column6",
"Left":18.5738,
"Left":21.5635,
"Width":5.21229,
"Height":1.00542,
"Border":{
@ -693,6 +713,19 @@
},
"TextAlign":"MiddleCenter",
"Text":"核对人"
},
{
"Type":"StaticBox",
"Name":"StaticBox36",
"AlignColumn":"Column8",
"Left":10.1865,
"Width":2.98979,
"Height":1.01,
"Border":{
"Styles":"[DrawRight|DrawBottom]"
},
"TextAlign":"MiddleCenter",
"Text":"入库数量"
}
]
},
@ -722,14 +755,14 @@
"Name":"Line1",
"Anchor":"[Left|Top|Right]",
"Top":2.6,
"Width":23
"Width":25.9821
},
{
"Type":"Line",
"Name":"Line2",
"Anchor":"[Left|Top|Right]",
"Top":2.68,
"Width":23
"Width":25.9821
}
]
},