添加交接记录报表
This commit is contained in:
		
							parent
							
								
									336531bb2a
								
							
						
					
					
						commit
						2178fa777c
					
				| 
						 | 
				
			
			@ -122,6 +122,9 @@
 | 
			
		|||
    <None Update="ReportTemp\changeShifts_temp.grf">
 | 
			
		||||
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
			
		||||
    </None>
 | 
			
		||||
    <None Update="ReportTemp\changeShifts_temp_new.grf">
 | 
			
		||||
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
			
		||||
    </None>
 | 
			
		||||
    <None Update="ReportTemp\machine_log_check.grf">
 | 
			
		||||
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 | 
			
		||||
    </None>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -51,5 +51,23 @@ namespace DM_Weight.Models
 | 
			
		|||
 | 
			
		||||
        [SugarColumn(ColumnName = "machineId")]
 | 
			
		||||
        public string MachineId { get; set; }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 单位
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        [SugarColumn(ColumnName = "pack_unit")]
 | 
			
		||||
        public string PackdUnit { get; set; }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 库存数
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        [SugarColumn(ColumnName = "stockQuantity")]
 | 
			
		||||
        public int StockQuantity { get; set; }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 空瓶数
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        [SugarColumn(ColumnName = "emptyQuantity")]
 | 
			
		||||
        public int EmptyQuantity { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -243,7 +243,8 @@ namespace DM_Weight.Report
 | 
			
		|||
            // 定义Grid++Report报表主对象
 | 
			
		||||
            GridppReport Report = new GridppReport();
 | 
			
		||||
            // 加载模板文件
 | 
			
		||||
            Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "changeShifts_temp.grf");
 | 
			
		||||
            //Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "changeShifts_temp.grf");
 | 
			
		||||
            Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "changeShifts_temp_new.grf");
 | 
			
		||||
            string SQL = string.Empty;
 | 
			
		||||
            Report.DetailGrid.Recordset.ConnectionString = gridConnectionString;
 | 
			
		||||
            Report.Initialize += new _IGridppReportEvents_InitializeEventHandler(() =>
 | 
			
		||||
| 
						 | 
				
			
			@ -253,7 +254,7 @@ namespace DM_Weight.Report
 | 
			
		|||
                Report.ParameterByName("endDate").Value = endDate ?? DateTime.Now.AddDays(1);
 | 
			
		||||
            });
 | 
			
		||||
            SQL = $@"SELECT opt_date,drug_name,drug_spec,beforenum,getnum,usenum,manu_no,surplus,CONCAT(fromoperator,' ',fromreviewer) as fromoperator,
 | 
			
		||||
                    CONCAT(tooperator,' ',toreviewer) as tooperator
 | 
			
		||||
                    CONCAT(tooperator,' ',toreviewer) as tooperator,pack_unit,stockQuantity,emptyQuantity
 | 
			
		||||
                    from `hkc_shiftsreport` WHERE `machineid` = '{p_machine_id}' AND `opt_date` > '{p_startDate}'
 | 
			
		||||
                        AND opt_date < '{p_endDate}'  ORDER BY opt_date";
 | 
			
		||||
            Report.DetailGrid.Recordset.QuerySQL = SQL;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| 
						 | 
				
			
			@ -213,25 +213,32 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
                }).ExecuteCommand();
 | 
			
		||||
 | 
			
		||||
                //插入交接班报表数据信息
 | 
			
		||||
                string strSql = @"SELECT drug.drug_name,drug.DRUG_SPEC,c.manu_no,d.useNum,d.getNum,sum(quantity) as surplus,
 | 
			
		||||
                                    (SELECT d2.manunoquantity FROM dm_machine_record d2 WHERE d2.drug_id = c.`drug_id`  and d2.manu_no=c.manu_no  AND d2.operation_time < @beforeDate
 | 
			
		||||
                                    ORDER BY d2.operation_time DESC,d2.id DESC LIMIT 1) AS beforeNum
 | 
			
		||||
                                    from channel_stock		c LEFT JOIN drug_info drug on c.drug_id=drug.drug_id left JOIN	(SELECT drug_id,manu_no,
 | 
			
		||||
                                    SUM(IF(d1.`type` = 1, d1.quantity, 0)) AS getNum,SUM(IF(d1.`type` = 2, d1.quantity, 0)) AS useNum FROM dm_machine_record d1
 | 
			
		||||
                                    WHERE d1.`type` IN (1, 2) AND d1.`operation_time` >= @startDate and d1.`operation_time` <=@endDate and d1.machine_id=@machineId GROUP BY d1.Drug_ID ,d1.manu_no) d
 | 
			
		||||
                                    on c.drug_id=d.drug_id and c.manu_no=d.manu_no WHERE c.machine_id=@machineId and c.drug_id is not NULL GROUP BY c.Drug_ID ,c.manu_no
 | 
			
		||||
                                    UNION
 | 
			
		||||
                                    SELECT drug.drug_name,drug.DRUG_SPEC,d.manu_no,d.useNum,d.getNum,sum(quantity) as surplus,(SELECT d2.manunoquantity FROM dm_machine_record d2 WHERE d2.drug_id = d.`drug_id`  and d2.manu_no=d.manu_no  AND d2.operation_time < @beforeDate
 | 
			
		||||
                                    ORDER BY d2.operation_time DESC,d2.id DESC LIMIT 1) AS beforeNum from (SELECT drug_id,manu_no, SUM(IF(d1.`type` = 1, d1.quantity, 0)) AS getNum,SUM(IF(d1.`type` = 2, d1.quantity, 0)) AS useNum FROM dm_machine_record d1 
 | 
			
		||||
                                     WHERE d1.`type` IN (1, 2) AND d1.`operation_time` >= @startDate and d1.`operation_time` <=@endDate and d1.machine_id=@machineId GROUP BY d1.Drug_ID ,d1.manu_no) d	
 | 
			
		||||
                                    LEFT JOIN drug_info drug on d.drug_id=drug.drug_id left JOIN		 channel_stock		c on c.drug_id=d.drug_id and c.manu_no=d.manu_no AND c.machine_id=@machineId GROUP BY d.Drug_ID ,d.manu_no ";
 | 
			
		||||
                //string strSql = @"SELECT drug.drug_name,drug.DRUG_SPEC,c.manu_no,d.useNum,d.getNum,sum(quantity) as surplus,
 | 
			
		||||
                //                    (SELECT d2.manunoquantity FROM dm_machine_record d2 WHERE d2.drug_id = c.`drug_id`  and d2.manu_no=c.manu_no  AND d2.operation_time < @beforeDate
 | 
			
		||||
                //                    ORDER BY d2.operation_time DESC,d2.id DESC LIMIT 1) AS beforeNum
 | 
			
		||||
                //                    from channel_stock		c LEFT JOIN drug_info drug on c.drug_id=drug.drug_id left JOIN	(SELECT drug_id,manu_no,
 | 
			
		||||
                //                    SUM(IF(d1.`type` = 1, d1.quantity, 0)) AS getNum,SUM(IF(d1.`type` = 2, d1.quantity, 0)) AS useNum FROM dm_machine_record d1
 | 
			
		||||
                //                    WHERE d1.`type` IN (1, 2) AND d1.`operation_time` >= @startDate and d1.`operation_time` <=@endDate and d1.machine_id=@machineId GROUP BY d1.Drug_ID ,d1.manu_no) d
 | 
			
		||||
                //                    on c.drug_id=d.drug_id and c.manu_no=d.manu_no WHERE c.machine_id=@machineId and c.drug_id is not NULL GROUP BY c.Drug_ID ,c.manu_no
 | 
			
		||||
                //                    UNION
 | 
			
		||||
                //                    SELECT drug.drug_name,drug.DRUG_SPEC,d.manu_no,d.useNum,d.getNum,sum(quantity) as surplus,(SELECT d2.manunoquantity FROM dm_machine_record d2 WHERE d2.drug_id = d.`drug_id`  and d2.manu_no=d.manu_no  AND d2.operation_time < @beforeDate
 | 
			
		||||
                //                    ORDER BY d2.operation_time DESC,d2.id DESC LIMIT 1) AS beforeNum from (SELECT drug_id,manu_no, SUM(IF(d1.`type` = 1, d1.quantity, 0)) AS getNum,SUM(IF(d1.`type` = 2, d1.quantity, 0)) AS useNum FROM dm_machine_record d1 
 | 
			
		||||
                //                     WHERE d1.`type` IN (1, 2) AND d1.`operation_time` >= @startDate and d1.`operation_time` <=@endDate and d1.machine_id=@machineId GROUP BY d1.Drug_ID ,d1.manu_no) d	
 | 
			
		||||
                //                    LEFT JOIN drug_info drug on d.drug_id=drug.drug_id left JOIN		 channel_stock		c on c.drug_id=d.drug_id and c.manu_no=d.manu_no AND c.machine_id=@machineId GROUP BY d.Drug_ID ,d.manu_no ";
 | 
			
		||||
               
 | 
			
		||||
                
 | 
			
		||||
                //交接班表里只显示值班柜(row_no:1,2)的不显示周转柜
 | 
			
		||||
                string strSql = @"SELECT di.drug_name as DrugName,di.drug_spec as DrugSpec,di.pack_unit,sum(if(cs.drawer_type=1,cs.quantity,0)) stockQuantity,
 | 
			
		||||
                                sum(if(cs.drawer_type=2,cs.quantity,0)) EmptyQuantity FROM channel_stock cs inner join drug_info di on cs.drug_id=di.drug_id 
 | 
			
		||||
                                WHERE (row_no in(1,2) or drawer_type=2) and machine_id =@machineId GROUP BY cs.drug_id ORDER BY cs.Drug_ID";
 | 
			
		||||
 | 
			
		||||
                List<ShiftsReport> shiftsReports = SqlSugarHelper.Db.SqlQueryable<dynamic>(strSql)
 | 
			
		||||
                 .AddParameters(new
 | 
			
		||||
                 {
 | 
			
		||||
                     machineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1",
 | 
			
		||||
                     beforeDate = listHkcChangeShifts[0].OptDate,
 | 
			
		||||
                     startDate = listHkcChangeShifts[0].OptDate,
 | 
			
		||||
                     endDate = dt
 | 
			
		||||
                     //beforeDate = listHkcChangeShifts[0].OptDate,
 | 
			
		||||
                     //startDate = listHkcChangeShifts[0].OptDate,
 | 
			
		||||
                     //endDate = dt
 | 
			
		||||
                 })
 | 
			
		||||
                .Select(it => new ShiftsReport())
 | 
			
		||||
                .ToList();
 | 
			
		||||
