.vs/slnx.sqlite | 补丁 | 查看 | 原始文档 | blame | 历史 | |
StandardInterface/MES.Service/Dto/webApi/ERPZJDB.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
StandardInterface/MES.Service/Modes/MesInvItemDbsq.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
StandardInterface/MES.Service/service/DbckaManager.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
StandardInterface/MES.Service/service/WomcaaManager.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
StandardInterface/MES.Service/service/ZjdbManager.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
StandardInterface/MESApplication/Controllers/ZJdbController.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
.vs/slnx.sqliteBinary files differ
StandardInterface/MES.Service/Dto/webApi/ERPZJDB.cs
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,49 @@ using System.Collections.Generic; namespace MES.Service.Dto.webApi { public class ERPZJDB { public ERPZJDBA ERPZJDBA { get; set; } = new ERPZJDBA(); public List<ERPZJDBB> ERPZJDBB { get; set; } = new List<ERPZJDBB>(); } public class ERPZJDBA { public string? billno { get; set; } // åæ®ç¼ç public string? dj_lx { get; set; } // åæ®ç±»å public string? db_lx1 { get; set; } // è°æ¨ç±»å public string? db_fx { get; set; } // è°æ¨æ¹å public string? db_lx { get; set; } // è°æ¨ç±»å public string? yw_lx { get; set; } // ä¸å¡ç±»å public string? dj_zt { get; set; } // åæ®ç¶æ public string? sq_bm { get; set; } // ç³è¯·é¨é¨ public string? dc_kc { get; set; } // è°åºåºåç»ç» public string? dr_kc { get; set; } // è°å ¥åºåç»ç» public string? dc_hz { get; set; } // è°åºè´§ä¸» public string? dr_hz { get; set; } // è°å ¥è´§ä¸» public string? dr_ck { get; set; } // è°å ¥ä»åº public string? dc_bm { get; set; } // è°åºé¨é¨ public string? dr_bm { get; set; } // è°å ¥é¨é¨ public string? bz { get; set; } // 夿³¨ public string type { get; set; } // type public string? erpid { get; set; } // è°æ¨åºåºåid } public class ERPZJDBB { public string? itemid { get; set; } // ç©æç¼ç public string? unit { get; set; } // åä½ public string? quantity { get; set; } // ç³è¯·æ°é public string? dc_org { get; set; } // è°åºç»ç» public string? dc_depot { get; set; } // è°åºä»åº public string? dr_org { get; set; } // è°å ¥ç»ç» public string? dr_depot { get; set; } // è°å ¥ä»åº public string? dc_hz { get; set; } // è°åºè´§ä¸» public string? dr_hz { get; set; } // è°å ¥è´§ä¸» public string? bz { get; set; } // 夿³¨ public string? erpid { get; set; } // è°æ¨åºåºè¡id public string? eid { get; set; } // è°æ¨åºåºå¤´id } } StandardInterface/MES.Service/Modes/MesInvItemDbsq.cs
@@ -211,5 +211,43 @@ ///</summary> [SugarColumn(ColumnName = "ERPID")] public string? Erpid { get; set; } /// <summary> /// è°åºåºåç»ç» ///</summary> [SugarColumn(ColumnName = "DC_KC")] public string? DcKc { get; set; } /// <summary> /// è°å ¥åºåç»ç» ///</summary> [SugarColumn(ColumnName = "DR_KC")] public string? DrKc { get; set; } /// <summary> /// è°å ¥è´§ä¸» ///</summary> [SugarColumn(ColumnName = "DR_HZ")] public string? DrHz { get; set; } /// <summary> /// è°å ¥ä»åº ///</summary> [SugarColumn(ColumnName = "DR_CK")] public string? DrCk { get; set; } /// <summary> /// è°åºé¨é¨ ///</summary> [SugarColumn(ColumnName = "DC_BM")] public string? DcBm { get; set; } /// <summary> /// è°å ¥é¨é¨ ///</summary> [SugarColumn(ColumnName = "DR_BM")] public string? DrBm { get; set; } /// <summary> /// MESç±»å ///</summary> [SugarColumn(ColumnName = "TYPE2")] public string? Type2 { get; set; } } } StandardInterface/MES.Service/service/DbckaManager.cs
@@ -59,7 +59,8 @@ CreateDate = DateTime.Now, CreateBy = "System", DbStatus="æªè°æ¨", Status=1 Status=1, Type2 = "åå¸å¼è°æ¨å", }; // var single = base.GetSingle(it => it.Erpid == entity.Erpid); StandardInterface/MES.Service/service/WomcaaManager.cs
@@ -98,8 +98,30 @@ List<Womcab> mesWomcabs) { //å®ä¹è¾å ¥åæ° var inputParam1 = new SugarParameter("P_WORK_NO", mesWomcaa.Caa001); // å®ä¹è¾åºåæ° var outParam1 = new SugarParameter("c_Result", null, true); var outParam2 = new SugarParameter("C_MSG", null, true); // ä½¿ç¨ SqlSugar æ§è¡åå¨è¿ç¨ Db.Ado.ExecuteCommand( "BEGIN PRC_UPDATE_DAA2(:P_WORK_NO,:c_Result,:C_MSG); END;", inputParam1, outParam1, outParam2); // è·åè¾åºåæ°çå¼ var result = int.Parse((string)outParam1.Value); var message = outParam2.Value == DBNull.Value ? string.Empty : (string)outParam2.Value; if (result == 1) { //åå¨è¿ç¨å¤±è´¥åäºå¡è¿è¡åæ» db.Ado.RollbackTran(); throw new Exception(message); } // æäº¤äºå¡ db.Ado.CommitTran(); var decimals = mesWomcabs.Select(s => s.Id).ToArray(); @@ -119,29 +141,7 @@ if (update && insertOrUpdate) { //å®ä¹è¾å ¥åæ° var inputParam1 = new SugarParameter("P_WORK_NO", mesWomcaa.Caa001); // å®ä¹è¾åºåæ° var outParam1 = new SugarParameter("c_Result", null, true); var outParam2 = new SugarParameter("C_MSG", null, true); // ä½¿ç¨ SqlSugar æ§è¡åå¨è¿ç¨ Db.Ado.ExecuteCommand( "BEGIN PRC_UPDATE_DAA2(:P_WORK_NO,:c_Result,:C_MSG); END;", inputParam1, outParam1, outParam2); // è·åè¾åºåæ°çå¼ var result = int.Parse((string)outParam1.Value); var message = outParam2.Value == DBNull.Value ? string.Empty : (string)outParam2.Value; if (result == 1) { //åå¨è¿ç¨å¤±è´¥åäºå¡è¿è¡åæ» db.Ado.RollbackTran(); throw new Exception(message); } // æäº¤äºå¡ db.Ado.CommitTran(); return true; } throw new NotImplementedException("æ´æ°å¤±è´¥"); StandardInterface/MES.Service/service/ZjdbManager.cs
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,142 @@ using SqlSugar; using System; using System.Collections.Generic; using System.Linq; using MES.Service.DB; using MES.Service.Dto.webApi; using MES.Service.Modes; namespace MES.Service.service { public class ERPZJDBManager : Repository<MesInvItemDbsq> { public bool SaveList(List<ERPZJDB> list) { var result = list.Select(Save).ToList(); return result.All(b => b); } public bool Save(ERPZJDB data) { var head = MapErpToMesHead(data.ERPZJDBA); var details = MapErpDbckbToDbckb(data.ERPZJDBB); return UseTransaction(db => { switch (data.ERPZJDBA.type) { case "3": return UpdateData(db, head, details) ? 1 : 0; case "2": case "4": case "5": return SaveOrUpdateData(db, head, details) ? 1 : 0; default: throw new NotImplementedException($"type没æ {data.ERPZJDBA.type} è¿ä¸ªç±»å"); } }) > 0; } private MesInvItemDbsq MapErpToMesHead(ERPZJDBA dto) { var entity = new MesInvItemDbsq { BillNo = dto.billno,//åæ®ç¼ç Djlx = dto.dj_lx, //åæ®ç±»å DbLx1 = dto.db_lx1, //è°æ¨ç±»å DbFx = dto.db_fx, //è°æ¨æ¹å DbLx = dto.db_lx, //è°æ¨ç±»å YwLx = dto.yw_lx, //ä¸å¡ç±»å DjZt = dto.dj_zt, //åæ®ç¶æ SqBm = dto.sq_bm, //ç³è¯·é¨é¨ DcKc = dto.dc_kc, //è°åºåºåç»ç» DrKc = dto.dr_kc, //è°å ¥åºåç»ç» DcHz = dto.dc_hz, //è°åºè´§ä¸» DrHz = dto.dr_hz, //è°å ¥è´§ä¸» DrCk = dto.dr_ck, //è°å ¥ä»åº DcBm = dto.dc_bm, //è°åºé¨é¨ DrBm = dto.dr_bm, //è°å ¥é¨é¨ Type2 = "ç´æ¥è°æ¨å", // Remark = dto.bz, Erpid = dto.erpid, CreateDate = DateTime.Now, CreateBy = "System", DbStatus = "æªè°æ¨", Status = 1 }; var single = Db.Queryable<MesInvItemDbsq>() .Where(it => it.Erpid == entity.Erpid) .First(); if (single != null) entity.Id = single.Id; return entity; } private List<MesInvItemDbsqItems> MapErpDbckbToDbckb(List<ERPZJDBB> list) { var result = new List<MesInvItemDbsqItems>(); foreach (var dto in list) { var item = new MesInvItemDbsqItems { ItemId = Convert.ToDecimal(dto.itemid), ItemUnit = Convert.ToDecimal(dto.unit), SqNum = decimal.TryParse(dto.quantity, out var qty) ? qty : 0, DcOrg = dto.dc_org, DcDepot = dto.dc_depot, DrOrg = dto.dr_org, DrDepot = dto.dr_depot, DcHz = dto.dc_hz, DrHz = dto.dr_hz, Remark = dto.bz, Erpid = dto.erpid, Eid = dto.eid, }; var existing = Db.Queryable<MesInvItemDbsqItems>().Where(s => s.Erpid == item.Erpid).Single(); if (existing != null) item.Id = existing.Id; result.Add(item); } return result; } private bool SaveOrUpdateData(SqlSugarScope db, MesInvItemDbsq head, List<MesInvItemDbsqItems> details) { if (head.Id != null) base.DeleteById(head.Id); db.Deleteable<MesInvItemDbsqItems>() .Where(d => d.Eid == head.Erpid) .ExecuteCommand(); var insertedHead = db.Insertable(head) .IgnoreColumns(true) .ExecuteReturnIdentity(); if (insertedHead <= 0) throw new Exception("主表æå ¥å¤±è´¥ï¼æªè¿åID"); var success = db.Insertable(details) .PageSize(10) .IgnoreColumnsNull() .ExecuteCommand() > 0; if (insertedHead >= 0 && success) return true; throw new NotImplementedException("æå ¥ææ´æ°å¤±è´¥"); } private bool UpdateData(SqlSugarScope db, MesInvItemDbsq head, List<MesInvItemDbsqItems> details) { var ids = details.Select(d => d.Id).ToArray(); var deletedHead = base.DeleteById(head.Id); var deletedDetails = db.Deleteable<MesInvItemDbsqItems>().In(ids).ExecuteCommand() > 0; if (deletedHead && deletedDetails) return true; throw new NotImplementedException("æ´æ°å¤±è´¥"); } } } StandardInterface/MESApplication/Controllers/ZJdbController.cs
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,103 @@ using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; using System.Dynamic; using MES.Service.service; using MES.Service.Dto.webApi; using MES.Service.util; using Newtonsoft.Json; using MES.Service.Modes; namespace MESApplication.Controllers { [ApiController] [Route("api/[controller]")] public class ERPZJDBController : ControllerBase { private readonly ERPZJDBManager _manager = new(); // è¿éå¯¹åºæ°ç Service private readonly MessageCenterManager _messageManager = new(); private const string METHOD = "POST"; private const string TableName = "ERPZJDB"; private const string URL = "http://localhost:10054/api/ERPZJDB/"; /// <summary> /// ä¿ååæ¡è°æ¨å /// </summary> [HttpPost("Save")] public ResponseResult Save([FromBody] ERPZJDB data) { var msg = new MessageCenter { TableName = TableName, Url = URL + "Save", Method = METHOD, Data = JsonConvert.SerializeObject(data), Status = 1, CreateBy = "PL017", Route = data.ERPZJDBA.billno // 注æå billno }; try { dynamic resultInfos = new ExpandoObject(); var success = _manager.Save(data); resultInfos.tbBillList = success; msg.Result = success ? (short?)1 : (short?)0; msg.DealWith = 1; _messageManager.save(msg); return new ResponseResult { status = 0, message = "OK", data = resultInfos }; } catch (Exception ex) { msg.Result = 0; msg.DealWith = 0; msg.ResultData = ex.Message; _messageManager.save(msg); return ResponseResult.ResponseError(ex); } } /// <summary> /// æ¹éä¿åè°æ¨å /// </summary> [HttpPost("SaveList")] public ResponseResult SaveList([FromBody] List<ERPZJDB> dataList) { var msg = new MessageCenter { TableName = TableName, Url = URL + "SaveList", Method = METHOD, Data = JsonConvert.SerializeObject(dataList), Status = 1, CreateBy = "PL017" }; try { dynamic resultInfos = new ExpandoObject(); var success = _manager.SaveList(dataList); resultInfos.tbBillList = success; msg.Result = success ? (short?)1 : (short?)0; msg.DealWith = 1; _messageManager.save(msg); return new ResponseResult { status = 0, message = "OK", data = resultInfos }; } catch (Exception ex) { msg.Result = 0; msg.DealWith = 0; msg.ResultData = ex.Message; _messageManager.save(msg); return ResponseResult.ResponseError(ex); } } } }