Commit 809a0469 authored by 吴春's avatar 吴春
parents bb456408 8e443eba
using Newtonsoft.Json;
using BarcodeLib;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using QRCoder;
......@@ -103,5 +104,48 @@ namespace REBORN.Common.Plugin
}
#endregion
#region 条形码生成
/// <summary>
/// 批量生成二维码图片
/// </summary>
public static bool CreateQRCode(string path, int imgSize, string logoPath, string savePath, System.Drawing.Imaging.ImageFormat imageFormat)
{
try
{
//生成图片
Bitmap image = GetPTQRCode(path, imgSize);
//保存图片
SaveImg(savePath, image, imageFormat);
return true;
}
catch (Exception ex)
{
LogHelper.Write(ex, "Create_CodeImages");
return false;
}
}
public static void CreateTQRCode(string message, string path, System.Drawing.Imaging.ImageFormat imageFormat, int width = 500, int height = 100)
{
Barcode b = new Barcode();
Image img = b.Encode(TYPE.CODE128, message, Color.Black, Color.White, width, height);
MemoryStream stream = new MemoryStream();
img.Save(stream, imageFormat);
Bitmap imgData = (Bitmap)(img);
string DirectoryPath = Path.GetDirectoryName(path);
//保存图片到目录
if (!Directory.Exists(DirectoryPath))
{
//当前目录不存在,则创建
Directory.CreateDirectory(DirectoryPath);
}
//文件名称
imgData.Save(path, imageFormat);
}
#endregion
}
}
......@@ -5,6 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BarcodeLib" Version="2.2.5" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.1" />
......
......@@ -9,6 +9,7 @@ using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using REBORN.Commom.Plugin;
using System.IO;
namespace Property.Module.FixedAssets
{
......@@ -1961,6 +1962,109 @@ namespace Property.Module.FixedAssets
};
}
/// <summary>
/// 获取入库单的标签
/// </summary>
/// <param name="procurementId"></param>
/// <param name="StockInId"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public object GetProcurementStockInLableList(int procurementId, int StockInId, UserInfo userInfo)
{
List<object> RObj = new List<object>();
var pmodel = procurementRepository.GetEntity(procurementId);
int eRPGroupId = userInfo.RB_Group_id;
var siList = supplies_StockInRepository.GetList(new RB_Supplies_StockIn_Extend() { RB_Group_Id = eRPGroupId, ProcurementId = procurementId, Id = StockInId });
if (siList.Any())
{
string siIds = string.Join(",", siList.Where(x => x.StockInState == StockInStatusEnum.StockIn).Select(x => x.Id));
var sidList = supplies_StockInDetailRepository.GetList(new RB_Supplies_StockInDetail_Extend() { RB_Group_Id = eRPGroupId, StockInIdStr = siIds });
List<RB_Supplies_Material_Extend> materialList = new List<RB_Supplies_Material_Extend>();
if (sidList.Any())
{
string matIds = string.Join(",", sidList.Select(x => x.SuppliesId).Distinct());
materialList = supplies_MaterialRepository.GetList(new RB_Supplies_Material_Extend() { RB_Group_Id = eRPGroupId, SuppliesIdStr = matIds });
}
foreach (var item in sidList)
{
var siModel = siList.Where(x => x.Id == item.StockInId).FirstOrDefault();
var materialModel = materialList.Where(x => x.Id == item.SuppliesId).FirstOrDefault();
if (materialModel == null) { continue; }
List<string> spList = new List<string>();
if (!string.IsNullOrEmpty(materialModel.SpecificationName) && materialModel.SpecificationName != "[]")
{
spList = JsonConvert.DeserializeObject<List<string>>(materialModel.SpecificationName);
}
string QRCode = "D-" + (siModel.WarehouseId ?? 0) + "-" + procurementId + "-" + (item.SuppliesId ?? 0) + "-" + (item.StockInId ?? 0);
string TQRCode = "DA" + (siModel.WarehouseId ?? 0) + "A" + procurementId + "A" + (item.SuppliesId ?? 0) + "A" + (item.StockInId ?? 0);
#region 生成二维码 + 条形码
string QRName = "QR-" + DateTime.Now.ToString("yyyyMMdd") + "-" + procurementId + "-" + (item.SuppliesId ?? 0) + ".jpg";
string TQRName = "TQR-" + DateTime.Now.ToString("yyyyMMdd") + "-" + procurementId + "-" + (item.SuppliesId ?? 0) + ".jpg";
string basepath = AppContext.BaseDirectory;
string QRPath = basepath + "\\upfile\\qrcode\\" + QRName;
string QRImage = "/upfile/qrcode/" + QRName;
string TQRPath = basepath + "\\upfile\\qrcode\\" + TQRName;
string TQRImage = "/upfile/qrcode/" + TQRName;
//验证文件是否存在, 存在的话就不用生成了
if (!File.Exists(QRPath))
{
QRCodeHelper.CreateQRCode(QRCode, 5, "", QRPath, System.Drawing.Imaging.ImageFormat.Jpeg);
}
if (!File.Exists(TQRPath))
{
int width = 340;
if (TQRCode.Length > 30)
{
width = 370;
}
QRCodeHelper.CreateTQRCode(TQRCode, TQRPath, System.Drawing.Imaging.ImageFormat.Jpeg, width, 50);
}
#endregion
var empModel = CacheManager.User.UserReidsCache.GetEmployee(item.CreateBy);
for (int i = 0; i < (item.Number ?? 0); i++)
{
RObj.Add(new
{
materialModel.GoodsId,
GoodsName = materialModel.Name,
SpecificationList = spList,
CreateDate = item.CreateDate.HasValue ? item.CreateDate.Value.ToString("yyyy-MM-dd") : "",
EmName = empModel?.EmName ?? "",
siModel.WareHouseName,
CostMoney = item.UnitPrice,
QRImage,
TQRImage,
TQRCode
});
}
}
}
return RObj;
}
/// <summary>
/// 获取采购入库批次列表
/// </summary>
/// <param name="procurementId"></param>
/// <param name="userInfo"></param>
/// <returns></returns>
public object GetProcurementSotckInBatchList(int procurementId, UserInfo userInfo)
{
List<object> RObj = new List<object>();
var siList = supplies_StockInRepository.GetList(new RB_Supplies_StockIn_Extend() { RB_Group_Id = userInfo.RB_Group_id, ProcurementId = procurementId });
siList = siList.Where(x => x.StockInState == StockInStatusEnum.StockIn).ToList();
return siList.Select(x => new
{
StockInId = x.Id,
x.StockInNum
});
}
#endregion
}
}
......@@ -1506,6 +1506,48 @@ namespace Property.WebApi.Controllers.User
});
}
/// <summary>
/// 获取采购单 入库批次
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetProcurementSotckInBatchList()
{
var requestParm = GetRequestParm();
UserInfo userInfo = CacheManager.User.UserReidsCache.GetUserLoginInfo(requestParm.uid);
JObject parms = JObject.Parse(requestParm.msg.ToString());
int ProcurementId = parms.GetInt("ProcurementId", 0);
if (ProcurementId <= 0)
{
return ApiResult.ParamIsNull("请传递参数");
}
var list = suppliesModule.GetProcurementSotckInBatchList(ProcurementId, userInfo);
return ApiResult.Success("", list);
}
/// <summary>
/// 获取采购入库 的标签
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetProcurementStockInLableList()
{
var requestParm = GetRequestParm();
UserInfo userInfo = CacheManager.User.UserReidsCache.GetUserLoginInfo(requestParm.uid);
JObject parms = JObject.Parse(requestParm.msg.ToString());
int ProcurementId = parms.GetInt("ProcurementId", 0);
int StockInId = parms.GetInt("StockInId", 0);
if (ProcurementId <= 0)
{
return ApiResult.ParamIsNull("请传递参数");
}
var list = suppliesModule.GetProcurementStockInLableList(ProcurementId, StockInId, userInfo);
return ApiResult.Success("", list);
}
#endregion
#region 根据二维码标识 获取商品信息
......
......@@ -53,6 +53,8 @@ namespace Property.WebApi
"http://www.test.com:8080",
"http://www.test.com:8081",
"http://www.test.com:8082",
"http://localhost:8080",
"http://localhost:8081",
"http://testzcyx.oytour.com:8080",
"http://testzcyx.oytour.com:8081",
"http://testzcyx.oytour.com",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment