调拨入库根据调拨单中的单位与药品信息表中小单位做对比进行单位转换
This commit is contained in:
		
							parent
							
								
									b02847a5c6
								
							
						
					
					
						commit
						0c085b4bab
					
				| 
						 | 
				
			
			@ -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_xianchang;userid=root;password=root" />
 | 
			
		||||
	<add name="database" connectionString="server=127.0.0.1;port=3306;database=sanya_xianchang2;userid=root;password=root" />
 | 
			
		||||
  </connectionStrings>
 | 
			
		||||
	<!--<runtime>
 | 
			
		||||
		--><!--配置之后,Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!--
 | 
			
		||||
| 
						 | 
				
			
			@ -12,7 +12,7 @@
 | 
			
		|||
	<appSettings>
 | 
			
		||||
		
 | 
			
		||||
		<!-- 设备id -->
 | 
			
		||||
		<add key="machineId" value="DM2" />
 | 
			
		||||
		<add key="machineId" value="DM1" />
 | 
			
		||||
		<!-- 供应单位 -->
 | 
			
		||||
		<add key="supplierDept" value="药库" />
 | 
			
		||||
		<!-- 领用部门 -->
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -93,7 +93,12 @@ namespace DM_Weight.Models
 | 
			
		|||
 | 
			
		||||
        [SugarColumn(IsIgnore = true)]
 | 
			
		||||
        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
 | 
			
		||||
                            {
 | 
			
		||||
                                Thread.Sleep(100);
 | 
			
		||||
                                Thread.Sleep(200);
 | 
			
		||||
                                // 灯在闪烁继续监听状态
 | 
			
		||||
                                GetBackDoorState();
 | 
			
		||||
                            }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,6 +16,7 @@ using System.Collections.Generic;
 | 
			
		|||
using System.Collections.ObjectModel;
 | 
			
		||||
using System.Configuration;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Reactive;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
| 
						 | 
				
			
			@ -291,7 +292,7 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
            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)
 | 
			
		||||
                                                    .AddParameters(new
 | 
			
		||||
| 
						 | 
				
			
			@ -321,8 +322,9 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
                    }
 | 
			
		||||
                    //ChannelStock stock = new ChannelStock();
 | 
			
		||||
                    //查询每种药有多少个批次
 | 
			
		||||
                    var invoicesManuNo = SqlSugarHelper.Db.Queryable<InOutInvoice>()
 | 
			
		||||
                               .Where(iManuNo => iManuNo.InvoiceNo == invoices[i].InvoiceNo && iManuNo.DrugId == invoices[i].DrugId && iManuNo.Status == 0 && iManuNo.Type == 2 && iManuNo.CancelFlag == 0).ToList();
 | 
			
		||||
                    var invoicesManuNo = SqlSugarHelper.Db.Queryable<InOutInvoice>().Includes<DrugInfo>(oi => oi.DrugInfo).InnerJoin<DrugInfo>((oi, di) => oi.DrugId == di.DrugId)
 | 
			
		||||
                              .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++)
 | 
			
		||||
                    {
 | 
			
		||||
                        //查询是否有库存
 | 
			
		||||
| 
						 | 
				
			
			@ -362,7 +364,7 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
                           .Select(it =>
 | 
			
		||||
                           {
 | 
			
		||||
                               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;
 | 
			
		||||
                           })
 | 
			
		||||
                           .ToList();
 | 
			
		||||
| 
						 | 
				
			
			@ -520,7 +522,11 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
                        {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                            ChannelStock it = record[i];
 | 
			
		||||
                            ChannelStock it = record[i]; 
 | 
			
		||||
                            if (it.AddQuantity <= 0)
 | 
			
		||||
                            {
 | 
			
		||||
                                continue;
 | 
			
		||||
                            }
 | 
			
		||||
                            if (it.BoardType == 6 && it.PosNo == 0)
 | 
			
		||||
                            {
 | 
			
		||||
                                _portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
 | 
			
		||||
| 
						 | 
				
			
			@ -619,7 +625,7 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
                    {
 | 
			
		||||
                        // 更新屏显库存
 | 
			
		||||
                        //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 })
 | 
			
		||||
                                                                        .Select(it =>
 | 
			
		||||
                                                                        {
 | 
			
		||||
| 
						 | 
				
			
			@ -740,9 +746,9 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
 | 
			
		||||
            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 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(" FROM in_out_invoice where status=@Status  and type=@type  and cancel_flag=@CancelFlag GROUP BY invoice_no,drug_id) 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 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 io inner join drug_info di on io.drug_id=di.drug_id where io.status=@Status  and 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(" 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");
 | 
			
		||||
| 
						 | 
				
			
			@ -766,7 +772,7 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
            Invoices = SqlSugarHelper.Db.SqlQueryable<dynamic>(sb.ToString())
 | 
			
		||||
                .AddParameters(new
 | 
			
		||||
                {
 | 
			
		||||
                    Status = 0,
 | 
			
		||||
                    Status = 2,
 | 
			
		||||
                    type = 2,
 | 
			
		||||
                    CancelFlag = 0,
 | 
			
		||||
                    CreateTime = OrderDate,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -182,7 +182,7 @@ namespace DM_Weight.ViewModels
 | 
			
		|||
        public async void OpenOrderDialog()
 | 
			
		||||
        {
 | 
			
		||||
            //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毫秒,等待页面渲染
 | 
			
		||||
                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(ConfigurationManager.AppSettings["storage"]), oi => oi.Pharmacy == ConfigurationManager.AppSettings["storage"])
 | 
			
		||||
                .Where(oi => oi.DmStatus == 1)
 | 
			
		||||
                .Where(oi => oi.HisDispFlag == 1)
 | 
			
		||||
                //.Where(oi => oi.HisDispFlag == 1)
 | 
			
		||||
                .Where(oi => oi.CancelFlag == 1)
 | 
			
		||||
                .GroupBy(oi => oi.OrderDate)
 | 
			
		||||
                .Select(oi => oi)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue