From 716435e1177c454a9cd652fae35769a0ef9a3b7c Mon Sep 17 00:00:00 2001
From: 南骏 池 <chiffly@163.com>
Date: 星期四, 13 二月 2025 10:10:39 +0800
Subject: [PATCH] 1.成品入库(初步) 2.仓库入参新增字段备注 3.采购入库,其他入库主表新增仓库id 4.其他出库优化
---
entity/MesInvItemIns.cs | 15 +++
service/Warehouse/MesCprkManager.cs | 83 ++++++++++++++++++++
service/Warehouse/MesItemQtManager.cs | 17 ++--
entity/MesInvItemInCItems.cs | 6 +
Dto/service/WarehouseQuery.cs | 2
service/Warehouse/MesInvItemInCDetailsManager.cs | 2
Controllers/Warehouse/MesCprkController.cs | 73 ++++++++++++++++++
service/Warehouse/MesItemQtrkManager.cs | 30 +++++--
8 files changed, 208 insertions(+), 20 deletions(-)
diff --git a/Controllers/Warehouse/MesCprkController.cs b/Controllers/Warehouse/MesCprkController.cs
new file mode 100644
index 0000000..a22d2aa
--- /dev/null
+++ b/Controllers/Warehouse/MesCprkController.cs
@@ -0,0 +1,73 @@
+锘縰sing System.Dynamic;
+using Microsoft.AspNetCore.Mvc;
+using NewPdaSqlServer.Dto.service;
+using NewPdaSqlServer.entity;
+using NewPdaSqlServer.service.Warehouse;
+using NewPdaSqlServer.util;
+
+namespace NewPdaSqlServer.Controllers.Warehouse;
+
+[ApiController]
+[Route("api/[controller]")]
+public class MesCprkController : ControllerBase
+{
+ private readonly MesCprkManager m = new();
+
+ /// <summary>
+ /// 鑾峰彇鏉$爜淇℃伅鍜岀墿鏂欎俊鎭�
+ /// </summary>
+ /// <returns></returns>
+ [HttpPost("GetBarInfo")]
+ public ResponseResult GetBarInfo(WarehouseQuery unity)
+ {
+ try
+ {
+ dynamic resultInfos = new ExpandoObject();
+ resultInfos.tbBillList = m.GetBarInfo(unity);
+ if(resultInfos.tbBillList == null)
+ {
+ return new ResponseResult
+ {
+ status = -1,
+ message = "姝ゆ潯鐮佷笉瀛樺湪锛侊紒锛�",
+ data = resultInfos
+ };
+ }
+ resultInfos.tbMesItems = m.GetItemNo(resultInfos.tbBillList.ItemId);
+ return new ResponseResult
+ {
+ status = 0,
+ message = "OK",
+ data = resultInfos
+ };
+ }
+ catch (Exception ex)
+ {
+ return ResponseResult.ResponseError(ex);
+ }
+ }
+
+ /// <summary>
+ /// 鑾峰彇鏉$爜淇℃伅鍜岀墿鏂欎俊鎭�
+ /// </summary>
+ /// <returns></returns>
+ [HttpPost("CPRK")]
+ public ResponseResult CPRK(WarehouseQuery unity)
+ {
+ try
+ {
+ dynamic resultInfos = new ExpandoObject();
+ //resultInfos.tbBillList = m.CPRK(unity);
+ return new ResponseResult
+ {
+ status = 0,
+ message = resultInfos.tbBillList,
+ data = resultInfos
+ };
+ }
+ catch (Exception ex)
+ {
+ return ResponseResult.ResponseError(ex);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Dto/service/WarehouseQuery.cs b/Dto/service/WarehouseQuery.cs
index a16ba74..ac13440 100644
--- a/Dto/service/WarehouseQuery.cs
+++ b/Dto/service/WarehouseQuery.cs
@@ -7,6 +7,7 @@
public string? blNo { get; set; } //琛ユ枡鍗曞彿
public string? id { get; set; }
public string? sectionCode { get; set; }
+ //鏉$爜缂栧彿
public string? barcode { get; set; }
public string? userName { get; set; }
public string? billNo { get; set; }
@@ -14,6 +15,7 @@
public DateTime? date { get; set; }
public string? Type { get; set; }
+ //搴撲綅缂栫爜
public string? DepotCode { get; set; }
public string? DepotSectionName { get; set; }
diff --git a/entity/MesInvItemInCItems.cs b/entity/MesInvItemInCItems.cs
index bef4fa1..50b649f 100644
--- a/entity/MesInvItemInCItems.cs
+++ b/entity/MesInvItemInCItems.cs
@@ -164,5 +164,11 @@
[SugarColumn(ColumnName = "ITEM_ID")]
public long? ItemId { get; set; }
+ /// <summary>
+ /// 浠撳簱id
+ /// </summary>
+ [SugarColumn(ColumnName = "depot_id")]
+ public string? DepotId { get; set; }
+
[SugarColumn(ColumnName = "SUPP_ID")] public string? SuppId { get; set; }
}
\ No newline at end of file
diff --git a/entity/MesInvItemIns.cs b/entity/MesInvItemIns.cs
index b1a8dc6..8585581 100644
--- a/entity/MesInvItemIns.cs
+++ b/entity/MesInvItemIns.cs
@@ -106,6 +106,7 @@
public DateTime? CheckDate { get; set; }
/// <summary>
+ /// 鍏ュ簱鍗曞搴旂殑鐢宠鍗曞彿锛堟病鏈夌敵璇锋祦绋嬬殑灏变负绌猴級
/// </summary>
[SugarColumn(ColumnName = "TASK_NO")]
public string? TaskNo { get; set; }
@@ -258,7 +259,7 @@
public string? IqcReleaseNo { get; set; }
/// <summary>
- /// 鍒拌揣鍗曞彿/鍏跺畠鍏ュ簱鍗曞彿
+ /// 鍏ュ簱鍗曠殑鐩稿叧鍗曞彿锛堢敓浜х浉鍏冲瓨 鎸囦护鍗曞彿 -1锛岄噰璐浉鍏崇殑瀛樺埌璐у崟鍙凤級
/// </summary>
[SugarColumn(ColumnName = "CBILL_NO")]
public string? CbillNo { get; set; }
@@ -305,6 +306,18 @@
[SugarColumn(ColumnName = "ReceiveOrgId")]
public string? ReceiveOrgId { get; set; }
+ /// <summary>
+ /// 鍏ュ簱鍗曠殑鐩稿叧鍗曞彿锛堢敓浜х浉鍏冲瓨 鎸囦护鍗曞彿 -1锛岄噰璐浉鍏崇殑瀛樺埌璐у崟鍙凤級
+ /// </summary>
+ [SugarColumn(ColumnName = "work_no")]
+ public string? WorkNo { get; set; }
+
+ /// <summary>
+ /// 鍏ュ簱绫诲埆锛堜簨鍔$被鍨嬪悕绉帮級
+ /// </summary>
+ [SugarColumn(ColumnName = "in_type")]
+ public string? InType { get; set; }
+
//鍦ㄦ暟鎹簱鏌ヨ鏃跺拷鐣ヨ繖涓瓧娈�
[SugarColumn(IsIgnore = true)] public string? DepotName { get; set; }
diff --git a/service/Warehouse/MesCprkManager.cs b/service/Warehouse/MesCprkManager.cs
new file mode 100644
index 0000000..354be65
--- /dev/null
+++ b/service/Warehouse/MesCprkManager.cs
@@ -0,0 +1,83 @@
+锘縰sing System.Data;
+using System.Data.SqlClient;
+using Masuit.Tools;
+using NewPdaSqlServer.DB;
+using NewPdaSqlServer.Dto.service;
+using NewPdaSqlServer.entity;
+using SqlSugar;
+using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
+
+namespace NewPdaSqlServer.service.Warehouse;
+
+public class MesCprkManager : Repository<MesCgthSq>
+{
+ public MesInvItemBarcodes GetBarInfo(WarehouseQuery unity)
+ {
+ return Db.Queryable<MesInvItemBarcodes>()
+ .Where(s => s.ItemBarcode == unity.barcode)
+ .First(); // 杩斿洖绗竴琛屾暟鎹紝濡傛灉娌℃湁鍒欒繑鍥� null
+ }
+
+ public MesItems GetItemNo(decimal strItemId)
+ {
+ return Db.Queryable<MesItems>()
+ .Where(s => s.Id == strItemId)
+ .First();
+ }
+
+ public string CPRK(WarehouseQuery unity)
+ {
+ var _strMsg = "";
+ var _intSum = "";
+ using (var conn = new SqlConnection(DbHelperSQL.strConn))
+ {
+ if (unity.userName.IsNullOrEmpty()) throw new Exception("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖");
+ if (unity.CfNum <= 0) throw new Exception("鎷嗗垎鏁伴噺闇�澶т簬绛変簬0");
+ if (unity.barcode.IsNullOrEmpty()) throw new Exception("鏉$爜涓嶅厑璁镐负绌�");
+
+ using (var cmd = new SqlCommand("[prc_pda_bar_cf]", conn))
+ {
+ try
+ {
+ conn.Open();
+ cmd.CommandType = CommandType.StoredProcedure;
+ SqlParameter[] parameters =
+ {
+ new("@outMsg", SqlDbType.NVarChar, 300),
+ new("@outSum", SqlDbType.NVarChar, 300),
+ new("@barcode_new", SqlDbType.NVarChar, 300),
+ new("@c_user", unity.userName),
+ new("@p_old_barcode", unity.barcode),
+ new("@p_qty", unity.CfNum),
+
+ };
+ parameters[0].Direction = ParameterDirection.Output;
+ parameters[1].Direction = ParameterDirection.Output;
+ parameters[2].Direction = ParameterDirection.Output;
+
+ foreach (var parameter in parameters)
+ cmd.Parameters.Add(parameter);
+ cmd.ExecuteNonQuery();
+ _strMsg = parameters[0].Value.ToString();
+ _intSum = parameters[1].Value.ToString();
+
+ var result = Convert.ToInt32(_intSum);
+ if (result <= 0) throw new Exception(_strMsg);
+
+ return _strMsg;
+
+ //return 0;
+
+ }
+ catch (Exception ex)
+ {
+ throw new Exception(ex.Message);
+ }
+ finally
+ {
+ conn.Close();
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/service/Warehouse/MesInvItemInCDetailsManager.cs b/service/Warehouse/MesInvItemInCDetailsManager.cs
index cf0c551..13296d4 100644
--- a/service/Warehouse/MesInvItemInCDetailsManager.cs
+++ b/service/Warehouse/MesInvItemInCDetailsManager.cs
@@ -126,7 +126,7 @@
UseTransaction(db =>
{
var existingRecord = db.Queryable<MesInvItemIns>()
- .Where(it => it.InsDate.Value.Date == DateTime.Now.Date
+ .Where(it => it.InsDate.Value.ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd")
&& it.Status == 0
&& it.TransctionNo == transactionNo
&& it.BillNo == itemBarcodeDetails.BillNo
diff --git a/service/Warehouse/MesItemQtManager.cs b/service/Warehouse/MesItemQtManager.cs
index 83730c5..a67d156 100644
--- a/service/Warehouse/MesItemQtManager.cs
+++ b/service/Warehouse/MesItemQtManager.cs
@@ -142,9 +142,9 @@
throw new Exception($"鍏朵粬鍑哄簱鐢宠鍗� {p_bill_no} 涓嶅瓨鍦紝璇风‘璁わ紒");
// 妫�鏌ヤ粨搴撴槸鍚︿竴鑷�
- if (mesItemQt.Qt011 != stock.DepotsCode)
+ if (Convert.ToInt32(mesItemQt.Qt008) != stock.DepotId)
throw new Exception(
- $"鎵爜鍑鸿揣浠撳簱{stock.DepotsCode}涓庡叾浠栧嚭搴撶敵璇蜂粨搴搟mesItemQt.Qt011}涓嶄竴鑷达紝璇锋牳瀵癸紒");
+ $"鎵爜鍑鸿揣浠撳簱id{mesItemQt.Qt008}涓庡叾浠栧嚭搴撶敵璇蜂粨搴搟stock.DepotId}涓嶄竴鑷达紝璇锋牳瀵癸紒");
// 鑾峰彇鍑哄簱鍗曟槑缁�
var qtDetail = Db.Queryable<MesItemQtDatall>()
@@ -199,7 +199,7 @@
// 鏌ユ壘褰撳ぉ鏄惁宸插瓨鍦ㄥ嚭搴撳崟
var existingOut = Db.Queryable<MesInvItemOuts>()
- .Where(it => it.PbillNo == p_bill_no
+ .Where(it => it.TaskNo == p_bill_no
// && it.DepotCode == stock.DepotsCode
&& it.DepotId == stock.DepotId
&& it.OutDate.Value.Date.ToString("yyyy-MM-dd") ==
@@ -216,7 +216,7 @@
{
// 鍒涘缓鏂扮殑鍑哄簱鍗�
outId = Guid.NewGuid();
- outNo = BillNo.GetBillNo("INV_OUT_OTHER");
+ outNo = BillNo.GetBillNo("QTCK(鍏朵粬鍑哄簱鍗�)");
var mesItemQt = Db.Queryable<MesItemQt>()
.Where(it => it.Qtck == p_bill_no)
@@ -240,9 +240,9 @@
: null,
OutPart = mesItemQt.Qt012,
FType = 0,
- WorkNo = p_bill_no,
+ //WorkNo = p_bill_no,
OutType = "鍏朵粬鍑哄簱",
- PbillNo = p_bill_no,
+ //PbillNo = p_bill_no,
OutDate = DateTime.Now,
Nflag = 0,
Reason = mesItemQt.Qt010,
@@ -281,7 +281,8 @@
Guid = Guid.NewGuid(),
ItemOutId = outId,
ItemNo = qtDetail.Qd002,
- Quantity = stock.Quantity,
+ Quantity = qtDetail.Qd007,
+ TlQty = stock.Quantity,
CreateBy = c_user,
CreateDate = DateTime.Now,
LastupdateBy = c_user,
@@ -308,7 +309,7 @@
// 鏇存柊宸插瓨鍦ㄧ殑鍑哄簱鐗╂枡璁板綍鏁伴噺
commit += db.Updateable<MesInvItemOutItems>()
.SetColumns(it =>
- it.Quantity == (it.Quantity ?? 0) + stock.Quantity)
+ it.TlQty == (it.TlQty ?? 0) + stock.Quantity)
.Where(it => it.ItemOutId == outId &&
it.ItemId == barcode.ItemId &&
it.QtOutId == qtDetail.Guid)
diff --git a/service/Warehouse/MesItemQtrkManager.cs b/service/Warehouse/MesItemQtrkManager.cs
index 2d13b92..8c75e6d 100644
--- a/service/Warehouse/MesItemQtrkManager.cs
+++ b/service/Warehouse/MesItemQtrkManager.cs
@@ -170,11 +170,14 @@
// 鏌ヨ鏄惁瀛樺湪鏈叆搴撶殑鍏ュ簱鍗�
var existingInv = db.Queryable<MesInvItemIns>()
.Where(x => x.Status == 0
+ && x.InsDate.Value.ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd")
&& x.TransctionNo == transactionNo.ToString()
- && x.CbillNo == p_bill_no
- && x.SuppNo == barcode.SuppNo
+ && x.TaskNo == p_bill_no
+ //&& x.CbillNo == p_bill_no
+ && x.BillTypeId == billTypeId
+ && x.DepotsId == Convert.ToInt64(c_depot_id))
// && x.DepotsCode == c_depot_code)
- && x.DepotsId == c_depot_id)
+ //&& x.SuppNo == barcode.SuppNo)
.First();
var newId = Guid.Empty;
@@ -183,7 +186,7 @@
if (existingInv == null)
{
newId = Guid.NewGuid();
- billNo = BillNo.GetBillNo("INV_IN_OTHER");
+ billNo = BillNo.GetBillNo("QTRK(鍏朵粬鍏ュ簱鍗�)");
barcode.UrgentFlag ??= false;
@@ -204,7 +207,11 @@
CbillNo = p_bill_no,
Fstatus = 0,
Status = 0,
- Reason = qtrk.Qt010
+ Reason = qtrk.Qt010,
+ TaskNo = p_bill_no,
+ DepotsId = Convert.ToInt64(c_depot_id) ,
+ InType = "鍏朵粬鍏ュ簱"
+
}).IgnoreColumns(true).ExecuteCommand();
}
else
@@ -217,8 +224,9 @@
var existingItem = db.Queryable<MesInvItemInCItems>()
.Where(x => x.ItemInId == newId
&& x.ItemId == barcode.ItemId
- && x.WorkNo == barcode.WorkNo
- && x.WorkLine == barcode.WorkLine)
+ && x.DepotId == c_depot_id.ToString()
+ )
+ //&& x.DepotCode =
.First();
if (existingItem == null)
@@ -246,7 +254,8 @@
Remark = barcode.Memo,
EbelnK3id = barcode.EbelnK3id,
LineK3id = barcode.LineK3id,
- ItemId = barcode.ItemId
+ ItemId = barcode.ItemId,
+ DepotId = c_depot_id.ToString()
}).IgnoreColumns(true).ExecuteCommand();
else
// 瀛樺湪鍒欐洿鏂版暟閲�
@@ -274,7 +283,7 @@
LotNo = barcode.LotNo,
SuppId = barcode.SuppId,
SuppNo = barcode.SuppNo,
- DepotId = c_depot_id,
+ DepotId = Convert.ToInt64(c_depot_id),
DepotCode = c_depot_code,
DepotSectionCode = p_section_code,
ItemSname = barcode.ItemSname,
@@ -377,7 +386,8 @@
// 鏇存柊鐢宠鍗曟槑缁嗗凡鍏ュ簱鏁伴噺
res += db.Updateable<MesItemQtrrDetail>()
.SetColumns(x => x.Qd008 == (x.Qd008 ?? 0) + barcode.Quantity)
- .Where(x => x.Guid == barcode.Guid)
+ .Where(x => x.QtrkGuid == qtrk.Guid &&
+ x.ItemId == barcode.ItemId.ToString())
.ExecuteCommand();
// 妫�鏌ユ槸鍚﹀畬鍏ㄥ叆搴撳苟鏇存柊鐘舵��
--
Gitblit v1.9.3