| 
						 | 
				
			
			@ -245,11 +252,14 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
                            OptDate = dt,
 | 
			
		||||
                            DrugName = shiftsReports[i].DrugName,
 | 
			
		||||
                            DrugSpec = shiftsReports[i].DrugSpec,
 | 
			
		||||
                            BeforeNum = shiftsReports[i].BeforeNum ?? 0,
 | 
			
		||||
                            GetNum = shiftsReports[i].GetNum ?? 0,
 | 
			
		||||
                            UseNum = shiftsReports[i].UseNum ?? 0,
 | 
			
		||||
                            ManuNo = shiftsReports[i].ManuNo,
 | 
			
		||||
                            Surplus = shiftsReports[i].Surplus ?? 0,
 | 
			
		||||
                            PackdUnit= shiftsReports[i].PackdUnit,
 | 
			
		||||
                            StockQuantity= shiftsReports[i].StockQuantity,
 | 
			
		||||
                            EmptyQuantity= shiftsReports[i].EmptyQuantity,
 | 
			
		||||
                            //BeforeNum = shiftsReports[i].BeforeNum ?? 0,
 | 
			
		||||
                            //GetNum = shiftsReports[i].GetNum ?? 0,
 | 
			
		||||
                            //UseNum = shiftsReports[i].UseNum ?? 0,
 | 
			
		||||
                            //ManuNo = shiftsReports[i].ManuNo,
 | 
			
		||||
                            //Surplus = shiftsReports[i].Surplus ?? 0,
 | 
			
		||||
                            FromOperator = Operator == null ? "" : Operator.Nickname,
 | 
			
		||||
                            FromReviewer = Reviewer == null ? "" : Reviewer.Nickname,
 | 
			
		||||
                            ToOperator = JieOperator == null ? "" : JieOperator.Nickname,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue