From 8f7cd84b08901d34847d12f194d6f73cb27d2a96 Mon Sep 17 00:00:00 2001 From: maqiao <625215135@qq.com> Date: Tue, 3 Dec 2024 10:52:09 +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 | 52 +++++++++---- DM_Weight/ReportTemp/account_book_temp-01.grf | 76 +++++++++++++------ 2 files changed, 91 insertions(+), 37 deletions(-) diff --git a/DM_Weight/Report/GridReportUtil.cs b/DM_Weight/Report/GridReportUtil.cs index 230a69f..75340fa 100644 --- a/DM_Weight/Report/GridReportUtil.cs +++ b/DM_Weight/Report/GridReportUtil.cs @@ -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> tableList = SqlSugarHelper.Db.SqlQueryable(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(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 diff --git a/DM_Weight/ReportTemp/account_book_temp-01.grf b/DM_Weight/ReportTemp/account_book_temp-01.grf index fe1caf3..e6e2399 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,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 } ] },