|
|
@ -13,6 +13,9 @@ using Common.DjyService;
|
|
|
|
using djy.Model.AmsDto;
|
|
|
|
using djy.Model.AmsDto;
|
|
|
|
using Common.Extensions;
|
|
|
|
using Common.Extensions;
|
|
|
|
using Common.DJYModel;
|
|
|
|
using Common.DJYModel;
|
|
|
|
|
|
|
|
using System.Transactions;
|
|
|
|
|
|
|
|
using Dapper.Contrib.Extensions;
|
|
|
|
|
|
|
|
using Common.Utilities;
|
|
|
|
|
|
|
|
|
|
|
|
namespace djy.Service.Ams
|
|
|
|
namespace djy.Service.Ams
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -24,21 +27,78 @@ namespace djy.Service.Ams
|
|
|
|
DapperDBBase dapper = new DapperDBBase();
|
|
|
|
DapperDBBase dapper = new DapperDBBase();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<AMSDto> GetAll()
|
|
|
|
|
|
|
|
|
|
|
|
public TableData Load(AMSQuery req, string userid)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var result = new TableData();
|
|
|
|
|
|
|
|
var user = DbBus.Get(DbList.djydb).Select<User>().Where(w => w.GID == userid).ToOne();
|
|
|
|
|
|
|
|
var dto = DbBus.Get(DbList.AMSCenter).Select<AMS_Master>().Where(x => x.IsDel == "0" || x.IsDel == null&&x.CompID==user.CompId).WhereIf(req.MBLNO != null, x => x.MBLNO == req.MBLNO);
|
|
|
|
|
|
|
|
result.count = dto.ToList().Count();
|
|
|
|
|
|
|
|
var list= dto.Page(req.Page,req.Limit).ToList<AMSDto>();
|
|
|
|
|
|
|
|
if (list != null) {
|
|
|
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var hodto = DbBus.Get(DbList.AMSCenter).Select<AMS_House>().Where(x => x.IsDel == "0" || x.IsDel == null && x.PID == item.GID).ToList<AMS_HouseDto>();
|
|
|
|
|
|
|
|
item.HouseDto = hodto;
|
|
|
|
|
|
|
|
if (hodto!=null) {
|
|
|
|
|
|
|
|
foreach (var it in hodto)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
var cnt = DbBus.Get(DbList.AMSCenter).Select<AMS_Cntrno>().Where(x => x.IsDel == "0" || x.IsDel == null && x.HID == it.GID).ToList();
|
|
|
|
|
|
|
|
it.CntrnoDto = cnt;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
result.data = list;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async void SaveInfo(AMSDto dto,string userid)
|
|
|
|
public void Delete(string ids)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string[] id = ids.Split(',');
|
|
|
|
|
|
|
|
using (var transaction = new TransactionScope())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
using (IDbConnection connection = dapper.GetConn())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
foreach (string oid in id)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (oid != "")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
connection.Execute("update AMS_Cntrno set isdel ='1' where pid='" + oid + "'");
|
|
|
|
|
|
|
|
connection.Execute("update AMS_House set isdel ='1' where pid='" + oid + "'");
|
|
|
|
|
|
|
|
connection.Execute("update AMS_Master set isdel ='1' where gid='" + oid + "'");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
transaction.Complete();
|
|
|
|
|
|
|
|
connection.Dispose();
|
|
|
|
|
|
|
|
connection.Close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connection.Dispose();
|
|
|
|
|
|
|
|
connection.Close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async void SaveInfo(AMSDto dto, string userid)
|
|
|
|
|
|
|
|
{
|
|
|
|
if (dto.GID.IsNull())
|
|
|
|
if (dto.GID.IsNull())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
using (var transaction = dapper.BeginTransaction(dapper.GetConn()))
|
|
|
|
var user = DbBus.Get(DbList.djydb).Select<User>().Where(w => w.GID == userid).ToOne();
|
|
|
|
|
|
|
|
using (var transaction = new TransactionScope())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
using (IDbConnection connection = dapper.GetConn())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var user = DbBus.Get(DbList.djydb).Select<User>().Where(w => w.GID == userid).ToOne();
|
|
|
|
|
|
|
|
AMS_Master master = dto.MapTo<AMS_Master>();
|
|
|
|
AMS_Master master = dto.MapTo<AMS_Master>();
|
|
|
|
master.CreateTime = DateTime.Now;
|
|
|
|
master.CreateTime = DateTime.Now;
|
|
|
|
master.LastUpdate = DateTime.Now;
|
|
|
|
master.LastUpdate = DateTime.Now;
|
|
|
@ -47,34 +107,86 @@ namespace djy.Service.Ams
|
|
|
|
master.UserName = user.SHOWNAME;
|
|
|
|
master.UserName = user.SHOWNAME;
|
|
|
|
master.CompID = user.CompId;
|
|
|
|
master.CompID = user.CompId;
|
|
|
|
master.CompName = user.COMNAME;
|
|
|
|
master.CompName = user.COMNAME;
|
|
|
|
dapper.Insert<AMS_Master>(master);
|
|
|
|
connection.Insert<AMS_Master>(master);
|
|
|
|
|
|
|
|
if (dto.HouseDto != null && dto.HouseDto.Count() > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
foreach (var item in dto.HouseDto)
|
|
|
|
foreach (var item in dto.HouseDto)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
AMS_House house = dto.MapTo<AMS_House>();
|
|
|
|
AMS_House house = dto.MapTo<AMS_House>();
|
|
|
|
house.GID = Guid.NewGuid().ToString("N");
|
|
|
|
house.GID = Guid.NewGuid().ToString("N");
|
|
|
|
house.PID = master.GID;
|
|
|
|
house.PID = master.GID;
|
|
|
|
dapper.Insert<AMS_House>(house);
|
|
|
|
connection.Insert<AMS_House>(house);
|
|
|
|
|
|
|
|
if (item.CntrnoDto!=null&&item.CntrnoDto.Count()>0) {
|
|
|
|
foreach (var it in item.CntrnoDto)
|
|
|
|
foreach (var it in item.CntrnoDto)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
AMS_Cntrno cntrno = dto.MapTo<AMS_Cntrno>();
|
|
|
|
AMS_Cntrno cntrno = dto.MapTo<AMS_Cntrno>();
|
|
|
|
cntrno.GID = Guid.NewGuid().ToString("N");
|
|
|
|
cntrno.GID = Guid.NewGuid().ToString("N");
|
|
|
|
cntrno.PID = master.GID;
|
|
|
|
cntrno.PID = master.GID;
|
|
|
|
cntrno.HID = house.GID;
|
|
|
|
cntrno.HID = house.GID;
|
|
|
|
dapper.Insert<AMS_Cntrno>(cntrno);
|
|
|
|
connection.Insert<AMS_Cntrno>(cntrno);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
transaction.Rollback();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
transaction.Complete();
|
|
|
|
|
|
|
|
connection.Dispose();
|
|
|
|
|
|
|
|
connection.Close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
transaction.Rollback();
|
|
|
|
connection.Dispose();
|
|
|
|
|
|
|
|
connection.Close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using (var transaction = new TransactionScope())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
using (IDbConnection connection = dapper.GetConn())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AMS_Master master = dto.MapTo<AMS_Master>();
|
|
|
|
|
|
|
|
connection.Update<AMS_Master>(master);
|
|
|
|
|
|
|
|
connection.Execute("delete AMS_House where pid='"+ master.GID + "'");
|
|
|
|
|
|
|
|
connection.Execute("delete AMS_Cntrno where pid='" + master.GID + "'");
|
|
|
|
|
|
|
|
if (dto.HouseDto!=null&& dto.HouseDto.Count()>0) {
|
|
|
|
|
|
|
|
foreach (var item in dto.HouseDto)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
AMS_House house = dto.MapTo<AMS_House>();
|
|
|
|
|
|
|
|
house.GID = Guid.NewGuid().ToString("N");
|
|
|
|
|
|
|
|
house.PID = master.GID;
|
|
|
|
|
|
|
|
connection.Insert<AMS_House>(house);
|
|
|
|
|
|
|
|
if (item.CntrnoDto!=null&&item.CntrnoDto.Count()>0) {
|
|
|
|
|
|
|
|
foreach (var it in item.CntrnoDto)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
AMS_Cntrno cntrno = dto.MapTo<AMS_Cntrno>();
|
|
|
|
|
|
|
|
cntrno.GID = Guid.NewGuid().ToString("N");
|
|
|
|
|
|
|
|
cntrno.PID = master.GID;
|
|
|
|
|
|
|
|
cntrno.HID = house.GID;
|
|
|
|
|
|
|
|
connection.Insert<AMS_Cntrno>(cntrno);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
}
|
|
|
|
|
|
|
|
transaction.Complete();
|
|
|
|
|
|
|
|
connection.Dispose();
|
|
|
|
|
|
|
|
connection.Close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
connection.Dispose();
|
|
|
|
|
|
|
|
connection.Close();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|