报表去掉批号是空的(空瓶),报表1添加上月结存及批次,修复盘点时sql错误

This commit is contained in:
maqiao 2024-12-31 14:46:55 +08:00
parent c83b5b51b1
commit 663f9799d1
4 changed files with 39 additions and 9 deletions

View File

@ -3,7 +3,7 @@
<connectionStrings>
<!-- 数据库连接字符串 -->
<!--<add name="database" connectionString="server=127.0.0.1;database=wpf_dm_program;userid=root;password=qq1223" />-->
<add name="database" connectionString="server=127.0.0.1;port=3306;database=sanya_xianchang2;userid=root;password=root" />
<add name="database" connectionString="server=127.0.0.1;port=3306;database=sanya_xx;userid=root;password=root" />
</connectionStrings>
<!--<runtime>
--><!--配置之后Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!--
@ -40,7 +40,7 @@
<!-- 抽屉串口使用的协议232或者485 -->
<add key="DrawerProtocol" value="485" />
<!-- 抽屉串口的串口号 -->
<add key="DrawerPortPath" value="COM3" />
<add key="DrawerPortPath" value="COM1" />
<!-- can总线串口的串口号 -->
<add key="CanBusPortPath" value="COM9" />
<!-- 条码枪串口的串口号 -->

View File

@ -385,7 +385,7 @@ namespace DM_Weight.Report
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
WHERE mr.`machine_id` = '{machine_id}' and type in(1,2,31,4,5) and mr.manu_no is not NULL 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++)
@ -401,19 +401,19 @@ namespace DM_Weight.Report
string strValue = kvp.Value.ToString();
string inQuantitySQL = $@"SELECT GROUP_CONCAT(SumInQuantity) as StrTotalQuantity,GROUP_CONCAT(manu_no) as StrTotalManuNo from
(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)
from dm_machine_record mr where drug_id='{strValue}' and machine_id='{machine_id}' and type in(1,2,31,4,5) and mr.manu_no is not NULL
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(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)
from dm_machine_record mr where drug_id='{strValue}' and machine_id='{machine_id}' and type in(1,2,31,4,5) and mr.manu_no is not NULL
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}' and Type<>32 GROUP BY drug_id,manu_no ) b on a.drug_id=b.drug_id and a.manu_no=b.manu_no
WHERE DATE_FORMAT(operation_time,'%Y-%m')='{strDate}' and machine_id='{machine_id}' and Type<>32 and manu_no is not NULL 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

@ -299,6 +299,7 @@
"Name":"Group1",
"ByFields":"drugId",
"GroupHeader":{
"Height":2.01083,
"PrintGridBorder":false,
"Control":[
{
@ -481,6 +482,35 @@
"Charset":134
},
"DataField":"月"
},
{
"Type":"StaticBox",
"Name":"StaticBox37",
"Top":1,
"Width":1.8,
"Height":0.98,
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"Text":"上月结存:"
},
{
"Type":"StaticBox",
"Name":"StaticBox38",
"Left":6.2177,
"Top":1,
"Width":1.00542,
"Height":0.98,
"Font":{
"Name":"宋体",
"Size":105000,
"Bold":true,
"Charset":134
},
"Text":"批号:"
}
],
"NewPageColumn":"Before"

View File

@ -29,8 +29,8 @@ namespace DM_Weight.ViewModels
public static List<UseFor> SelectUseList = new()
{
new UseFor{UseId=0,UseName="入账册"},
new UseFor { UseId = 96, UseName = "不入账册" }
new UseFor { UseId = 96, UseName = "不入账册" },
new UseFor{UseId=0,UseName="入账册"}
};
private List<UseFor> _selectsUseFor = SelectUseList;
@ -482,7 +482,7 @@ namespace DM_Weight.ViewModels
string machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
string strSql = $@"SELECT cl.`row_no` AS rowNo,cl.`col_no` AS colNo,cl.`quantity` AS quantity,cl.`manu_no` AS manuNo,cl.`eff_date` AS effDate,
di.`drug_name` AS drugName,di.`drug_spec` AS drugSpec,di.`pack_unit` AS packUnit,di.`manufactory` AS manufactory,di.`max_stock` maxStock,
cl.`drug_id` AS drugId,cl.`machine_id` AS MachineId FROM channel_stock cl INNER JOIN drug_info di ON di.`drug_id` = cl.`drug_id` WHERE cl.`machine_id` = '{machine_id}' AND cl.`drawer_type` = 1 ORDER BY cl.`drug_id`";
cl.`drug_id` AS drugId,cl.`machine_id` AS MachineId FROM channel_stock cl INNER JOIN drug_info di ON di.`drug_id` = cl.`drug_id` WHERE cl.`machine_id` = '{machine_id}' AND cl.`drawer_type` = 1 ";
if (App.SingleModel)
{
strSql += " AND ROW_NO<=8";