交接柜补药页面添加药品分组

This commit is contained in:
maqiao 2024-12-02 10:55:28 +08:00
parent e9a3d6467d
commit afe1866439
2 changed files with 24 additions and 11 deletions

View File

@ -26,10 +26,13 @@ namespace DM_Weight.Port
private readonly ILog logger = LogManager.GetLogger(typeof(CheckOrderNewWindowViewModel));
public ModbusHelper()
{
socket = MakeKeepALiveSocket();
client = new TcpClient();
client.Client = socket;
master = ModbusIpMaster.CreateIp(client);
if (ConfigurationManager.AppSettings["test"] == null || !(ConfigurationManager.AppSettings["test"].ToString().Equals("Y")))
{
socket = MakeKeepALiveSocket();
client = new TcpClient();
client.Client = socket;
master = ModbusIpMaster.CreateIp(client);
}
}
public static ModbusHelper GetInstance()
@ -56,9 +59,9 @@ namespace DM_Weight.Port
public bool[] GetAllBoxState()
{
if (ConfigurationManager.AppSettings["test"]!=null&&ConfigurationManager.AppSettings["test"].ToString().Equals("Y"))
if (ConfigurationManager.AppSettings["test"] != null && ConfigurationManager.AppSettings["test"].ToString().Equals("Y"))
{
return new bool[] { false,false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
return new bool[] { false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false };
}
bool[] bools = Policy.Handle<Exception>()
.Retry(3, (exception, retryCount) =>
@ -79,7 +82,7 @@ namespace DM_Weight.Port
{
flags[i] = r2[17 - i] == '1' ? true : false;
}
logger.Info($"获取所有箱子门状态返回:{string.Join(',',flags)}");
logger.Info($"获取所有箱子门状态返回:{string.Join(',', flags)}");
return flags;
});
return bools;
@ -90,7 +93,7 @@ namespace DM_Weight.Port
{
return true;
}
bool bFlag=false;
bool bFlag = false;
Policy.Handle<Exception>().Retry(3, ((exception, retryCount) =>
{
this.Dispose();
@ -124,7 +127,7 @@ namespace DM_Weight.Port
BitConverter.GetBytes((uint)10000).CopyTo(inOptionValues, Marshal.SizeOf(dummy) * 2);//发探测包时间间隔
//IPEndPoint iep = new IPEndPoint(IPAddress.Parse("192.168.1.13"), 502);
string modbusIp = ConfigurationManager.AppSettings["modbusIp"].ToString();
int modbusPort =Convert.ToInt32(ConfigurationManager.AppSettings["modbusPort"]);
int modbusPort = Convert.ToInt32(ConfigurationManager.AppSettings["modbusPort"]);
IPEndPoint iep = new IPEndPoint(IPAddress.Parse(modbusIp), modbusPort);
Socket _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
_socket = Policy.Handle<Exception>()

View File

@ -75,6 +75,13 @@ namespace DM_Weight.ViewModels
.OrderBy(cs => cs.Chnguid)
.OrderBy(cs => cs.DrawerNo)
.ToList();
ChannelStocks= ChannelStocks.GroupBy(it=>new {it.DrawerNo,it.DrugId})
.Select(it=>
{
var ret = it.First();
ret.Quantity = it.Sum(itx => itx.Quantity);
return ret;
}).ToList();
ChannelStocks.ForEach(cs => cs.AddQuantity = cs.BaseQuantity - cs.Quantity);
}
//开药箱放入药品
@ -129,8 +136,11 @@ namespace DM_Weight.ViewModels
Quantity = jiaojie_it.BaseQuantity,
//ManuNo = it.ManuNo,
//EffDate = it.EffDate,
Id = jiaojie_it.Id,
}).UpdateColumns(jiaojie_it => new { jiaojie_it.Quantity }).ExecuteCommand();
//Id = jiaojie_it.Id,
DrugId=jiaojie_it.DrugId,
DrawerNo=jiaojie_it.DrawerNo,
MachineId=jiaojie_it.MachineId,
}).UpdateColumns(jiaojie_it => new { jiaojie_it.Quantity }).WhereColumns(jiaojie_it=>new { jiaojie_it.DrugId, jiaojie_it.DrawerNo, jiaojie_it.MachineId }).ExecuteCommand();
}
List<ChannelStock> jiaojie = selectedStock.GroupBy(cs => cs.DrawerNo).Select(cs => cs.FirstOrDefault()).ToList();