调拨复入库取调拨单状态status为2的数据
This commit is contained in:
		
							parent
							
								
									e224fdd28b
								
							
						
					
					
						commit
						37fe5d4a6c
					
				| 
						 | 
					@ -93,7 +93,11 @@ namespace DM_Weight.Models
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [SugarColumn(IsIgnore = true)]
 | 
					        [SugarColumn(IsIgnore = true)]
 | 
				
			||||||
        public string drug_name_spec { get; set; }
 | 
					        public string drug_name_spec { get; set; }
 | 
				
			||||||
        //[SugarColumn(ColumnName = "drug_name_spec")]
 | 
					
 | 
				
			||||||
        //public string Name { get; set; }
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 药品单位转换率
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        [SugarColumn(ColumnName = "convert_ratio")]
 | 
				
			||||||
 | 
					        public int ConvertRatio { get; set; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -545,7 +545,7 @@ namespace DM_Weight.Port
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                            else
 | 
					                            else
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
                                Thread.Sleep(100);
 | 
					                                Thread.Sleep(200);
 | 
				
			||||||
                                // 灯在闪烁继续监听状态
 | 
					                                // 灯在闪烁继续监听状态
 | 
				
			||||||
                                GetBackDoorState();
 | 
					                                GetBackDoorState();
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
| 
						 | 
					@ -700,7 +700,7 @@ namespace DM_Weight.Port
 | 
				
			||||||
            while (_length != length && end.Subtract(start).TotalMilliseconds < timeout)
 | 
					            while (_length != length && end.Subtract(start).TotalMilliseconds < timeout)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                _length = serialPort.BytesToRead;
 | 
					                _length = serialPort.BytesToRead;
 | 
				
			||||||
                if (_length == 0&& operation.Equals("开储物箱"))
 | 
					                if (_length == 0 && operation.Equals("开储物箱"))
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    _length = serialPort.BytesToRead;
 | 
					                    _length = serialPort.BytesToRead;
 | 
				
			||||||
| 
						 | 
					@ -712,6 +712,13 @@ namespace DM_Weight.Port
 | 
				
			||||||
                        logger.Info($"再次发送OpenStorage:{Convert.ToHexString(bufferWrite)};{end}");
 | 
					                        logger.Info($"再次发送OpenStorage:{Convert.ToHexString(bufferWrite)};{end}");
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                if (_length == 0 && operation.Equals("查储物箱状态"))
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Thread.Sleep(200);
 | 
				
			||||||
 | 
					                    byte[] bufferWrite = new byte[] { 0xaa, (byte)(_doorAddr), 0x02, 0x00, 0x00, 0x00, 0x00, 0xee };
 | 
				
			||||||
 | 
					                    canBusSerial.Write(bufferWrite, 0, 8);
 | 
				
			||||||
 | 
					                    logger.Info($"再次发送查储物箱状态指令:{Convert.ToHexString(bufferWrite)};{end}");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                end = DateTime.Now;
 | 
					                end = DateTime.Now;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (_length != length)
 | 
					            if (_length != length)
 | 
				
			||||||
| 
						 | 
					@ -817,7 +824,7 @@ namespace DM_Weight.Port
 | 
				
			||||||
            byte[] buffer = new byte[] { 0xaa, (byte)(_doorAddr), 0x02, 0x00, 0x00, 0x00, 0x00, 0xee };
 | 
					            byte[] buffer = new byte[] { 0xaa, (byte)(_doorAddr), 0x02, 0x00, 0x00, 0x00, 0x00, 0xee };
 | 
				
			||||||
            canBusSerial.Write(buffer, 0, 8);
 | 
					            canBusSerial.Write(buffer, 0, 8);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return await GetBufferByPort(canBusSerial, 8);
 | 
					            return await GetBufferByPort(canBusSerial, 8, "查储物箱状态");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        // 打开电控门储物箱(有灯使能)
 | 
					        // 打开电控门储物箱(有灯使能)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -291,7 +291,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            if (SelectedInvoice != null)
 | 
					            if (SelectedInvoice != null)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                //先查询有几种药
 | 
					                //先查询有几种药
 | 
				
			||||||
                string strSql = @"SELECT sum(Quantity) AS SumQuantity, COUNT(ID) AS CountNum,INVOICE_NO AS InvoiceNo,drug_id AS DrugId,QUANTITY AS quantity,drug_manu_no AS drugManuNo FROM IN_OUT_INVOICE WHERE INVOICE_NO=@INVOICE_NO  GROUP BY INVOICE_NO,DRUG_ID";
 | 
					                string strSql = @"SELECT SUM(IF(di.small_unit=io.units,io.quantity,io.quantity*di.convert_ratio)) AS SumQuantity, COUNT(io.ID) AS CountNum,io.INVOICE_NO AS InvoiceNo,io.drug_id AS DrugId,io.QUANTITY AS quantity,io.drug_manu_no AS drugManuNo FROM IN_OUT_INVOICE io inner join drug_info di on io.drug_id=di.drug_id WHERE io.INVOICE_NO=@INVOICE_NO  GROUP BY io.INVOICE_NO,io.DRUG_ID";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                var invoices = SqlSugarHelper.Db.SqlQueryable<InOutInvoice>(strSql)
 | 
					                var invoices = SqlSugarHelper.Db.SqlQueryable<InOutInvoice>(strSql)
 | 
				
			||||||
                                                    .AddParameters(new
 | 
					                                                    .AddParameters(new
 | 
				
			||||||
| 
						 | 
					@ -323,8 +323,8 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    //ChannelStock stock = new ChannelStock();
 | 
					                    //ChannelStock stock = new ChannelStock();
 | 
				
			||||||
                    //查询每种药有多少个批次
 | 
					                    //查询每种药有多少个批次
 | 
				
			||||||
                    var invoicesManuNo = SqlSugarHelper.Db.Queryable<InOutInvoice>()
 | 
					                    var invoicesManuNo = SqlSugarHelper.Db.Queryable<InOutInvoice>().Includes<DrugInfo>(oi=>oi.DrugInfo).InnerJoin<DrugInfo>((oi,di)=>oi.DrugId==di.DrugId)
 | 
				
			||||||
                               .Where(iManuNo => iManuNo.InvoiceNo == invoices[i].InvoiceNo && iManuNo.DrugId == invoices[i].DrugId && iManuNo.Status == 0 && iManuNo.Type == 2 && iManuNo.CancelFlag == 0).ToList();
 | 
					                               .Where(oi => oi.InvoiceNo == invoices[i].InvoiceNo && oi.DrugId == invoices[i].DrugId && oi.Status == 2 && oi.Type == 2 && oi.CancelFlag == 0).ToList();
 | 
				
			||||||
                    for (int j = 0; j < invoicesManuNo.Count; j++)
 | 
					                    for (int j = 0; j < invoicesManuNo.Count; j++)
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        //查询是否有库存
 | 
					                        //查询是否有库存
 | 
				
			||||||
| 
						 | 
					@ -366,7 +366,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                           .Select(it =>
 | 
					                           .Select(it =>
 | 
				
			||||||
                           {
 | 
					                           {
 | 
				
			||||||
                               var ret = it.First();
 | 
					                               var ret = it.First();
 | 
				
			||||||
                               ret.AddQuantity = invoicesManuNo[j].quantity;
 | 
					                               ret.AddQuantity = invoicesManuNo[j].Units== invoicesManuNo[j].DrugInfo.SmallUnit? invoicesManuNo[j].quantity: invoicesManuNo[j].quantity* invoicesManuNo[j].DrugInfo.ConvertRatio;
 | 
				
			||||||
                               return ret;
 | 
					                               return ret;
 | 
				
			||||||
                           })
 | 
					                           })
 | 
				
			||||||
                           .ToList();
 | 
					                           .ToList();
 | 
				
			||||||
| 
						 | 
					@ -525,6 +525,10 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            ChannelStock it = record[i];
 | 
					                            ChannelStock it = record[i];
 | 
				
			||||||
 | 
					                            if(it.AddQuantity<=0)
 | 
				
			||||||
 | 
					                            {
 | 
				
			||||||
 | 
					                                continue;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
                            if (it.BoardType == 6 && it.PosNo == 0)
 | 
					                            if (it.BoardType == 6 && it.PosNo == 0)
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
                                _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
 | 
					                                _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
 | 
				
			||||||
| 
						 | 
					@ -623,7 +627,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        // 更新屏显库存
 | 
					                        // 更新屏显库存
 | 
				
			||||||
                        //List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
 | 
					                        //List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
 | 
				
			||||||
                        List<ChannelStock> singleChannels = record.Where(it => it.BoardType != 1)
 | 
					                        List<ChannelStock> singleChannels = record.Where(it => it.BoardType != 1&&it.AddQuantity>0)
 | 
				
			||||||
                                                                        .GroupBy(it => new { it.DrawerNo, it.ColNo })
 | 
					                                                                        .GroupBy(it => new { it.DrawerNo, it.ColNo })
 | 
				
			||||||
                                                                        .Select(it =>
 | 
					                                                                        .Select(it =>
 | 
				
			||||||
                                                                        {
 | 
					                                                                        {
 | 
				
			||||||
| 
						 | 
					@ -744,8 +748,8 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            var sb = new StringBuilder();
 | 
					            var sb = new StringBuilder();
 | 
				
			||||||
            //sb.Append("select i.invoice_no as InvoiceNo, i.invoice_date as InvoiceDate, COUNT(i.id) as `Count`, SUM(i.quantity) as quantity, p1.pharmacy_name as PharmacyName1, p2.pharmacy_name as PharmacyName2 from in_out_invoice i");
 | 
					            //sb.Append("select i.invoice_no as InvoiceNo, i.invoice_date as InvoiceDate, COUNT(i.id) as `Count`, SUM(i.quantity) as quantity, p1.pharmacy_name as PharmacyName1, p2.pharmacy_name as PharmacyName2 from in_out_invoice i");
 | 
				
			||||||
            sb.Append(" SELECT count(1) as Count, i.InvoiceNo, i.InvoiceDate, sum(i.quantity) as quantity, p1.pharmacy_name as PharmacyName1, p2.pharmacy_name PharmacyName2 from ");
 | 
					            sb.Append(" SELECT count(1) as Count, i.InvoiceNo, i.InvoiceDate, sum(i.quantity) as quantity, p1.pharmacy_name as PharmacyName1, p2.pharmacy_name PharmacyName2 from ");
 | 
				
			||||||
            sb.Append(" (SELECT drug_id,in_pharmacy_id,out_pharmacy_id, invoice_no as InvoiceNo, DATE_FORMAT(Invoice_Date,'%Y-%m-%d')  as InvoiceDate, SUM(quantity) as quantity ");
 | 
					            sb.Append(" (SELECT io.drug_id,io.in_pharmacy_id,io.out_pharmacy_id, io.invoice_no as InvoiceNo, DATE_FORMAT(io.Invoice_Date,'%Y-%m-%d')  as InvoiceDate, SUM(IF(di.small_unit=io.units,io.quantity,io.quantity*di.convert_ratio)) as quantity  ");
 | 
				
			||||||
            sb.Append(" FROM in_out_invoice where status=@Status  and type=@type  and cancel_flag=@CancelFlag GROUP BY invoice_no,drug_id) i ");
 | 
					            sb.Append(" FROM in_out_invoice io inner join drug_info di on io.drug_id=di.drug_id where io.status=@Status  and io.type=@type  and io.cancel_flag=@CancelFlag GROUP BY io.invoice_no,io.drug_id) i ");
 | 
				
			||||||
            sb.Append(" inner join ( select c.drug_id as drug_id from channel_list c where c.machine_id = '" + (ConfigurationManager.AppSettings["machineId"] ?? "DM1") + "' group by c.drug_id ) di on di.drug_id = i.drug_id");
 | 
					            sb.Append(" inner join ( select c.drug_id as drug_id from channel_list c where c.machine_id = '" + (ConfigurationManager.AppSettings["machineId"] ?? "DM1") + "' group by c.drug_id ) di on di.drug_id = i.drug_id");
 | 
				
			||||||
            sb.Append(" left join pharmacy_info p1 on p1.pharmacy = i.in_pharmacy_id");
 | 
					            sb.Append(" left join pharmacy_info p1 on p1.pharmacy = i.in_pharmacy_id");
 | 
				
			||||||
            sb.Append(" left join pharmacy_info p2 on p2.pharmacy = i.out_pharmacy_id where 1=1");
 | 
					            sb.Append(" left join pharmacy_info p2 on p2.pharmacy = i.out_pharmacy_id where 1=1");
 | 
				
			||||||
| 
						 | 
					@ -769,7 +773,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            Invoices = SqlSugarHelper.Db.SqlQueryable<dynamic>(sb.ToString())
 | 
					            Invoices = SqlSugarHelper.Db.SqlQueryable<dynamic>(sb.ToString())
 | 
				
			||||||
                .AddParameters(new
 | 
					                .AddParameters(new
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    Status = 0,
 | 
					                    Status = 2,
 | 
				
			||||||
                    type = 2,
 | 
					                    type = 2,
 | 
				
			||||||
                    CancelFlag = 0,
 | 
					                    CancelFlag = 0,
 | 
				
			||||||
                    CreateTime = OrderDate,
 | 
					                    CreateTime = OrderDate,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -182,7 +182,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
        public async void OpenOrderDialog()
 | 
					        public async void OpenOrderDialog()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            //if (SelectedOrder != null && SelectedOrder.DmStatus == 0 && SelectedOrder.CancelFlag == 0 && SelectedOrder.HisDispFlag == 0)
 | 
					            //if (SelectedOrder != null && SelectedOrder.DmStatus == 0 && SelectedOrder.CancelFlag == 0 && SelectedOrder.HisDispFlag == 0)
 | 
				
			||||||
            if (SelectedOrder != null && SelectedOrder.DmStatus == 1 && SelectedOrder.CancelFlag == 1 && SelectedOrder.HisDispFlag == 1)
 | 
					            if (SelectedOrder != null && SelectedOrder.DmStatus == 1 && SelectedOrder.CancelFlag == 1)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                // 此处延时1毫秒,等待页面渲染
 | 
					                // 此处延时1毫秒,等待页面渲染
 | 
				
			||||||
                await Task.Delay(TimeSpan.FromMilliseconds(1));
 | 
					                await Task.Delay(TimeSpan.FromMilliseconds(1));
 | 
				
			||||||
| 
						 | 
					@ -227,7 +227,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PatientId"), oi => oi.PatientId == SearchValue)
 | 
					                .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PatientId"), oi => oi.PatientId == SearchValue)
 | 
				
			||||||
                .WhereIF(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]), oi => oi.Pharmacy == ConfigurationManager.AppSettings["storage"])
 | 
					                .WhereIF(!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]), oi => oi.Pharmacy == ConfigurationManager.AppSettings["storage"])
 | 
				
			||||||
                .Where(oi => oi.DmStatus == 1)
 | 
					                .Where(oi => oi.DmStatus == 1)
 | 
				
			||||||
                .Where(oi => oi.HisDispFlag == 1)
 | 
					                //.Where(oi => oi.HisDispFlag == 1)
 | 
				
			||||||
                .Where(oi => oi.CancelFlag == 1)
 | 
					                .Where(oi => oi.CancelFlag == 1)
 | 
				
			||||||
                .GroupBy(oi => oi.OrderDate)
 | 
					                .GroupBy(oi => oi.OrderDate)
 | 
				
			||||||
                .Select(oi => oi)
 | 
					                .Select(oi => oi)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue