Commit 4c886347 by Seniorious

1

parent 3cad28fc
......@@ -40,6 +40,9 @@ using static JmpDehumidifierLib.Dehumidifier;
using JmpDehumidifierLib;
using NLog.Fluent;
using System.Security.Policy;
using Quartz.Util;
using static Dm.parser.LVal;
using System.IO.Pipelines;
namespace APIs.Controllers
{
......@@ -169,6 +172,147 @@ namespace APIs.Controllers
}
/// <summary>
/// 手持机上传盘点单据结果
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
[HttpPost]
public async Task<ApiResult> UploadInventoryOrder([FromBody] UploadInventoryOrderReq req)
{
try
{
#region 合法判断
if (req.orderId == null || req.orderId == 0)
{
return new ApiResult
{
code = ResultCode.OPERATE_FAILED.Code,
msg = "参数不正确",
};
}
var inventoryMain = await _bussinessInventoryService.QueryOne(s => s.id == req.orderId);
if (inventoryMain == null) return new ApiResult { code = ResultCode.OPERATE_FAILED.Code, msg = "盘点单据不存在" };
if (inventoryMain.inventoryState != "running") return new ApiResult { code = ResultCode.OPERATE_FAILED.Code, msg = "盘点单据未开启" };
#endregion
var inventoryDetail = await _bussinessInventoryDetailService.Query(s => s.inventoryId == req.orderId);
inventoryMain.inventoryState = "finished";
inventoryMain.updateTime = DateTime.Now;
inventoryMain.totalNum = req.totalNum;
inventoryMain.actualNum = req.actualNum;
inventoryMain.addNum = req.addNum;
inventoryMain.deleteNum = req.deleteNum;
#region 金额字典
Dictionary<string, decimal?> invDic = (await _inventoryService.Query())
.Select(s => new { Key = s.epc, Value = s.price })
.ToDictionary(s => s.Key, s => s.Value);
Dictionary<string, decimal> sizeDic = (await _equipmentSizeService.Query())
.Select(s => new { Key = s.id, Value = Convert.ToDecimal(s.price) })
.ToDictionary(s => s.Key, s => s.Value);
#endregion
var equs = new List<string>();
foreach (var detail in req.detailList)
{
var de = inventoryDetail.FirstOrDefault(s => s.id == detail.id);
if (de == null) continue;
de.updateTime = inventoryMain.updateTime;
de.stockNumber = detail.stockNumber;
de.fixNumber = detail.fixNumber;
de.num = detail.num;
de.state = detail.state;
if (!sizeDic.TryGetValue(de.sizeId, out var spr)) spr = 0;
equs.AddRange(detail.epcList);
foreach (var epc in detail.epcList)
{
if (invDic.TryGetValue(epc, out var ipr))
{
de.fixPrice += ipr;
}
else
{
de.fixPrice += spr;
}
}
}
inventoryMain.epcUpdate = JsonConvert.SerializeObject(equs);
if (await _bussinessInventoryService.UploadInventoryOrder(inventoryMain, inventoryDetail))
{
var param = new
{
orderId = inventoryMain.id,
totalNum = inventoryMain.totalNum,
actualNum = inventoryMain.actualNum,
addNum = inventoryMain.addNum,
deleteNum = inventoryMain.deleteNum,
epcList = inventoryMain.epcUpdate,
equipmentList = inventoryDetail.Select(s => new
{
typeId = s.typeId,
sizeId = s.sizeId,
stockNumber = s.stockNumber,
fixNumber = s.fixNumber,
num = s.num,
price = s.fixPrice,
state = s.state,
})
};
string resJson = HttpHelper.HttpPost(AdminGlobalContext.jyzbConfig.Url + "BussinessInventory/UploadStock", JsonConvert.SerializeObject(param));
var res = JsonConvert.DeserializeObject<res<string>>(resJson);
if (res.code.Equals("99200"))
{
return new ApiResult
{
code = ResultCode.OPERATE_SUCCESS.Code,
msg = ResultCode.OPERATE_SUCCESS.Msg,
};
}
else
{
inventoryMain.inventoryState = "running";
await _bussinessInventoryService.Update(inventoryMain);
return new ApiResult
{
code = ResultCode.OPERATE_FAILED.Code,
msg = "上报平台失败",
};
}
}
else
{
return new ApiResult
{
code = ResultCode.OPERATE_FAILED.Code,
msg = "更新盘点单据失败",
};
}
}
catch (Exception ex)
{
var error = new ApiResult
{
code = ResultCode.OPERATE_FAILED.Code,
msg = ex.Message,
};
return error;
}
}
/// <summary>
/// 手持机获取盘点单据
/// </summary>
/// <param name="req"></param>
......@@ -203,8 +347,8 @@ namespace APIs.Controllers
month = s.month,
applyTime = s.applyTime,
createTime = s.createTime,
warehouseId= s.warehouseId,
warehouseName=s.warehouseName,
warehouseId = s.warehouseId,
warehouseName = s.warehouseName,
}).ToList();
var src = new ApiResult
......@@ -812,8 +956,8 @@ namespace APIs.Controllers
};
}
var removeEpcs = myOrder != null
? PendingEpc.Except(warehouseInvtory.Where(s => s.state == reqState).Select(s => s.epc).ToList()).ToList()
var removeEpcs = myOrder != null
? PendingEpc.Except(warehouseInvtory.Where(s => s.state == reqState).Select(s => s.epc).ToList()).ToList()
: PendingEpc.Except(warehouseInvtory.Select(s => s.epc).ToList()).ToList();
epcList = PendingEpc.Where(s => !removeEpcs.Contains(s)).ToList();
}
......@@ -1065,7 +1209,7 @@ namespace APIs.Controllers
policeId = req.policeId,
fingerList = req.fingerList.Select(s => new { fingerInfo = s.fingerInfo, fingerNum = s.fingerNum })
};
var json = HttpHelper.HttpPost(/*AdminGlobalContext.jyzbConfig.Url*/"http://192.168.2.14:10030" + "/PolicemanFinger/insertOrUpdateFingerInfo", JsonConvert.SerializeObject(send));
var json = HttpHelper.HttpPost(AdminGlobalContext.jyzbConfig.Url + "/PolicemanFinger/insertOrUpdateFingerInfo", JsonConvert.SerializeObject(send));
var httprs = JsonConvert.DeserializeObject<HttpHelper.res<string>>(json);
if (httprs != null && httprs.code == "99200")
......
......@@ -51,4 +51,26 @@ namespace APIs.Req
public int? setState { get; set; }
public string setHumid { get; set; }
}
public class UploadInventoryOrderReq
{
public long? orderId { get; set; }
public int? totalNum { get; set; }
public int? actualNum { get; set; }
public int? addNum { get; set; }
public int? deleteNum { get; set; }
public List<InventoryDetail> detailList { get; set; }
public class InventoryDetail
{
public long? id { get; set; }
public string type_id { get; set; }
public string sizeId { get; set; }
public int? stockNumber { get; set; }
public int? fixNumber { get; set; }
public int? num { get; set; }
public int? state { get; set; }
public List<string> epcList { get; set; }
}
}
}
\ No newline at end of file
......@@ -9,6 +9,7 @@ namespace Repositories.IRepository.IBussiness
{
public interface IBussinessInventoryRepository : IBaseRepository<BussinessInventory>
{
Task<bool> UploadInventoryOrder(BussinessInventory main, List<BussinessInventoryDetail> details);
Task<BussinessInventory>? GenerateInventoryOrder(BussinessInventory myBIOrder);
Task<bool> OrderRollBack(BussinessInventory myBIOrder);
}
......
......@@ -127,5 +127,45 @@ namespace Repositories.Repository.Bussiness
}
}
}
public async Task<bool> UploadInventoryOrder(BussinessInventory main, List<BussinessInventoryDetail> details)
{
using (var context = _suger.GetDbClient())
{
try
{
context.BeginTran();
context.Updateable(main).UpdateColumns(it => new
{
it.updateTime,
it.inventoryState,
it.addNum,
it.deleteNum,
it.totalNum,
it.actualNum,
it.epcUpdate
}).ExecuteCommand();
context.Updateable(details).UpdateColumns(it => new
{
it.updateTime,
it.stockNumber,
it.fixNumber,
it.num,
it.state,
it.fixPrice,
}).ExecuteCommand();
context.CommitTran();
return true;
}
catch (Exception e)
{
return false;
}
}
}
}
}
......@@ -33,5 +33,10 @@ namespace Services
{
return _bussinessInventoryRepository.OrderRollBack(myBIOrder);
}
public Task<bool> UploadInventoryOrder(BussinessInventory main, List<BussinessInventoryDetail> details)
{
return _bussinessInventoryRepository.UploadInventoryOrder(main, details);
}
}
}
......@@ -9,6 +9,7 @@ namespace Services.Interface
{
public interface IBussinessInventoryService : IBaseServices<BussinessInventory>
{
Task<bool> UploadInventoryOrder(BussinessInventory main, List<BussinessInventoryDetail> details);
Task<BussinessInventory>? GenerateInventoryOrder(BussinessInventory myBIOrder);
Task<bool> OrderRollBack(BussinessInventory myBIOrder);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论