From 87336b96ba0a03cb461a5f5cbd13f4d6dfdae876 Mon Sep 17 00:00:00 2001
From: wbc <2597324127@qq.com>
Date: 星期一, 08 十二月 2025 15:32:46 +0800
Subject: [PATCH] 焕美平板增加通用功能页面,可以使用朋乐的部分pda页面功能(pda存储过程更改,平板同步更新)
---
StandardInterface/MES.Service/service/ZZCXDManager.cs | 100 ++++++++++++++++++++++++++++++++++---------------
1 files changed, 69 insertions(+), 31 deletions(-)
diff --git a/StandardInterface/MES.Service/service/ZZCXDManager.cs b/StandardInterface/MES.Service/service/ZZCXDManager.cs
index ecbfdae..4449457 100644
--- a/StandardInterface/MES.Service/service/ZZCXDManager.cs
+++ b/StandardInterface/MES.Service/service/ZZCXDManager.cs
@@ -12,8 +12,20 @@
{
public bool SaveList(List<ERPZZCXD> list)
{
- var result = list.Select(Save).ToList();
- return result.All(b => b);
+ /*var result = list.Select(Save).ToList();
+ return result.All(b => b);*/
+ foreach (var item in list)
+ {
+ try
+ {
+ Save(item);
+ }
+ catch (Exception ex)
+ {
+ throw new Exception($"鍗曟嵁 {item.Main.bill_no} 鍑洪敊: {ex.Message}", ex);
+ }
+ }
+ return true;
}
public bool Save(ERPZZCXD data)
@@ -44,8 +56,9 @@
var entity = new ZZCX
{
BillNo = dto.bill_no, // 鍗曟嵁缂栫爜
- Erpid = dto.erpid , // ERP 涓昏〃 ID
- DjLx = dto.dj_lx,
+ Erpid = string.IsNullOrEmpty(dto.erpid) ? (decimal?)null : Convert.ToDecimal(dto.erpid),
+ // ERP 涓昏〃 ID
+ DjLx = dto.dj_lx,
KcZz = dto.kc_zz,
SwLx = dto.sw_lx,
// Time = string.IsNullOrEmpty(dto.time) ? (DateTime?)null : DateTime.Parse(dto.time),
@@ -78,27 +91,28 @@
{
var item = new ZZCXA
{
- Erpid = dto.erpid,
- /* BillNo = dto.bill_no,
- DjLx = dto.dj_lx,
- KcZz = dto.kc_zz,
- SwLx = dto.sw_lx,
- // Time = string.IsNullOrEmpty(dto.time) ? (DateTime?)null : DateTime.Parse(dto.time),
- Time = dto.time,
- Bm = dto.bm,
- Cgy = dto.cgy,
- Kcz = dto.kcz,
- DjZt = dto.dj_zt,
- Memo = dto.memo,
- Cphzlx = dto.cphzlx,
- Cphz = dto.cphz,
- Zjhzlx = dto.zjhzlx,
- Zjhz = dto.zjhz,*/
- ItemId = dto.item_id,
+ /* BillNo = dto.bill_no,
+ DjLx = dto.dj_lx,
+ KcZz = dto.kc_zz,
+ SwLx = dto.sw_lx,
+ // Time = string.IsNullOrEmpty(dto.time) ? (DateTime?)null : DateTime.Parse(dto.time),
+ Time = dto.time,
+ Bm = dto.bm,
+ Cgy = dto.cgy,
+ Kcz = dto.kcz,
+ DjZt = dto.dj_zt,
+ Memo = dto.memo,
+ Cphzlx = dto.cphzlx,
+ Cphz = dto.cphz,
+ Zjhzlx = dto.zjhzlx,
+ Zjhz = dto.zjhz,*/
+ Erpid = string.IsNullOrEmpty(dto.erpid) ? (decimal?)null : Convert.ToDecimal(dto.erpid),
+ YdId = string.IsNullOrEmpty(dto.yd_id) ? (decimal?)null : Convert.ToDecimal(dto.yd_id),
+ ItemId = string.IsNullOrEmpty(dto.item_id) ? (decimal?)null : Convert.ToDecimal(dto.item_id),
Qty = string.IsNullOrEmpty(dto.qty) ? (decimal?)null : Convert.ToDecimal(dto.qty),
Unit = dto.unit,
- DepotId = dto.depot_id,
- YdId = mainErpId
+ DepotId = string.IsNullOrEmpty(dto.depot_id) ? (decimal?)null : Convert.ToDecimal(dto.depot_id)
+
};
var existing = Db.Queryable<ZZCXA>().Where(s => s.Erpid == item.Erpid).Single();
@@ -113,17 +127,18 @@
{
var subEntity = new ZZCXB
{
- Eid = subDto.eid,
- ItemId = subDto.item_id,
+ Eid = string.IsNullOrEmpty(subDto.eid) ? (decimal?)null : Convert.ToDecimal(subDto.eid),
+ Erpid = string.IsNullOrEmpty(subDto.erpid) ? (decimal?)null : Convert.ToDecimal(subDto.erpid),
+ YdId = string.IsNullOrEmpty(subDto.yd_id) ? (decimal?)null : Convert.ToDecimal(subDto.yd_id),
+ ItemId = string.IsNullOrEmpty(subDto.item_id) ? (decimal?)null : Convert.ToDecimal(subDto.item_id),
Qty = string.IsNullOrEmpty(subDto.qty) ? (decimal?)null : Convert.ToDecimal(subDto.qty),
Unit = subDto.unit,
- DepotId = subDto.depot_id,
+ DepotId = string.IsNullOrEmpty(subDto.depot_id) ? (decimal?)null : Convert.ToDecimal(subDto.depot_id),
LotNo = subDto.lot_no,
- Memo = subDto.memo,
- Erpid = mainErpId
+ Memo = subDto.memo
};
- var existingSub = Db.Queryable<ZZCXB>().Where(s => s.Eid == subEntity.Eid).Single();
+ var existingSub = Db.Queryable<ZZCXB>().Where(s => s.Erpid == subEntity.Erpid).Single();
if (existingSub != null) subEntity.Id = existingSub.Id;
item.SubItems ??= new List<ZZCXB>();
@@ -137,12 +152,25 @@
private bool SaveOrUpdateData(SqlSugarScope db, ZZCX head, List<ZZCXA> children)
{
+ // 1. 鏍¢獙鏄惁瀛樺湪棰嗘枡璁板綍锛圡ES_INV_ITEM_OUTS锛�
+ var hasMaterialOut = db.Queryable<MesInvItemOuts>()
+ .Any(x => x.WorkNo == head.BillNo);
+
+ if (hasMaterialOut)
+ {
+ throw new Exception($"MES宸叉湁棰嗘枡璁板綍锛屽崟鍙凤細{head.BillNo}锛屼笉鑳芥洿鏂帮紒");
+ }
+
if (head.Id != null)
base.DeleteById(head.Id);
+
+ // 鍒犻櫎瀛欒〃
+ db.Deleteable<ZZCXB>().Where(d => d.YdId == head.Erpid).ExecuteCommand();
+ // 鍒犻櫎瀛愯〃锛堜娇鐢� yd_id 浣滀负鍏宠仈锛�
db.Deleteable<ZZCXA>().Where(d => d.YdId == head.Erpid).ExecuteCommand();
- db.Deleteable<ZZCXB>().Where(d => d.Erpid == head.Erpid).ExecuteCommand();
-
+ // 鍒犻櫎涓昏〃
+ db.Deleteable<ZZCX>().Where(d => d.Erpid == head.Erpid).ExecuteCommand();
var insertedHead = db.Insertable(head)
.IgnoreColumns(true)
.ExecuteReturnIdentity();
@@ -180,6 +208,16 @@
private bool UpdateData(SqlSugarScope db, ZZCX head, List<ZZCXA> children)
{
+
+ // 1. 鏍¢獙鏄惁瀛樺湪棰嗘枡璁板綍锛圡ES_INV_ITEM_OUTS锛�
+ var hasMaterialOut = db.Queryable<MesInvItemOuts>()
+ .Any(x => x.WorkNo == head.BillNo);
+
+ if (hasMaterialOut)
+ {
+ throw new Exception($"MES宸叉湁棰嗘枡璁板綍锛屽崟鍙凤細{head.BillNo}锛屼笉鑳藉垹闄わ紒");
+ }
+
// 鍒犻櫎涓昏〃
var deletedHead = db.Deleteable<ZZCX>()
.Where(d => d.Erpid == head.Erpid)
--
Gitblit v1.9.3