From a90b36c3f1e2b7831b8ef15b09da9f8ab9f04e81 Mon Sep 17 00:00:00 2001
From: wet <1034391973@qq.com>
Date: Fri, 13 May 2022 18:05:24 +0800
Subject: [PATCH] ams
---
ams/Djy.Common/Common.csproj | 2 +
ams/Djy.Common/DapperDBBase.cs | 61 ++++++------------
ams/Djy.Common/DjyService/DbContext.cs | 4 +-
ams/Djy.Common/Interface/IDapperDBBase.cs | 4 ++
ams/djy.IService/Ams/IAmsService.cs | 11 +++-
ams/djy.Model/Ams/AMS_Cntrno.cs | 6 +-
ams/djy.Model/AmsDto/AMSDto.cs | 33 +++++++++-
ams/djy.Service/Ams/AmsService.cs | 62 +++++++++++++++++--
ams/djy.Service/djy.Service.csproj | 6 ++
.../Controllers/AMS/AmsController.cs | 44 +++++--------
ams/djy.WebApi/appsettings.Development.json | 18 +-----
ams/djy.WebApi/appsettings.Prod.json | 20 +-----
ams/djy.WebApi/appsettings.json | 16 +----
13 files changed, 161 insertions(+), 126 deletions(-)
diff --git a/ams/Djy.Common/Common.csproj b/ams/Djy.Common/Common.csproj
index 797c6c9..702fe37 100644
--- a/ams/Djy.Common/Common.csproj
+++ b/ams/Djy.Common/Common.csproj
@@ -35,6 +35,7 @@
+
@@ -65,6 +66,7 @@
+
diff --git a/ams/Djy.Common/DapperDBBase.cs b/ams/Djy.Common/DapperDBBase.cs
index 9431ca8..298f154 100644
--- a/ams/Djy.Common/DapperDBBase.cs
+++ b/ams/Djy.Common/DapperDBBase.cs
@@ -1,5 +1,4 @@
-
-using Dapper;
+using Dapper;
using Dapper.Contrib.Extensions;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Configuration;
@@ -9,16 +8,19 @@ using System.Threading.Tasks;
using Common;
using Microsoft.EntityFrameworkCore;
using Common.Interface;
+using System.Linq.Expressions;
+using System;
+using System.Linq;
namespace Common
{
///
/// Dapper帮助类
///
- public class DapperDBBase : DbContext, IDapperDBBase
+ public class DapperDBBase : DbContext,IDapperDBBase
{
private string sqlConnection;
-
+
public DapperDBBase()
{
@@ -33,9 +35,9 @@ namespace Common
if (string.IsNullOrEmpty(sqlConnection))
sqlConnection = sysOptionConfig.YsWebconfig.DapperDbString;
- IDbConnection conn = new SqlConnection(sqlConnection);
- conn.Open();
- return conn;
+ IDbConnection conn = new SqlConnection(sqlConnection);
+ conn.Open();
+ return conn;
}
///
@@ -410,7 +412,6 @@ namespace Common
///
/// 根据查询SQL直接返回datatable
- /// Author GHB 2021-6-15
///
/// 实体模型
///
@@ -426,7 +427,7 @@ namespace Common
}
///
- /// 执行SQL语句返回结果gjg
+ /// 执行SQL语句返回结果
///
///
///
@@ -438,6 +439,11 @@ namespace Common
return await Conn.ExecuteScalarAsync(Sql, parms);
}
}
+
+
+
+
+
///
/// 执行中包含事务sql
///
@@ -501,45 +507,18 @@ namespace Common
-
- /// 数据库连接名
- private static string _connection = string.Empty;
-
- /// 获取连接名
- private static string Connection
+
+ public long Insert(T model) where T : class, new()
{
- get { return _connection; }
- set { _connection = value; }
- }
-
-
-
- /// 定义一个标识确保线程同步
- private static readonly object locker = new object();
-
- private static DapperDBBase uniqueInstance;
- ///
- /// 获取实例,这里为单例模式,保证只存在一个实例
- ///
- ///
- public static DapperDBBase GetInstance()
- {
- // 双重锁定实现单例模式,在外层加个判空条件主要是为了减少加锁、释放锁的不必要的损耗
- if (uniqueInstance == null)
+ using (IDbConnection Conn = GetConn())
{
- lock (locker)
- {
- if (uniqueInstance == null)
- {
- uniqueInstance = new DapperDBBase();
- }
- }
+ return Conn.Insert(model);
}
- return uniqueInstance;
}
+
}
}
diff --git a/ams/Djy.Common/DjyService/DbContext.cs b/ams/Djy.Common/DjyService/DbContext.cs
index 3c94066..dd88fb4 100644
--- a/ams/Djy.Common/DjyService/DbContext.cs
+++ b/ams/Djy.Common/DjyService/DbContext.cs
@@ -21,13 +21,13 @@ namespace Common.DjyService
///
///独立的大简云publice库
///
- public const string djypublicedb = "djydb";
+ public const string djydb = "djydb";
///
///大简云平台老库
///
public const string djyolddb = "djyolddb";
///
- /// 账单中心库
+ /// AMS
///
public const string AMSCenter = "AMS";
///
diff --git a/ams/Djy.Common/Interface/IDapperDBBase.cs b/ams/Djy.Common/Interface/IDapperDBBase.cs
index af39be9..2cccb6b 100644
--- a/ams/Djy.Common/Interface/IDapperDBBase.cs
+++ b/ams/Djy.Common/Interface/IDapperDBBase.cs
@@ -1,6 +1,8 @@
using Dapper;
+using System;
using System.Collections.Generic;
using System.Data;
+using System.Linq.Expressions;
using System.Threading.Tasks;
namespace Common.Interface
@@ -207,5 +209,7 @@ namespace Common.Interface
///
///
Task ExecSqlTransAsync(List listSql);
+
+
}
}
diff --git a/ams/djy.IService/Ams/IAmsService.cs b/ams/djy.IService/Ams/IAmsService.cs
index 3afec1a..98b95c8 100644
--- a/ams/djy.IService/Ams/IAmsService.cs
+++ b/ams/djy.IService/Ams/IAmsService.cs
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using djy.Model;
using Common;
using Common.Djy;
+using djy.Model.AmsDto;
namespace djy.Paas.IService
{
@@ -14,8 +15,14 @@ namespace djy.Paas.IService
///
public interface IAmsService:IsBase
{
-
-
+ ///
+ /// 新增
+ ///
+ ///
+ ///
+ void SaveInfo(AMSDto dto,string userid);
+
+ List GetAll();
}
}
diff --git a/ams/djy.Model/Ams/AMS_Cntrno.cs b/ams/djy.Model/Ams/AMS_Cntrno.cs
index 0bd224e..78286c4 100644
--- a/ams/djy.Model/Ams/AMS_Cntrno.cs
+++ b/ams/djy.Model/Ams/AMS_Cntrno.cs
@@ -19,8 +19,10 @@ namespace djy.Model.Ams
/// 父键
///
public string HID { get; set; }
-
-
+ ///
+ /// 业务id
+ ///
+ public string PID { get; set; }
///
/// 箱号
diff --git a/ams/djy.Model/AmsDto/AMSDto.cs b/ams/djy.Model/AmsDto/AMSDto.cs
index 8c43504..39efc99 100644
--- a/ams/djy.Model/AmsDto/AMSDto.cs
+++ b/ams/djy.Model/AmsDto/AMSDto.cs
@@ -2,27 +2,52 @@
using System;
using System.Collections.Generic;
-namespace AMSDto
+namespace djy.Model.AmsDto
{
- public class AMSSaveDto
+ public class AMSDto
{
///
/// 主键
///
public string GID { get; set; }
+
+ ///
+ /// 用户id
+ ///
+ public string UserID { get; set; }
+
+ ///
+ /// 用户
+ ///
+ public string UserName { get; set; }
+
+ ///
+ /// 公司id
+ ///
+ public string CompID { get; set; }
+
+ ///
+ /// 公司
+ ///
+ public string CompName { get; set; }
+
+
///
/// 船公司id
///
public string CARRIERID { get; set; }
+
///
/// 船公司
///
public string CARRIER { get; set; }
+
+
///
/// 提单号
///
@@ -60,6 +85,7 @@ namespace AMSDto
///
public string LastNoUsPort { get; set; }
+
///
/// 卸货港
///
@@ -76,6 +102,9 @@ namespace AMSDto
///
public DateTime? ETD { get; set; }
+ public DateTime? CreateTime { get; set; }
+ public DateTime? LastUpdate { get; set; }
+
public List HouseDto { get; set; }
}
diff --git a/ams/djy.Service/Ams/AmsService.cs b/ams/djy.Service/Ams/AmsService.cs
index 669e325..44fcb9a 100644
--- a/ams/djy.Service/Ams/AmsService.cs
+++ b/ams/djy.Service/Ams/AmsService.cs
@@ -10,7 +10,9 @@ using System.Data.SqlClient;
using Common;
using djy.Model.Ams;
using Common.DjyService;
-using AMSDto;
+using djy.Model.AmsDto;
+using Common.Extensions;
+using Common.DJYModel;
namespace djy.Service.Ams
{
@@ -19,13 +21,65 @@ namespace djy.Service.Ams
///
public class AmsService : ServBase, IAmsService
{
+ DapperDBBase dapper = new DapperDBBase();
-
- public async void SaveInfo(AMSSaveDto dto)
+
+ public List GetAll()
{
+ throw new NotImplementedException();
+ }
+
+ public async void SaveInfo(AMSDto dto,string userid)
+ {
+
+ if (dto.GID.IsNull())
+ {
+ using (var transaction = dapper.BeginTransaction(dapper.GetConn()))
+ {
+ try
+ {
+ var user = DbBus.Get(DbList.djydb).Select().Where(w => w.GID == userid).ToOne();
+ AMS_Master master = dto.MapTo();
+ master.CreateTime = DateTime.Now;
+ master.LastUpdate = DateTime.Now;
+ master.GID = Guid.NewGuid().ToString("N");
+ master.UserID = user.GID;
+ master.UserName = user.SHOWNAME;
+ master.CompID = user.CompId;
+ master.CompName = user.COMNAME;
+ dapper.Insert(master);
+ foreach (var item in dto.HouseDto)
+ {
+ AMS_House house = dto.MapTo();
+ house.GID = Guid.NewGuid().ToString("N");
+ house.PID = master.GID;
+ dapper.Insert(house);
+ foreach (var it in item.CntrnoDto)
+ {
+ AMS_Cntrno cntrno = dto.MapTo();
+ cntrno.GID = Guid.NewGuid().ToString("N");
+ cntrno.PID = master.GID;
+ cntrno.HID = house.GID;
+ dapper.Insert(cntrno);
+ }
+ }
+ transaction.Rollback();
+ }
+ catch (Exception ex)
+ {
+ transaction.Rollback();
+ }
+
+ }
+ }
+ else {
+
+
+
-
+ }
+
}
}
}
diff --git a/ams/djy.Service/djy.Service.csproj b/ams/djy.Service/djy.Service.csproj
index fc2eaf1..0425a63 100644
--- a/ams/djy.Service/djy.Service.csproj
+++ b/ams/djy.Service/djy.Service.csproj
@@ -10,6 +10,12 @@
+
+
+
+
+
+
diff --git a/ams/djy.WebApi/Controllers/AMS/AmsController.cs b/ams/djy.WebApi/Controllers/AMS/AmsController.cs
index 84d09a4..033b24f 100644
--- a/ams/djy.WebApi/Controllers/AMS/AmsController.cs
+++ b/ams/djy.WebApi/Controllers/AMS/AmsController.cs
@@ -1,8 +1,8 @@
-using AMSDto;
-using Common;
+using Common;
using Common.DjyService;
using Common.Utilities;
using djy.Model.Ams;
+using djy.Model.AmsDto;
using djy.Service;
using djy.Service.Ams;
using Microsoft.AspNetCore.Authorization;
@@ -14,36 +14,24 @@ namespace djy_AmsApi.Controllers
[AllowAnonymous]
public class AmsController : ApiBase
{
- DapperDBBase dapper = new DapperDBBase();
+
AmsService ser =new AmsService();
- [HttpPost("Add")]
- public Response Add(AMSSaveDto Dto)
+ [HttpPost("AddOrUpdate")]
+ public Response AddOrUpdate(AMSDto Dto)
{
var result = new Response();
-
- AMS_Master master = Dto.MapTo();
- using (var transaction = dapper.BeginTransaction(dapper.GetConn()))
- {
- try
- {
-
-
-
-
-
-
- master.CreateTime = DateTime.Now;
- var gid = dapper.InsertByEntityAsync(master);
-
- }
- catch (Exception ex)
- {
- transaction.Rollback();
- result.Code = 500;
- result.Message = ex.InnerException?.Message ?? ex.Message;
- }
- }
+ //if (GetLoginId==null) {
+ // result.Code = 401;
+ // result.Message = "登录过期,请重新登录!";
+ //}
+ if (Dto == null)
+ {
+ result.Code = 500;
+ result.Message = "无效数据!";
+ }
+ ser.SaveInfo(Dto, "d85fd590-d9f6-4410-93a1-f6fac77b606e");
+
return result;
}
diff --git a/ams/djy.WebApi/appsettings.Development.json b/ams/djy.WebApi/appsettings.Development.json
index 83130dc..d40bc08 100644
--- a/ams/djy.WebApi/appsettings.Development.json
+++ b/ams/djy.WebApi/appsettings.Development.json
@@ -34,7 +34,6 @@
{
"SysKey": "AMS",
-
"TitleName": "AMS",
"Index": 100,
"DataType": 1,
@@ -43,12 +42,11 @@
},
{
"SysKey": "djydb",
-
- "TitleName": "大简云新库",
+ "TitleName": "pingtai",
"Index": 100,
"DataType": 1,
"Status": 0,
- "ConnString": "Data Source =192.168.1.205,1433; Initial Catalog=TestPubliceData; Persist Security Info=True; User ID =test; Password=test123;pooling=true"
+ "ConnString": "Data Source =123.234.225.158,28000; Initial Catalog=DevDsPingTai; Persist Security Info=True; User ID =dev; Password=dev123;pooling=true"
},
{
@@ -57,17 +55,7 @@
"Index": 100,
"DataType": 1,
"Status": 0,
- "ConnString": "Data Source =192.168.1.205,1433; Initial Catalog=TestDjyLogs; Persist Security Info=True; User ID =test; Password=test123;pooling=true"
-
- },
- {
- "SysKey": "djyolddb",
-
- "TitleName": "大简云老库",
- "Index": 100,
- "DataType": 1,
- "Status": 0,
- "ConnString": "Data Source =192.168.1.205,1433; Initial Catalog=TestDsPingTai; Persist Security Info=True; User ID =test; Password=test123;pooling=true"
+ "ConnString": "Data Source =172.31.85.154,1433; Initial Catalog=djy_logs; Persist Security Info=True; User ID =sa; Password=QDdjy#2020*;pooling=true"
}
diff --git a/ams/djy.WebApi/appsettings.Prod.json b/ams/djy.WebApi/appsettings.Prod.json
index 1e23902..9f5e41c 100644
--- a/ams/djy.WebApi/appsettings.Prod.json
+++ b/ams/djy.WebApi/appsettings.Prod.json
@@ -32,7 +32,6 @@
{
"SysKey": "AMS",
-
"TitleName": "AMS",
"Index": 100,
"DataType": 1,
@@ -41,13 +40,11 @@
},
{
"SysKey": "djydb",
-
- "TitleName": "大简云新库",
+ "TitleName": "pingtai",
"Index": 100,
"DataType": 1,
"Status": 0,
- // "ConnString": "Data Source =172.17.0.3; Initial Catalog=djy_PaasData; Persist Security Info=True; User ID =sa; Password=QDdjy2021*;pooling=true",
- "ConnString": "Data Source =172.31.85.154; Initial Catalog=djy_PubliceData; Persist Security Info=True; User ID =sa; Password=QDdjy#2020*;pooling=true"
+ "ConnString": "Data Source =123.234.225.158,28000; Initial Catalog=DevDsPingTai; Persist Security Info=True; User ID =dev; Password=dev123;pooling=true"
},
{
@@ -56,19 +53,8 @@
"Index": 100,
"DataType": 1,
"Status": 0,
- // "ConnString": "Data Source =172.17.0.3; Initial Catalog=djy_logs; Persist Security Info=True; User ID = sa; Password=QDdjy2021*;pooling=true",
- "ConnString": "Data Source =172.31.85.154; Initial Catalog=djy_logs; Persist Security Info=True; User ID =sa; Password=QDdjy#2020*;pooling=true"
- },
- {
- "SysKey": "djyolddb",
+ "ConnString": "Data Source =172.31.85.154,1433; Initial Catalog=djy_logs; Persist Security Info=True; User ID =sa; Password=QDdjy#2020*;pooling=true"
- "TitleName": "大简云老库",
- "Index": 100,
- "DataType": 1,
- "Status": 0,
- // "ConnString": "Data Source =172.17.0.3; Initial Catalog=MYSHIPPINGTEST8; Persist Security Info=True; User ID =sa; Password=QDdjy2021*;pooling=true",
- //"ConnString": "Data Source =172.31.85.154; Initial Catalog=MYSHIPPINGTEST8; Persist Security Info=True; User ID =sa; Password=QDdjy#2020*;pooling=true",
- "ConnString": "Data Source =172.31.85.154; Initial Catalog=DsPingTai; Persist Security Info=True; User ID =sa; Password=QDdjy#2020*;pooling=true"
}
diff --git a/ams/djy.WebApi/appsettings.json b/ams/djy.WebApi/appsettings.json
index 6ef5ecb..2ca92b8 100644
--- a/ams/djy.WebApi/appsettings.json
+++ b/ams/djy.WebApi/appsettings.json
@@ -40,12 +40,11 @@
},
{
"SysKey": "djydb",
-
- "TitleName": "大简云新库",
+ "TitleName": "pingtai",
"Index": 100,
"DataType": 1,
"Status": 0,
- "ConnString": "Data Source =172.31.85.154,1433; Initial Catalog=djy_PubliceData; Persist Security Info=True; User ID =sa; Password=QDdjy#2020*;pooling=true"
+ "ConnString": "Data Source =123.234.225.158,28000; Initial Catalog=DevDsPingTai; Persist Security Info=True; User ID =dev; Password=dev123;pooling=true"
},
{
@@ -56,17 +55,8 @@
"Status": 0,
"ConnString": "Data Source =172.31.85.154,1433; Initial Catalog=djy_logs; Persist Security Info=True; User ID =sa; Password=QDdjy#2020*;pooling=true"
- },
- {
- "SysKey": "djyolddb",
-
- "TitleName": "大简云老库",
- "Index": 100,
- "DataType": 1,
- "Status": 0,
- "ConnString": "Data Source =172.31.85.154,1433; Initial Catalog=DsPingTai; Persist Security Info=True; User ID =sa; Password=QDdjy#2020*;pooling=true"
-
}
+
]