AFR添加模板功能、调整港口下拉列表数据

master
zhangxiaofeng 10 months ago
parent 02d75ba012
commit 087bacbc4f

@ -0,0 +1,42 @@
using FreeSql.DataAnnotations;
using Newtonsoft.Json;
using System;
using System.ComponentModel.DataAnnotations;
namespace Common.DJYModel
{
[JsonObject(MemberSerialization.OptIn), Table(Name = "MappingPort", DisableSyncStructure = true)]
public class MappingPort
{
[JsonProperty, Column(IsPrimary = true, IsNullable = false)]
[MaxLength(36)]
public string GID { get; set; }
[MaxLength(20)]
public string Code { get; set; }
[MaxLength(20)]
public string Module { get; set; }
[MaxLength(50)]
public string MapCode { get; set; }
[MaxLength(200)]
public string MapName { get; set; }
[MaxLength(500)]
public string Remark { get; set; }
public DateTime CreateTime { get; set; }
public DateTime? ModifyTime { get; set; }
[MaxLength(36)]
public string CreateUser { get; set; }
[MaxLength(36)]
public string ModifyUser { get; set; }
}
}

@ -15,7 +15,7 @@ namespace djy.IService.Afr
List<CommonMappiCode> GetCTNALL();
List<CommonMappiCode> GetPackage();
List<CodeDangerGradeDto> GetDangerousGoods(string strlink);
List<CommonCodeValue> GetPort(string strlink, int page, int limit);
List<CommonMappiCode> GetPort(string strlink, int page, int limit);
List<CommonCodeValue> GetVessel(string strlink, int page, int limit);
#endregion
@ -26,5 +26,8 @@ namespace djy.IService.Afr
Task<(bool isSuccess, string message)> Send(string ids, string hids, int sendType);
Task SaveReceipt(AFRReceiptDto input);
Task<List<AFRMasterHistory>> GetHistory(string pid, string hid);
Task<List<AFRAddrTemplate>> GetTemplate(string type, string name);
Task SaveTemplate(AFRAddrTemplate input);
Task DeleteTemplate(string ids);
}
}

@ -0,0 +1,51 @@
using djy.Model.AFR;
using FreeSql.DataAnnotations;
using System;
namespace djy.Model.Afr
{
[Table(Name = "AFR_AddrTemplate", DisableSyncStructure = true)]
public class AFRAddrTemplate : AFRBaseModel
{
/// <summary>
/// 地址
/// </summary>
public string Address { get; set; }
/// <summary>
/// 城市
/// </summary>
public string City { get; set; }
/// <summary>
/// 联系人
/// </summary>
public string Contact { get; set; }
/// <summary>
/// 国家
/// </summary>
public string Country { get; set; }
/// <summary>
/// 国家代码
/// </summary>
public string CountryCode { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 联系人电话
/// </summary>
public string Tel { get; set; }
/// <summary>
/// 收发通类型 1:发货人 2:收货人 3:通知人
/// </summary>
public byte? Type { get; set; }
}
}

@ -139,34 +139,41 @@ namespace djy.Service.AFR
}
}
public List<CommonCodeValue> GetPort(string strlink, int page, int limit)
public List<CommonMappiCode> GetPort(string strlink, int page, int limit)
{
try
{
if (page == 0 && limit == 0)
{
var List = DbBus.Get(DbList.Common).Select<CodePort>().WhereIf(strlink != "", x => x.Code.Contains(strlink.Trim()) || x.EnName.Contains(strlink.Trim())).ToList().Select(x => new CommonCodeValue
{
Code = x.Code,
Value = x.EnName,
}).Distinct().ToList();
return List;
}
else
{
var List = DbBus.Get(DbList.Common).Select<CodePort>().WhereIf(strlink != "", x => x.Code.Contains(strlink.Trim()) || x.EnName.Contains(strlink.Trim())).Page(page, limit).ToList().Select(x => new CommonCodeValue
{
Code = x.Code,
Value = x.EnName,
}).Distinct().ToList();
return List;
}
}
catch (Exception e)
{
throw;
}
//try
//{
//if (page == 0 && limit == 0)
//{
var List = DbBus.Get(DbList.Common)
.Select<CodePort, MappingPort>()
.InnerJoin((cp, mp) => cp.Code == mp.Code)
.Where((cp, mp) => mp.Module == "AFR")
.ToList((cp, mp) => new CommonMappiCode
{
//Code = cp.Code,
//Value = cp.EnName,
Code = null,
Value = null,
MapCode = mp.MapCode,
MapName = mp.MapName
});
return List;
//}
//else
//{
// var List = DbBus.Get(DbList.Common).Select<CodePort>().WhereIf(strlink != "", x => x.Code.Contains(strlink.Trim()) || x.EnName.Contains(strlink.Trim())).Page(page, limit).ToList().Select(x => new CommonCodeValue
// {
// Code = x.Code,
// Value = x.EnName,
// }).Distinct().ToList();
// return List;
//}
//}
//catch (Exception e)
//{
// throw;
//}
}
public List<CommonCodeValue> GetVessel(string strlink, int page, int limit)
@ -1260,5 +1267,41 @@ namespace djy.Service.AFR
await DbAMS.Insert(list).WithTransaction(tran).ExecuteAffrowsAsync();
}
}
public async Task<List<AFRAddrTemplate>> GetTemplate(string type, string name)
{
var data = await DbAMS.Select<AFRAddrTemplate>()
.WhereIf(!string.IsNullOrEmpty(type), t => t.Type == Convert.ToByte(type))
.WhereIf(!string.IsNullOrEmpty(name), t => t.Name.Contains(name))
.OrderByDescending(t=>t.CreateTime)
.ToListAsync();
return data;
}
public async Task SaveTemplate(AFRAddrTemplate input)
{
DateTime nowTime = DateTime.Now;
if (string.IsNullOrEmpty(input.GID))
{
input.GID = Guid.NewGuid().ToString();
input.LastUpdate = nowTime;
input.CreateTime = nowTime;
await DbAMS.Insert(input).ExecuteAffrowsAsync();
}
else
{
input.LastUpdate = nowTime;
await DbAMS.Update<AFRAddrTemplate>().SetSource(input).Where(t => t.GID == input.GID).ExecuteAffrowsAsync();
}
}
public async Task DeleteTemplate(string ids)
{
await DbAMS.Delete<AFRAddrTemplate>()
.Where(t => ids.Contains(t.GID))
.ExecuteAffrowsAsync();
}
}
}

@ -153,5 +153,38 @@ namespace djy_AfrApi.Controllers
{
return SuccessResp(DateTime.Now.ToString());
}
#region 模板
/// <summary>
/// 查询模板
/// </summary>
/// <param name="type">查询类型 1:发货人 2:收货人 3:通知人 空:查询所有</param>
/// <param name="name">模板名称</param>
[HttpGet("GetTemplate")]
public async Task<Response<List<AFRAddrTemplate>>> GetTemplate(string type, string name = null)
{
var data = await _afrService.GetTemplate(type, name);
return SuccessResp(data);
}
/// <summary>
/// 保存模板
/// </summary>
[HttpPost("SaveTemplate")]
public async Task<Response> SaveTemplate([FromBody] AFRAddrTemplate input)
{
await _afrService.SaveTemplate(input);
return SuccessResp();
}
/// <summary>
/// 删除模板
/// </summary>
/// <param name="ids">模板主键列表,使用,连接</param>
[HttpGet("DeleteTemplate")]
public async Task<Response> DeleteTemplate([Required] string ids)
{
await _afrService.DeleteTemplate(ids);
return SuccessResp();
}
#endregion
}
}

@ -158,9 +158,9 @@ namespace djy_AfrApi.Controllers.Common
/// <returns></returns>
[HttpGet("GetPort")]
[RedisCaching]
public Response<List<CommonCodeValue>> GetPort()
public Response<List<CommonMappiCode>> GetPort()
{
var result = new Response<List<CommonCodeValue>>();
var result = new Response<List<CommonMappiCode>>();
try
{
result.Result = ser.GetPort("", 0, 0);

@ -6,7 +6,7 @@
<Project>
<PropertyGroup>
<_PublishTargetUrl>D:\DJY\Code\djyweb_ams\web\djy_AfrApi\bin\Release\net5.0\publish-windows\</_PublishTargetUrl>
<History>True|2024-01-08T07:50:46.8011898Z;True|2024-01-05T17:51:52.2695558+08:00;True|2024-01-05T17:04:21.5306695+08:00;True|2024-01-05T16:48:05.1050469+08:00;True|2024-01-05T15:13:30.4657789+08:00;True|2024-01-05T15:00:49.5985418+08:00;True|2024-01-05T13:48:06.1634940+08:00;True|2024-01-05T11:59:09.7697688+08:00;True|2024-01-05T11:33:19.2093394+08:00;True|2024-01-05T11:27:31.2454199+08:00;True|2024-01-05T11:20:20.5464568+08:00;True|2024-01-04T18:36:38.8259124+08:00;True|2024-01-04T15:54:57.9348895+08:00;True|2024-01-04T15:44:34.6535493+08:00;False|2024-01-04T15:44:20.9673752+08:00;True|2024-01-04T11:14:33.4379160+08:00;True|2024-01-03T21:54:40.3579096+08:00;True|2024-01-03T21:52:09.6604718+08:00;True|2024-01-03T16:04:13.6208067+08:00;True|2024-01-03T15:07:08.9376581+08:00;True|2024-01-02T10:57:59.7067270+08:00;True|2024-01-02T10:28:44.8223638+08:00;True|2023-12-29T17:26:12.9612280+08:00;</History>
<History>True|2024-01-19T03:20:41.9920968Z;True|2024-01-08T15:50:46.8011898+08:00;True|2024-01-05T17:51:52.2695558+08:00;True|2024-01-05T17:04:21.5306695+08:00;True|2024-01-05T16:48:05.1050469+08:00;True|2024-01-05T15:13:30.4657789+08:00;True|2024-01-05T15:00:49.5985418+08:00;True|2024-01-05T13:48:06.1634940+08:00;True|2024-01-05T11:59:09.7697688+08:00;True|2024-01-05T11:33:19.2093394+08:00;True|2024-01-05T11:27:31.2454199+08:00;True|2024-01-05T11:20:20.5464568+08:00;True|2024-01-04T18:36:38.8259124+08:00;True|2024-01-04T15:54:57.9348895+08:00;True|2024-01-04T15:44:34.6535493+08:00;False|2024-01-04T15:44:20.9673752+08:00;True|2024-01-04T11:14:33.4379160+08:00;True|2024-01-03T21:54:40.3579096+08:00;True|2024-01-03T21:52:09.6604718+08:00;True|2024-01-03T16:04:13.6208067+08:00;True|2024-01-03T15:07:08.9376581+08:00;True|2024-01-02T10:57:59.7067270+08:00;True|2024-01-02T10:28:44.8223638+08:00;True|2023-12-29T17:26:12.9612280+08:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>
Loading…
Cancel
Save