Commit 32313da9 authored by 吴春's avatar 吴春
parents 23be6fec 5ef083c5
......@@ -15,6 +15,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="BarcodeLib" Version="2.2.5" />
<PackageReference Include="CoreHtmlToImage" Version="1.0.6" />
<PackageReference Include="LumenWorks.Framework.IO.Core" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
......@@ -23,6 +24,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NPOI" Version="2.4.1" />
<PackageReference Include="QRCoder" Version="1.3.9" />
<PackageReference Include="StackExchange.Redis" Version="2.0.601" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.6.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.7.1" />
......
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using QRCoder;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using BarcodeLib;
namespace Mall.Common.Plugin
{
/// <summary>
/// 二维码和条形码
/// </summary>
public static class QRCodeHelper
{
/// <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;
}
}
/// <summary>
/// 保存图片
/// </summary>
/// <param name="strPath">保存路径</param>
/// <param name="imgData">图片</param>
/// <param name="image">图片格式</param>
public static void SaveImg(string strPath, Bitmap imgData, System.Drawing.Imaging.ImageFormat image)
{
string DirectoryPath = Path.GetDirectoryName(strPath);
//保存图片到目录
if (!Directory.Exists(DirectoryPath))
{
//当前目录不存在,则创建
Directory.CreateDirectory(DirectoryPath);
}
//文件名称
imgData.Save(strPath, image);
}
#region 普通二维码
/// <summary>
///
/// </summary>
/// <param name="url">存储内容</param>
/// <param name="pixel">像素大小</param>
/// <returns></returns>
public static Bitmap GetPTQRCode(string url, int pixel)
{
QRCodeGenerator generator = new QRCodeGenerator();
QRCodeData codeData = generator.CreateQrCode(url, QRCodeGenerator.ECCLevel.M, true);
QRCoder.QRCode qrcode = new QRCoder.QRCode(codeData);
Bitmap qrImage = qrcode.GetGraphic(pixel, Color.Black, Color.White, true);
return qrImage;
}
#endregion
#region logo的二维码
/// <summary>
///
/// </summary>
/// <param name="url">存储内容</param>
/// <param name="pixel">像素大小</param>
/// <returns></returns>
public static Bitmap GetLogoQRCode(string url, string logoPath, int pixel)
{
QRCodeGenerator generator = new QRCodeGenerator();
QRCodeData codeData = generator.CreateQrCode(url, QRCodeGenerator.ECCLevel.M, true);
QRCoder.QRCode qrcode = new QRCoder.QRCode(codeData);
Bitmap icon = new Bitmap(logoPath);
Bitmap qrImage = qrcode.GetGraphic(pixel, Color.Black, Color.White, icon, 10, 3, true);
#region 参数介绍
//GetGraphic方法参数介绍
//pixelsPerModule //生成二维码图片的像素大小 ,我这里设置的是5
//darkColor //暗色 一般设置为Color.Black 黑色
//lightColor //亮色 一般设置为Color.White 白色
//icon //二维码 水印图标 例如:Bitmap icon = new Bitmap(context.Server.MapPath("~/images/zs.png")); 默认为NULL ,加上这个二维码中间会显示一个图标
//iconSizePercent //水印图标的大小比例 ,可根据自己的喜好设置
//iconBorderWidth // 水印图标的边框
//drawQuietZones //静止区,位于二维码某一边的空白边界,用来阻止读者获取与正在浏览的二维码无关的信息 即是否绘画二维码的空白边框区域 默认为true
#endregion
return qrImage;
}
#endregion
#region 条形码生成
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
}
}
using System;
using System.Collections.Generic;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
......@@ -98,6 +100,10 @@ namespace Mall.Module.Property
/// 入库明细
/// </summary>
private readonly RB_Supplies_StockInDetailRepository supplies_StockInDetailRepository = new RB_Supplies_StockInDetailRepository();
/// <summary>
/// erp用户列表
/// </summary>
private readonly Rb_employeeRepository erpemployeeRepository = new Rb_employeeRepository();
......@@ -570,9 +576,7 @@ namespace Mall.Module.Property
//增加采购单已入库数量
foreach (var item in demodel.DetailList)
{
var dModel = DetailList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == item.SpecificationKey).FirstOrDefault();
dModel.StockInNum = (dModel.StockInNum ?? 0) + item.InStockNum;
var dModel = DetailList.Where(x => x.GoodsId == item.GoodsId && x.SpecificationKey == item.SpecificationKey).FirstOrDefault();
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Procurement_Detail_Extend.StockInNum),dModel.StockInNum}
};
......@@ -630,6 +634,18 @@ namespace Mall.Module.Property
return "资产入库单生成失败";
}
#endregion
property_LogRepository.Insert(new Model.Entity.Property.RB_Property_Log()
{
Type = 3,
Content = "采购单入库",
CreateBy = empId,
CreateDate = DateTime.Now,
Id = 0,
MallBaseId = mallBaseId,
SourceId = demodel.Id,
TenantId = tenantId
});
}
procurementRepository.DBSession.Commit();
return "";
......@@ -782,6 +798,103 @@ namespace Mall.Module.Property
}
}
/// <summary>
/// 获取入库单的标签
/// </summary>
/// <param name="procurementId"></param>
/// <param name="eRPEmpId"></param>
/// <param name="eRPGroupId"></param>
/// <param name="empId"></param>
/// <returns></returns>
public object GetProcurementStockInLableList(int procurementId,int StockInId, int eRPEmpId, int eRPGroupId, int empId)
{
List<object> RObj = new List<object>();
var pmodel = procurementRepository.GetEntity(procurementId);
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 == 1).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>();
List<Model.Extend.Property.RB_Employee_Extend> empList = new List<Model.Extend.Property.RB_Employee_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 });
string erpEmpIds = string.Join(",", sidList.Select(x => x.CreateBy ?? 0).Distinct());
empList = erpemployeeRepository.GetList(new Model.Extend.Property.RB_Employee_Extend() { RB_Group_id = eRPGroupId, EmployeeIds = erpEmpIds });
}
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);
}
var empModel = empList.Where(x => x.EmployeeId == item.CreateBy).FirstOrDefault();
string QRCode = "D-" + (siModel.WarehouseId ?? 0) + "-" + procurementId + "-" + (item.SuppliesId ?? 0);
string TQRCode = "DA" + (siModel.WarehouseId ?? 0) + "A" + procurementId + "A" + (item.SuppliesId ?? 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\\code\\" + QRName;
string QRImage = "/upfile/code/" + QRName;
string TQRPath = basepath + "\\upfile\\code\\" + TQRName;
string TQRImage = "/upfile/code/" + TQRName;
//验证文件是否存在, 存在的话就不用生成了
if (!File.Exists(QRPath)) {
QRCodeHelper.CreateQRCode(QRCode, 5, "", QRPath, ImageFormat.Jpeg);
}
if (!File.Exists(TQRPath)) {
QRCodeHelper.CreateTQRCode(TQRCode, TQRPath, ImageFormat.Jpeg, 400, 80);
}
#endregion
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="eRPEmpId"></param>
/// <param name="eRPGroupId"></param>
/// <param name="empId"></param>
/// <returns></returns>
public object GetProcurementSotckInBatchList(int procurementId, int eRPEmpId, int eRPGroupId, int empId)
{
List<object> RObj = new List<object>();
var siList = supplies_StockInRepository.GetList(new RB_Supplies_StockIn_Extend() { RB_Group_Id = eRPGroupId, ProcurementId = procurementId });
siList = siList.Where(x => x.StockInState == 1).ToList();
return siList.Select(x => new
{
StockInId = x.Id,
x.StockInNum
});
}
#endregion
#region 获取资产物料列表
......
......@@ -2087,6 +2087,7 @@ namespace Mall.Module.User
var dmodel = distributor_InfoRepository.GetList(new RB_Distributor_Info_Extend() { UserId = remodel.UserId, TenantId = Convert.ToInt32(uid), MallBaseId = mallBaseId }).FirstOrDefault();
if (dmodel != null)
{
#region 回滚提现金额
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Distributor_Info.CommissionWithdrawal), (dmodel.CommissionWithdrawal ?? 0) + (remodel.AppliedMoney??0)}
};
......@@ -2098,6 +2099,7 @@ namespace Mall.Module.User
}
};
distributor_InfoRepository.Update(keyValues1, wheres1);
#endregion
#region 回滚佣金已提现字段
try
......
......@@ -36,16 +36,16 @@ namespace Mall.Repository.Property
{
where += " and ss." + nameof(RB_Supplies_StockIn_Extend.StockInNum) + " like '%" + dmodel.StockInNum + "%'";
}
if (!string.IsNullOrWhiteSpace(dmodel.SuppliesNum.Trim()))
if (!string.IsNullOrWhiteSpace(dmodel.SuppliesNum))
{
where += " and sm." + nameof(RB_Supplies_StockIn_Extend.SuppliesNum) + " like '%" + dmodel.SuppliesNum.Trim() + "%'";
}
if (!string.IsNullOrWhiteSpace(dmodel.SuppliesName.Trim()))
if (!string.IsNullOrWhiteSpace(dmodel.SuppliesName))
{
where += " and sm." + nameof(RB_Supplies_Material.Name) + " like '%" + dmodel.SuppliesName.Trim() + "%'";
}
if (!string.IsNullOrWhiteSpace(dmodel.SupplierName.Trim()))
if (!string.IsNullOrWhiteSpace(dmodel.SupplierName))
{
where += " and ss." + nameof(RB_Supplies_StockIn_Extend.SupplierName) + " like '%" + dmodel.SupplierName.Trim() + "%'";
}
......@@ -63,6 +63,52 @@ left join rb_supplies_material sm on ssd.SuppliesId=sm.Id
}
/// <summary>
/// 获取耗材分页数据
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Supplies_StockIn_Extend> GetList(RB_Supplies_StockIn_Extend dmodel)
{
string where = " where 1=1 ";
where += string.Format(" AND ss.{0}={1}", nameof(RB_Supplies_StockIn_Extend.Status), 0);
where += $@" and ss.RB_Group_Id={dmodel.RB_Group_Id}";
if (!string.IsNullOrWhiteSpace(dmodel.StartTime))
{
where += $@" and ss.{nameof(RB_Supplies_StockIn_Extend.StockInDate)} >='{dmodel.StartTime}'";
}
if (!string.IsNullOrWhiteSpace(dmodel.EndTime))
{
where += $@" and ss.{nameof(RB_Supplies_StockIn_Extend.StockInDate)} <='{dmodel.EndTime + " 23:59:59"}'";
}
if (!string.IsNullOrWhiteSpace(dmodel.StockInNum))
{
where += " and ss." + nameof(RB_Supplies_StockIn_Extend.StockInNum) + " like '%" + dmodel.StockInNum + "%'";
}
if (!string.IsNullOrWhiteSpace(dmodel.SupplierName))
{
where += " and ss." + nameof(RB_Supplies_StockIn_Extend.SupplierName) + " like '%" + dmodel.SupplierName.Trim() + "%'";
}
if (dmodel.Id > 0)
{
where += " and ss." + nameof(RB_Supplies_StockIn_Extend.Id) + "=" + dmodel.Id;
}
if (dmodel.WarehouseId > 0)
{
where += " and ss." + nameof(RB_Supplies_StockIn_Extend.WarehouseId) + "=" + dmodel.WarehouseId;
}
if (dmodel.ProcurementId > 0)
{
where += " and ss." + nameof(RB_Supplies_StockIn_Extend.ProcurementId) + "=" + dmodel.ProcurementId;
}
string sql = $@" select ss.*,sw.Name as WareHouseName from RB_Supplies_StockIn ss
left join rb_supplies_warehouse sw on ss.WarehouseId=sw.Id
{where} order by ss.Id desc";
return Get<RB_Supplies_StockIn_Extend>(sql).ToList();
}
/// <summary>
/// 获取耗材入库出库情况
/// </summary>
......
......@@ -255,6 +255,11 @@ namespace Mall.WebApi.Controllers.MallBase
{
return ApiResult.ParamIsNull("请选择商品");
}
demodel.DetailList = demodel.DetailList.Where(x => x.InStockNum > 0).ToList();
if (!demodel.DetailList.Any())
{
return ApiResult.ParamIsNull("请输入商品入库数量");
}
foreach (var item in demodel.DetailList)
{
if (item.GoodsId <= 0)
......@@ -277,6 +282,69 @@ namespace Mall.WebApi.Controllers.MallBase
return ApiResult.Failed(msg);
}
}
/// <summary>
/// 获取采购单 入库批次
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetProcurementSotckInBatchList()
{
var requestParm = RequestParm;
if (requestParm.ERPEmpId <= 0)
{
return ApiResult.ParamIsNull("请传递参数");
}
if (requestParm.ERPGroupId <= 0)
{
return ApiResult.ParamIsNull("请传递参数");
}
if (requestParm.EmpId <= 0)
{
return ApiResult.ParamIsNull("请传递参数");
}
JObject parms = JObject.Parse(requestParm.msg.ToString());
int ProcurementId = parms.GetInt("ProcurementId", 0);
if (ProcurementId <= 0)
{
return ApiResult.ParamIsNull("请传递参数");
}
var list = propertyModule.GetProcurementSotckInBatchList(ProcurementId, requestParm.ERPEmpId, requestParm.ERPGroupId, requestParm.EmpId);
return ApiResult.Success("", list);
}
/// <summary>
/// 获取采购入库 的标签
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetProcurementStockInLableList() {
var requestParm = RequestParm;
if (requestParm.ERPEmpId <= 0)
{
return ApiResult.ParamIsNull("请传递参数");
}
if (requestParm.ERPGroupId <= 0)
{
return ApiResult.ParamIsNull("请传递参数");
}
if (requestParm.EmpId <= 0)
{
return ApiResult.ParamIsNull("请传递参数");
}
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 = propertyModule.GetProcurementStockInLableList(ProcurementId, StockInId, requestParm.ERPEmpId, requestParm.ERPGroupId, requestParm.EmpId);
return ApiResult.Success("", list);
}
#endregion
#region 同步商品
......
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