Commit 0481217c by Seniorious

1

parent 2dc38498
......@@ -768,6 +768,10 @@ namespace APIs.Controllers
var policeName = string.IsNullOrEmpty(req.policeId) ? "" : (await _policeInfoService.QueryOne(s => s.id.Equals(req.policeId)))?.name;
var orgInfo = await _thisInfoService.QueryOne(s => true);
var warrantyList = (await _viewWarrantyWarnService.Query()).Select(s => s.epc).ToList();//超期提醒
Dictionary<string, int> warrantyDic = new Dictionary<string, int>();
foreach (var epc in epcList)
{
var epc_info = EpcConvert.EpcAnlysing(EpcConvert.ToHexByte(epc));
......@@ -840,6 +844,18 @@ namespace APIs.Controllers
updateTime = DateTime.Now,
});
if(warrantyList != null && warrantyList.Contains(epc))
{
string thisKey = $"{mysize.id}||{mytype?.name}({mysize.name})";
if (warrantyDic.TryGetValue(thisKey, out int va))
{
warrantyDic[thisKey] += 1;
}
else
{
warrantyDic.Add(thisKey, 1);
}
}
}
else
{
......@@ -883,16 +899,36 @@ namespace APIs.Controllers
var rs = await _logService.AddChannelLog(myOrder, summary, newEquList);
return rs ? new ApiResult
if (rs)
{
string msg = $"{(req.state == 0 ? "出库" : "入库")}成功{summary.number}件";
if (warrantyDic.Any())
{
msg += ",即将超期或已超期:";
foreach (var item in warrantyDic)
{
var name = item.Key.Split(new string[] { "||" }, StringSplitOptions.None).Skip(1).FirstOrDefault();
msg += $"{name}{item.Value}件,";
};
msg = msg.Substring(0, msg.Length - 1);
}
return new ApiResult
{
code = ResultCode.OPERATE_SUCCESS.Code,
msg = ResultCode.OPERATE_SUCCESS.Msg
}: new ApiResult
msg = msg
};
}
else
{
return new ApiResult
{
code = ResultCode.OPERATE_FAILED.Code,
msg = ResultCode.OPERATE_FAILED.Msg
};
}
}
catch (Exception ex)
{
var error = new ApiResult
......
......@@ -31,7 +31,8 @@ namespace Common
public ulong TimeSpan { get; set; } //当前日期时间戳,精确到毫秒
public byte MachineNum { get; set; } //服务器识别码(4bits),用于区分测试服务器与正式服务器生成的数据,实际1b就够了,其他3b做保留
/*---------以下为警用装备3.0添加参数-----------*/
public byte EType { get; set; } //1单标签 2双标签 3三标签(兼容2.0标签 2.0解析输出0)
public byte EType; //1单标签 2双标签 3三标签(兼容2.0标签 2.0解析输出0)
public byte EProperty; // 资产类型:0固定资产 1非固定资产(仅限3.0标签)
}
public static class EpcConvert
......@@ -154,6 +155,69 @@ namespace Common
}
/// <summary>
/// 生成3.0EPC
/// </summary>
/// <param name="epc"></param>
/// <returns></returns>
public static byte[] Epc3Gen(Analyzingepc epc)
{
byte[] buf = new byte[40];
int pos = 0;
SetData(ref buf, pos, 8, epc.Header);
pos += 8;
SetData(ref buf, pos, 6, epc.IssuerId);
pos += 6;
SetData(ref buf, pos, 54, OrganizationCodeTo6Bin(epc.OrganizationCode.ToUpper()));
pos += 54;
SetData(ref buf, pos, 4, epc.WzdmLen);
pos += 4;
var wzlen = ((epc.WzdmLen - 1) % 8) * 8;
SetData(ref buf, pos, wzlen, epc.Wzdm); // 物资代码暂时定义最长为64bits
pos += wzlen;
SetData(ref buf, pos, 8, epc.Hxdm); // 物资代码暂时定义最长为64bits
pos += 8;
SetData(ref buf, pos, 4, epc.SerialLen);
pos += 4;
/*----------------2.0版本字段-------------*/
SetData(ref buf, pos, 8, epc.Ver);
pos += 8;
SetData(ref buf, pos, 24, epc.ProductionDate);
pos += 24;
SetData(ref buf, pos, 6, epc.ExpiryDate);
pos += 6;
SetData(ref buf, pos, 2, epc.ExpiryDateUnit);
pos += 2;
SetData(ref buf, pos, 48, epc.TimeSpan);
pos += 48;
SetData(ref buf, pos, 12, epc.NoInBox);
pos += 12;
/*----------------警用装备3.0字段-------------*/
SetData(ref buf, pos, 4, epc.EProperty);
pos += 4;
SetData(ref buf, pos, 4, epc.EType);
pos += 4;
// 双字节对齐, 剩余保留区
if (pos % 16 != 0)
{
pos += 16 - pos % 16;
}
// 数据体长度
var len = pos / 8;
var crc = Crc16(buf, len);
SetData(ref buf, pos, 16, crc);
byte[] rtn = new byte[len + 2];
Array.Copy(buf, rtn, len + 2);
return rtn;
}
/// <summary>
/// 生成EPC
/// </summary>
/// <param name="epc"></param>
......@@ -270,6 +334,23 @@ namespace Common
rtn.EType = (byte)GetData(epc, pos, 4);
pos += 4;
}
else if (rtn.Ver == 0x03)
{
rtn.ProductionDate = (byte)GetData(epc, pos, 24);
pos += 24;
rtn.ExpiryDate = (byte)GetData(epc, pos, 6);
pos += 6;
rtn.ExpiryDateUnit = (byte)GetData(epc, pos, 2);
pos += 2;
rtn.TimeSpan = (byte)GetData(epc, pos, 48);
pos += 48;
rtn.NoInBox = (byte)GetData(epc, pos, 12);
pos += 12;
rtn.EProperty = (byte)GetData(epc, pos, 4);
pos += 4;
rtn.EType = (byte)GetData(epc, pos, 4);
pos += 4;
}
else
{
rtn.TagType = (byte)GetData(epc, pos, 8);
......@@ -340,14 +421,14 @@ namespace Common
pos += 48;
rtn.NoInBox = (UInt16)GetData(epc, pos, 12);
pos += 12;
rtn.MachineNum = (byte)GetData(epc, pos, 4);
rtn.EProperty = (byte)GetData(epc, pos, 4);
pos += 4;
rtn.EType = (byte)GetData(epc, pos, 4);
pos += 4;
rtn.EType = 1;
string baseEpc = Hex16ByteToHex16String(EpcConvert.Epc2Gen(rtn)).Replace(" ", "");
string baseEpc = Hex16ByteToHex16String(EpcConvert.Epc3Gen(rtn)).Replace(" ", "");
return baseEpc;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论