优化商品核价读取速度,优化jit开通无人值守参数设置,优化产品数据库数据直传批量设置商品

This commit is contained in:
wule_5900x committed 2025-11-20 20:56:56 +08:00
1 parent 6865064eca
commit 55d4a27d90
4 files changed
+359 -155

No files matched your search

+211 -40
View File
@@ -50,8 +50,17 @@ namespace TemuKJD.KJDForms.ProductForms
/// 期望到货区域列表
/// </summary>
public List<SkcReceiveAreaPickOutInfo> lstReceiveArea = new List<SkcReceiveAreaPickOutInfo>();
/// <summary>
/// 界面参数配置
/// </summary>
SetJitConfig setJitConfig = null;
/// <summary>
/// jit开通参数配置
/// </summary>
List<OpenJitParams> lstOpenJitParams = null;
public TemuJitForm()
{
InitializeComponent();
@@ -97,6 +106,11 @@ namespace TemuKJD.KJDForms.ProductForms
this.txtSpuId.TextChanged += Txt_TextChanged;
this.txtExtCode.TextChanged += Txt_TextChanged;
this.chkSearchTime.CheckedChanged += Txt_TextChanged;
// 读取货号开通jit参数
lstOpenJitParams = NaiBa.Util.Helper.ConfigHelper.LoadConfig<List<OpenJitParams>>("open_jit_params");
if (lstOpenJitParams == null)
lstOpenJitParams = new List<OpenJitParams>();
}
private void Txt_TextChanged(object sender, EventArgs e)
@@ -789,7 +803,11 @@ namespace TemuKJD.KJDForms.ProductForms
this.dgvExtCode.Rows.Clear();
foreach (var ext in extCodeLst)
{
this.dgvExtCode.Rows.Add(false, ext);
this.dgvExtCode.Rows.Add(
false,
ext,
lstOpenJitParams.Any(p => p.ExtCode == ext) ? "查看" : "未设置"
);
}
}));
}, cancellationTokenSource.Token);
@@ -1330,31 +1348,10 @@ Content-Disposition: form-data; name=""upload_sign""
BaseMsgForm.ShowError("请查询并选择商品!");
return;
}
var minPriceFen = (txtBatchPriceMin.Text.Trim(' ', '¥').ParseToDecimal() * 100).ParseToInt();
var maxPriceFen = (txtBatchPriceMax.Text.Trim(' ', '¥').ParseToDecimal() * 100).ParseToInt();
if (chkBatchPrice.Checked && (minPriceFen < 500 || maxPriceFen < 500 || maxPriceFen < minPriceFen))
string checkJitParamRst = CheckJitParam();
if (!string.IsNullOrEmpty(checkJitParamRst))
{
BaseMsgForm.ShowError("请合理设置价格!至少为 5 且最大值不能小于最小值!");
return;
}
var identifyCode = txtBatchIdentifyCode.Text.Trim();
if (chkBatchIdentifyCode.Checked && identifyCode.IsNullOrEmpty())
{
BaseMsgForm.ShowError("请填写识别码!");
return;
}
if (chkBatchRealPicture.Checked && pbRealPicture.Tag.ParseToString().IsNullOrEmpty())
{
BaseMsgForm.ShowError("请选择实拍图!");
return;
}
if (chkBatchStock.Checked && txtBatchStock.Text.Trim().ParseToInt() < 1)
{
BaseMsgForm.ShowError("请设置合理库存!大于 0 !");
BaseMsgForm.ShowError(checkJitParamRst);
return;
}
@@ -1376,6 +1373,39 @@ Content-Disposition: form-data; name=""upload_sign""
}, cancellationTokenSource.Token);
}
/// <summary>
/// 检测开通Jit配置是否合理
/// </summary>
/// <returns></returns>
string CheckJitParam()
{
var minPriceFen = (txtBatchPriceMin.Text.Trim(' ', '¥').ParseToDecimal() * 100).ParseToInt();
var maxPriceFen = (txtBatchPriceMax.Text.Trim(' ', '¥').ParseToDecimal() * 100).ParseToInt();
if (chkBatchPrice.Checked && (minPriceFen < 500 || maxPriceFen < 500 || maxPriceFen < minPriceFen))
{
return "请合理设置价格!至少为 5 且最大值不能小于最小值!";
}
var identifyCode = txtBatchIdentifyCode.Text.Trim();
if (chkBatchIdentifyCode.Checked && identifyCode.IsNullOrEmpty())
{
return "请填写识别码!";
}
var realPicture = pbBatchRealPicture.Tag.ParseToString();
if (chkBatchRealPicture.Checked && realPicture.IsNullOrEmpty())
{
return "请选择实拍图!";
}
var stock = txtBatchStock.Text.Trim().ParseToInt();
if (chkBatchStock.Checked && stock < 1)
{
return "请设置合理库存!大于 0 !";
}
return "";
}
void AutoJit(int type = 1)
{
//var batchExtCodeLst = txtBatchExtCode.Text.Trim().Split(new string[] { ",", " " }, StringSplitOptions.RemoveEmptyEntries);
@@ -1393,14 +1423,31 @@ Content-Disposition: form-data; name=""upload_sign""
// BaseMsgForm.ShowError("请选择商品!");
// return;
//}
var minPriceFen = (txtBatchPriceMin.Text.Trim(' ', '¥').ParseToDecimal() * 100).ParseToInt();
var maxPriceFen = (txtBatchPriceMax.Text.Trim(' ', '¥').ParseToDecimal() * 100).ParseToInt();
var dgvRows = this.dgvOpenJit.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colCheck"].Value.ParseToBool() == true).ToList();
var dgvRows = this.dgvOpenJit.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colCheck"].Value.ParseToBool() == true).ToList();
foreach (var dgvRow in dgvRows)
{
if (cancellationTokenSource.IsCancellationRequested)
break;
var minPriceFen = (txtBatchPriceMin.Text.Trim(' ', '¥').ParseToDecimal() * 100).ParseToInt();
var maxPriceFen = (txtBatchPriceMax.Text.Trim(' ', '¥').ParseToDecimal() * 100).ParseToInt();
var identifyCode = txtBatchIdentifyCode.Text.Trim();
var realPicture = pbBatchRealPicture.Tag.ParseToString();
var stock = txtBatchStock.Text.Trim().ParseToInt();
// 如果货号存在Jit开通配置,按货号指定配置开通
var extCode = dgvRow.Cells["colExtCode"].Value.ParseToString();
var extCodeOpenJitParams = lstOpenJitParams.FirstOrDefault(p => p.ExtCode == extCode);
if (extCodeOpenJitParams != null)
{
minPriceFen = (extCodeOpenJitParams.PriceMin * 100).ParseToInt();
maxPriceFen = (extCodeOpenJitParams.PriceMax * 100).ParseToInt();
identifyCode = extCodeOpenJitParams.IdentifyCode;
realPicture = extCodeOpenJitParams.RealPicture;
stock = extCodeOpenJitParams.Stock;
}
string orderId = dgvRow.Cells["colOrderId"].Value.ParseToString();
string prodId = dgvRow.Cells["colProductId"].Value.ParseToString();
string skcId = dgvRow.Cells["colProdSkc"].Value.ParseToString();
@@ -1449,6 +1496,8 @@ Content-Disposition: form-data; name=""upload_sign""
{
Thread.Sleep(100);
}
if (!changePriceForm.IsAdjustPrice && string.IsNullOrEmpty(changePriceForm.ErrMsg))
changePriceForm.ErrMsg = "操作超时";
// 显示调价结果
this.UpdatePriceChange(changePriceForm.IsAdjustPrice, changePriceForm.ErrMsg, product);
Thread.Sleep(500);
@@ -1475,7 +1524,7 @@ Content-Disposition: form-data; name=""upload_sign""
MainForm.instance.Controls.Add(complianceForm);
complianceForm.SendToBack();
complianceForm.Show();
complianceForm.txtCode.Text = this.txtBatchIdentifyCode.Text;
complianceForm.txtCode.Text = identifyCode;
}));
Thread.Sleep(200);
// 成功、失败或超时后继续
@@ -1483,8 +1532,10 @@ Content-Disposition: form-data; name=""upload_sign""
{
Thread.Sleep(100);
}
if (!complianceForm.IsEditComplianceSuccess && string.IsNullOrEmpty(complianceForm.ErrMsg))
complianceForm.ErrMsg = "操作超时";
var rows = dgvOpenJit.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colProductId"].Value.ParseToString() == prodId).ToList();
if (complianceForm?.IsEditComplianceSuccess == true)
if (complianceForm.IsEditComplianceSuccess == true)
{
foreach (var row in rows)
{
@@ -1511,7 +1562,7 @@ Content-Disposition: form-data; name=""upload_sign""
// ----------------------------------------------------------------------------------
if (chkBatchRealPicture.Checked && type == 1 && 1 == 1)
{
var uploadRst = UploadRealPicture(shop, pbRealPicture.Tag.ParseToString(), realPicInfo, dgvRow.Cells["colMsg"]);
var uploadRst = UploadRealPicture(shop, realPicture, realPicInfo, dgvRow.Cells["colMsg"]);
if (uploadRst)
{
var rows = dgvOpenJit.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colProductId"].Value.ParseToString() == prodId).ToList();
@@ -1573,7 +1624,7 @@ Content-Disposition: form-data; name=""upload_sign""
Invoke(new Action(() =>
{
stockForm = new ChangeStockForm(shop, product, txtBatchStock.Text.ParseToInt());
stockForm = new ChangeStockForm(shop, product, stock);
stockForm.IsAuto = true;
stockForm.TopLevel = false;
stockForm.Left = 10;
@@ -1588,6 +1639,8 @@ Content-Disposition: form-data; name=""upload_sign""
{
Thread.Sleep(100);
}
if (!stockForm.IsEditSuccess && string.IsNullOrEmpty(stockForm.ErrMsg))
stockForm.ErrMsg = "操作超时";
var rows = dgvOpenJit.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colProductId"].Value.ParseToString() == prodId).ToList();
if (stockForm.IsEditSuccess)
{
@@ -1820,8 +1873,8 @@ Content-Disposition: form-data; name=""upload_sign""
image.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] imageBytes = memoryStream.ToArray();
}
this.pbRealPicture.Tag = fileFullName;
this.pbRealPicture.Image = image;
this.pbBatchRealPicture.Tag = fileFullName;
this.pbBatchRealPicture.Image = image;
}
catch (Exception ex)
{
@@ -1857,12 +1910,61 @@ Content-Disposition: form-data; name=""upload_sign""
if (e.ColumnIndex < 0 || e.RowIndex < 0)
return;
dgvExtCode.Rows[e.RowIndex].Cells["colSelectExtCode"].Value = !dgvExtCode.Rows[e.RowIndex].Cells["colSelectExtCode"].Value.ParseToBool();
string headerText = dgvExtCode.Columns[e.ColumnIndex].HeaderText;
var row = dgvExtCode.Rows[e.RowIndex];
switch (headerText)
{
case "":
case "选":
case "货号":
row.Cells["colSelectExtCode"].Value = !row.Cells["colSelectExtCode"].Value.ParseToBool();
lstFilterExtCode = dgvExtCode.Rows.Cast<DataGridViewRow>()
.Where(r => r.Cells["colSelectExtCode"].Value.ParseToBool() == true)
.Select(r => r.Cells["colFilterExtCode"].Value.ParseToString()).Distinct().ToList();
FilterRows();
break;
case "JIT配置":
if (row.Cells[e.ColumnIndex].Value.ParseToString() == "查看")
{
var extCode = row.Cells["colFilterExtCode"].Value.ParseToString();
var jitParam = lstOpenJitParams.FirstOrDefault(p => p.ExtCode == extCode);
if (jitParam == null)
{
BaseMsgForm.ShowError("配置已删除");
}
else
{
var displayRst = DisplayOpenJitParams(jitParam);
if (!string.IsNullOrEmpty(displayRst))
BaseMsgForm.ShowError(displayRst);
}
}
break;
}
}
lstFilterExtCode = dgvExtCode.Rows.Cast<DataGridViewRow>()
.Where(r => r.Cells["colSelectExtCode"].Value.ParseToBool() == true)
.Select(r => r.Cells["colFilterExtCode"].Value.ParseToString()).Distinct().ToList();
FilterRows();
string DisplayOpenJitParams(OpenJitParams jitParam)
{
this.txtBatchPriceMin.Text = jitParam.PriceMin.ToString();
this.txtBatchPriceMax.Text = jitParam.PriceMax.ToString();
this.txtBatchIdentifyCode.Text = jitParam.IdentifyCode;
this.txtBatchStock.Text = jitParam.Stock.ToString();
try
{
Image image = Image.FromFile(jitParam.RealPicture);
using (MemoryStream memoryStream = new MemoryStream())
{
image.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] imageBytes = memoryStream.ToArray();
}
this.pbBatchRealPicture.Tag = jitParam.RealPicture;
this.pbBatchRealPicture.Image = image;
}
catch (Exception ex)
{
return ex.Message;
}
return "";
}
void FilterRows()
@@ -2169,8 +2271,74 @@ Content-Disposition: form-data; name=""upload_sign""
{
FilterRows();
}
private void btnSaveExtCodeJitConfig_Click(object sender, EventArgs e)
{
var rows = this.dgvExtCode.Rows.Cast<DataGridViewRow>()
.Where(r => r.Cells["colSelectExtCode"].Value.ParseToBool() == true).ToList();
var extCodeLst = rows.Select(r => r.Cells["colFilterExtCode"].Value.ParseToString()).Distinct().ToList();
if (extCodeLst.Count == 0)
{
BaseMsgForm.ShowError("请查询商品后在左边列表选择货号!");
return;
}
string checkJitParamRst = CheckJitParam();
if (!string.IsNullOrEmpty(checkJitParamRst))
{
BaseMsgForm.ShowError(checkJitParamRst);
return;
}
foreach (var extCode in extCodeLst)
{
lstOpenJitParams.RemoveAll(p => p.ExtCode == extCode);
var jitParam = new OpenJitParams()
{
ExtCode = extCode,
IdentifyCode = txtBatchIdentifyCode.Text.Trim(),
PriceMax = txtBatchPriceMax.Text.Trim().ParseToDecimal(),
PriceMin = txtBatchPriceMin.Text.Trim().ParseToDecimal(),
RealPicture = pbBatchRealPicture.Tag.ParseToString(),
Stock = txtBatchStock.Text.Trim().ParseToInt(),
};
lstOpenJitParams.Add(jitParam);
}
NaiBa.Util.Helper.ConfigHelper.SaveConfig("open_jit_params", lstOpenJitParams);
BaseMsgForm.ShowInfo("选中货号的JIT配置已保存!");
foreach (var row in rows)
{
row.Cells["colJitConfig"].Value = "查看";
}
}
private void btnRestoreJitParams_Click(object sender, EventArgs e)
{
var rows = this.dgvExtCode.Rows.Cast<DataGridViewRow>()
.Where(r => r.Cells["colSelectExtCode"].Value.ParseToBool() == true).ToList();
var extCodeLst = rows.Select(r => r.Cells["colFilterExtCode"].Value.ParseToString()).Distinct().ToList();
if (extCodeLst.Count == 0)
{
BaseMsgForm.ShowError("请查询商品后在左边列表选择货号!");
return;
}
foreach (var extCode in extCodeLst)
{
lstOpenJitParams.RemoveAll(p => p.ExtCode == extCode);
}
NaiBa.Util.Helper.ConfigHelper.SaveConfig("open_jit_params", lstOpenJitParams);
BaseMsgForm.ShowInfo("选中货号的JIT配置已重置!");
foreach (var row in rows)
{
row.Cells["colJitConfig"].Value = "未设置";
}
}
}
// jit操作查询相关设置
public class SetJitConfig
{
public string SearchShopId { get; set; } = "";
@@ -2182,7 +2350,10 @@ Content-Disposition: form-data; name=""upload_sign""
public bool SearchDuration { get; set; } = true;
}
public class OpenJitConfig
/// <summary>
/// 开开通jit配置参数
/// </summary>
public class OpenJitParams
{
public string ExtCode { get; set; }
public decimal PriceMin { get; set; }