From 9fcf388571ec31a08a540f618775e381353522aa Mon Sep 17 00:00:00 2001 From: maqiao <625215135@qq.com> Date: Tue, 3 Dec 2024 11:38:19 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=90=E6=97=A5=E6=B6=88=E8=80=97=E4=B8=93?= =?UTF-8?q?=E7=94=A8=E8=B4=A6=E5=86=8C1=E6=9F=A5=E8=AF=A2=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=85=A5=E5=BA=93=E6=95=B0=E9=87=8F=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=8E=9F=E6=9D=A5=E6=9F=A5=E7=9A=84=E5=87=BA=E5=BA=93?= =?UTF-8?q?=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DM_Weight/Report/GridReportUtil.cs | 43 +++++++++++------- DM_Weight/ReportTemp/account_book_temp-01.grf | 45 ++++++++++++++++--- 2 files changed, 66 insertions(+), 22 deletions(-) diff --git a/DM_Weight/Report/GridReportUtil.cs b/DM_Weight/Report/GridReportUtil.cs index 95aef72..47ca668 100644 --- a/DM_Weight/Report/GridReportUtil.cs +++ b/DM_Weight/Report/GridReportUtil.cs @@ -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> tableList = SqlSugarHelper.Db.SqlQueryable(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(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(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(stockQuantitySQL).First(); } } diff --git a/DM_Weight/ReportTemp/account_book_temp-01.grf b/DM_Weight/ReportTemp/account_book_temp-01.grf index fe1caf3..864ee56 100644 --- a/DM_Weight/ReportTemp/account_book_temp-01.grf +++ b/DM_Weight/ReportTemp/account_book_temp-01.grf @@ -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 } ] },