逐日消耗专用账册1查询添加入库数量,修改原来查的出库数量
This commit is contained in:
parent
ce7f17d022
commit
8f7cd84b08
|
@ -368,13 +368,39 @@ 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 drugId,DMYear,DMMonth,DMDay,manuNo,operationTime,sum(inQuantity) as inQuantity,SUM(outQuantity) as outQuantity,stockQuantity,operatorName,reviewerName,drugName,drugSpec,packUnit,bigUnit,dosage,manufactory
|
||||
//FROM (
|
||||
|
||||
//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,
|
||||
// IF(mr.`type` IN (1, 31), mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` > 0, mr.`quantity`, 0))
|
||||
// AS `inQuantity`, 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 ORDER BY mr.drug_id,operation_time
|
||||
//) t GROUP BY drugId,DMYear,DMMonth,DMDay,manuNo";
|
||||
|
||||
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,15 +415,15 @@ 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
|
||||
|
|
|
@ -119,6 +119,9 @@
|
|||
"Name":"Column2",
|
||||
"Width":4.81542
|
||||
},
|
||||
{
|
||||
"Name":"Column8"
|
||||
},
|
||||
{
|
||||
"Name":"Column3",
|
||||
"Width":2.03729
|
||||
|
@ -164,6 +167,12 @@
|
|||
"TextAlign":"MiddleCenter",
|
||||
"DataField":"批号"
|
||||
},
|
||||
{
|
||||
"Column":"Column8",
|
||||
"TextAlign":"MiddleCenter",
|
||||
"ShrinkFontToFit":true,
|
||||
"DataField":"入库数量"
|
||||
},
|
||||
{
|
||||
"Column":"Column3",
|
||||
"TextAlign":"MiddleCenter",
|
||||
|
@ -224,6 +233,12 @@
|
|||
"TextAlign":"MiddleCenter",
|
||||
"Text":"批号"
|
||||
},
|
||||
{
|
||||
"GroupTitle":false,
|
||||
"Column":"Column8",
|
||||
"TextAlign":"MiddleCenter",
|
||||
"Text":"Column8"
|
||||
},
|
||||
{
|
||||
"GroupTitle":false,
|
||||
"Column":"Column3",
|
||||
|
@ -330,7 +345,7 @@
|
|||
"Name":"FieldBox8",
|
||||
"Left":7.27604,
|
||||
"Top":0.0529167,
|
||||
"Width":2.32833,
|
||||
"Width":1.53458,
|
||||
"Height":0.978958,
|
||||
"Font":{
|
||||
"Name":"宋体",
|
||||
|
@ -344,7 +359,7 @@
|
|||
{
|
||||
"Type":"StaticBox",
|
||||
"Name":"StaticBox18",
|
||||
"Left":9.55146,
|
||||
"Left":9.2075,
|
||||
"Top":0.105833,
|
||||
"Width":1.21708,
|
||||
"Height":0.873125,
|
||||
|
@ -359,9 +374,9 @@
|
|||
{
|
||||
"Type":"FieldBox",
|
||||
"Name":"FieldBox9",
|
||||
"Left":10.7421,
|
||||
"Left":10.2129,
|
||||
"Top":0.105833,
|
||||
"Width":1.79917,
|
||||
"Width":1.27,
|
||||
"Height":0.873125,
|
||||
"Font":{
|
||||
"Name":"宋体",
|
||||
|
@ -374,8 +389,8 @@
|
|||
{
|
||||
"Type":"StaticBox",
|
||||
"Name":"StaticBox19",
|
||||
"Left":21.5371,
|
||||
"Top":0.079375,
|
||||
"Left":17.145,
|
||||
"Top":0.105833,
|
||||
"Width":0.396875,
|
||||
"Height":0.899583,
|
||||
"Font":{
|
||||
|
@ -389,8 +404,8 @@
|
|||
{
|
||||
"Type":"FieldBox",
|
||||
"Name":"FieldBox10",
|
||||
"Left":20.3465,
|
||||
"Top":0.105833,
|
||||
"Left":16.0867,
|
||||
"Top":0.132292,
|
||||
"Width":1.08479,
|
||||
"Height":0.846667,
|
||||
"Font":{
|
||||
|
@ -404,9 +419,9 @@
|
|||
{
|
||||
"Type":"StaticBox",
|
||||
"Name":"StaticBox20",
|
||||
"Left":12.8588,
|
||||
"Top":0.238125,
|
||||
"Width":2.01083,
|
||||
"Left":11.4035,
|
||||
"Top":0.211667,
|
||||
"Width":1.37583,
|
||||
"Height":0.582083,
|
||||
"Font":{
|
||||
"Name":"宋体",
|
||||
|
@ -419,9 +434,9 @@
|
|||
{
|
||||
"Type":"FieldBox",
|
||||
"Name":"FieldBox11",
|
||||
"Left":14.9225,
|
||||
"Top":0.264583,
|
||||
"Width":4.68313,
|
||||
"Left":12.8058,
|
||||
"Top":0.211667,
|
||||
"Width":3.20146,
|
||||
"Height":0.555625,
|
||||
"Font":{
|
||||
"Name":"宋体",
|
||||
|
@ -435,8 +450,8 @@
|
|||
{
|
||||
"Type":"StaticBox",
|
||||
"Name":"StaticBox21",
|
||||
"Left":22.8865,
|
||||
"Top":0.105833,
|
||||
"Left":18.3621,
|
||||
"Top":0.15875,
|
||||
"Width":0.608542,
|
||||
"Height":0.873125,
|
||||
"Font":{
|
||||
|
@ -450,8 +465,8 @@
|
|||
{
|
||||
"Type":"FieldBox",
|
||||
"Name":"FieldBox16",
|
||||
"Left":21.9869,
|
||||
"Top":0.105833,
|
||||
"Left":17.5419,
|
||||
"Top":0.132292,
|
||||
"Width":0.740833,
|
||||
"Height":0.846667,
|
||||
"Font":{
|
||||
|
@ -646,7 +661,7 @@
|
|||
"Type":"StaticBox",
|
||||
"Name":"StaticBox4",
|
||||
"AlignColumn":"Column3",
|
||||
"Left":10.1865,
|
||||
"Left":13.1763,
|
||||
"Width":2.03729,
|
||||
"Height":1.00542,
|
||||
"Border":{
|
||||
|
@ -659,7 +674,7 @@
|
|||
"Type":"StaticBox",
|
||||
"Name":"StaticBox5",
|
||||
"AlignColumn":"Column4",
|
||||
"Left":12.2238,
|
||||
"Left":15.2135,
|
||||
"Width":1.5875,
|
||||
"Height":1.00542,
|
||||
"Border":{
|
||||
|
@ -672,7 +687,7 @@
|
|||
"Type":"StaticBox",
|
||||
"Name":"StaticBox6",
|
||||
"AlignColumn":"Column5",
|
||||
"Left":13.8113,
|
||||
"Left":16.801,
|
||||
"Width":4.7625,
|
||||
"Height":1.00542,
|
||||
"Border":{
|
||||
|
@ -685,7 +700,7 @@
|
|||
"Type":"StaticBox",
|
||||
"Name":"StaticBox22",
|
||||
"AlignColumn":"Column6",
|
||||
"Left":18.5738,
|
||||
"Left":21.5635,
|
||||
"Width":5.21229,
|
||||
"Height":1.00542,
|
||||
"Border":{
|
||||
|
@ -693,6 +708,19 @@
|
|||
},
|
||||
"TextAlign":"MiddleCenter",
|
||||
"Text":"核对人"
|
||||
},
|
||||
{
|
||||
"Type":"StaticBox",
|
||||
"Name":"StaticBox36",
|
||||
"AlignColumn":"Column8",
|
||||
"Left":10.1865,
|
||||
"Width":2.98979,
|
||||
"Height":1.0054,
|
||||
"Border":{
|
||||
"Styles":"[DrawRight|DrawBottom]"
|
||||
},
|
||||
"TextAlign":"MiddleCenter",
|
||||
"Text":"入库数量"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -722,14 +750,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
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue