Commit 182d6cbf by zxw

大屏调用接口转发主平台

调整定时任务调用的数据库模式
parent 5c9dc64a
......@@ -2085,6 +2085,157 @@ namespace JunmpPoliceStation.Controllers
}
/// <summary>
/// 通过箱标/件标epc获取件标epc(混装 智能货架使用)
/// </summary>
/// <remarks>
///
/// ## 例子
///
/// {
/// "epcList":[
/// {"epc":"箱标/件标epc"},
/// {"epc":"箱标/件标epc"},
/// ]
///
/// }
///
/// </remarks>
/// <param name="jdata"></param>
/// <returns></returns>
[HttpPost("GetEpcListByEpc")]
public async Task<HttpResponseMessage> GetEpcListByEpc([FromBody] JObject jdata)
{
return await Task.Run(() =>
{
try
{
if (jdata != null)
{
var entity = JsonManager.GetJsonEntity(jdata);
Expression<Func<CommonJpEquipmentBoxMark, bool>> xbExpression = t => t.ReloadBoxingState != 1;
Expression<Func<CommonJpEquipmentInventory, bool>> jbExpression = t => t.InventoryState != "loss" && t.CurrentState == 0;
var xbEpcList = new List<string>();
var jbEpcList = new List<string>();
foreach (var epc in entity.epcList)
{
if (!string.IsNullOrEmpty(epc.epc))
{
if (epc.epc.Length == 24)
{
//旧版箱标
xbEpcList.Add(epc.epc);
continue;
}
var buffer = EpcConvert.ToHexByte(epc.epc);
var epc_info = EpcConvert.EpcAnlysing(buffer);
if (epc_info.TagType == 0x00)
{
//件标
jbEpcList.Add(epc.epc);
}
else
{
xbEpcList.Add(epc.epc);
}
}
}
if (xbEpcList.Count == 0 && jbEpcList.Count == 0)
{
return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR);
}
xbExpression = xbExpression.AndAlso(x => xbEpcList.Contains(x.Epc) || xbEpcList.Contains(x.OldEpc));
jbExpression = jbExpression.AndAlso(x => jbEpcList.Contains(x.Epc));
var param = new string[] {
"Warehouse",
"EquipmentDetail",
"Size",
"Supplier",
"CommonJpEquipmentInventories"
};
var param2 = new string[] {
"WarehouseCodeNavigation",
"EquipmentCodeNavigation",
"EquipmentSizecodeNavigation",
"SupplierCodeNavigation",
};
var data = _unitOfWork.EquipmentBoxMarkRepository.GetList(xbExpression, includes: param).ToList();
var data2 = _unitOfWork.EquipmentInventoryRepository.GetList(jbExpression, includes: param2).ToList();
var res = new List<object>();
res.AddRange(data.Select(x =>
new
{
id = x.Id,
createTime = x.CreateTime,
epc = x.Epc,
oneBoxNum = x.OneBoxNum,
warehouseId = x.WarehouseId,
warehouseName = x.Warehouse.Name,
orgizationId = x.Warehouse.OrgizationId,
equipmentInfoId = x.EquipmentDetail.EquipmentId,
equipmentDetailId = x.EquipmentDetailId,
equipmentDetailName = x.EquipmentDetail.Name,
equipmentDetailCode = x.EquipmentDetail.Code,
sizeId = x.SizeId,
sizeName = x.Size.SizeName,
sizeCode = x.Size.SizeCode,
sizeEpcType = x.Size.EpcType,
supplierId = x.SupplierId,
supplierCode = x.Supplier.SupplierCode,
supplierName = x.Supplier.Name,
oldEpc = x.OldEpc,
epcList = x.CommonJpEquipmentInventories.Select(y => y.Epc)
}).ToList());
res.AddRange(data2.Select(x =>
new
{
id = x.Id,
createTime = x.CreateTime,
epc = x.Epc,
oneBoxNum = 1,
warehouseId = x.WarehouseCode,
warehouseName = x.WarehouseCodeNavigation.Name,
orgizationId = x.WarehouseCodeNavigation.OrgizationId,
equipmentInfoId = x.EquipmentCodeNavigation.EquipmentId,
equipmentDetailId = x.EquipmentCode,
equipmentDetailName = x.EquipmentCodeNavigation.Name,
equipmentDetailCode = x.EquipmentCodeNavigation.Code,
sizeId = x.EquipmentSizecode,
sizeName = x.EquipmentSizecodeNavigation.SizeName,
sizeCode = x.EquipmentSizecodeNavigation.SizeCode,
sizeEpcType = x.EquipmentSizecodeNavigation.EpcType,
supplierId = x.SupplierCode,
supplierCode = x.SupplierCodeNavigation.SupplierCode,
supplierName = x.SupplierCodeNavigation.Name,
oldEpc = (string)null,
epcList = new List<string>() { x.Epc }
}).ToList());
return JsonManager.ReturnSuccessResponse(res);
}
else
{
return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR);
}
}
catch (Exception ex)
{
//_logger.LogError("Login/SignIn 错误:" + ex.ToString());
return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_FAILED);
}
});
}
/// <summary>
/// 根据装备包实例id获取物资出入流水记录
/// </summary>
/// <remarks>
......
......@@ -28,12 +28,15 @@ namespace JunmpPoliceStation.Extensions
HttpHelper _httpHelper;
private IConfiguration Configuration;
private ILogger<CronJob> _logger;
public CronJob(JunmppolicesqlContext dbContext, IConfiguration configuration, ILogger<CronJob> logger, HttpHelper httpHelper)
public CronJob(IConfiguration configuration, ILogger<CronJob> logger, HttpHelper httpHelper)
{
_dbContext = dbContext;
_httpHelper = httpHelper;
Configuration = configuration;
_logger = logger;
var options = new DbContextOptionsBuilder<JunmppolicesqlContext>();
options.UseMySQL(Configuration.GetConnectionString("MySqlConnection"));
_dbContext = new JunmppolicesqlContext(options.Options);
}
public void SyncEquipmentState()
......@@ -169,9 +172,9 @@ namespace JunmpPoliceStation.Extensions
Postdata = reqData,
IsNoTIP = true
});
if (res.StatusCode!=HttpStatusCode.Created)
if (res.StatusCode != HttpStatusCode.Created)
{
_logger.LogError("获取ACCESS_TOKEN失败 code:" + res.StatusCode +JsonConvert.SerializeObject(res));
_logger.LogError("获取ACCESS_TOKEN失败 code:" + res.StatusCode + JsonConvert.SerializeObject(res));
return false;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论