using NPOI.HPSF;
using OASystem.API.OAMethodLib;
using OASystem.Domain.Dtos.Resource;
using OASystem.Domain.Entities.Groups;
using OASystem.Infrastructure.Repositories.Groups;
using Org.BouncyCastle.Utilities;
using Quartz.Util;
using System.Collections.Generic;
using System.Net.Http.Headers;
namespace OASystem.API.Controllers
{
///
/// 资料相关
///
//[Authorize]
[Route("api/[controller]/[action]")]
public class ResourceController : ControllerBase
{
private readonly IMapper _mapper;
private readonly SqlSugarClient _sqlSugar;
private readonly IConfiguration _config;
private readonly CarDataRepository _carDataRep;
private readonly LocalGuideDataRepository _localGuideDataRep;
private readonly ThreeCodeRepository _ThreeCodeRep;
private readonly HotelDataRepository _hotelDataRep;
private readonly ResItemInfoRepository _resItemInfoRep;
private readonly SetDataRepository _setDataRepository;
private readonly CountryFeeRepository _countryFeeRep;
private readonly SetDataTypeRepository _setDataTypeRep;
private readonly AirTicketAgentRepository _airTicketAgentRep;
private readonly InvitationOfficialActivityDataRepository _InvitationOfficialActivityDataRep;
private readonly OfficialActivitiesRepository _officialActivitiesRep;
private readonly AskDataRepository _askDataRep;
private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
public ResourceController(IMapper mapper, IConfiguration config, SqlSugarClient sqlSugar, CarDataRepository carDataRep,LocalGuideDataRepository localGuideDataRep,
ThreeCodeRepository threeCodeRep,HotelDataRepository hotelDataRep, ResItemInfoRepository resItemInfoRep, SetDataRepository setDataRepository,
CountryFeeRepository countryFeeRep, SetDataTypeRepository setDataTypeRep, AirTicketAgentRepository airTicketAgentRep,
InvitationOfficialActivityDataRepository invitationOfficialActivityDataRep, OfficialActivitiesRepository officialActivitiesRep, AskDataRepository askDataRep,
TicketBlackCodeRepository ticketBlackCodeRep)
{
_mapper = mapper;
_config = config;
_sqlSugar = sqlSugar;
_carDataRep = carDataRep;
_localGuideDataRep = localGuideDataRep;
_ThreeCodeRep = threeCodeRep;
_hotelDataRep = hotelDataRep;
_resItemInfoRep = resItemInfoRep;
_setDataRepository = setDataRepository;
_countryFeeRep = countryFeeRep;
_setDataTypeRep = setDataTypeRep;
_airTicketAgentRep = airTicketAgentRep;
_InvitationOfficialActivityDataRep = invitationOfficialActivityDataRep;
_officialActivitiesRep = officialActivitiesRep;
_askDataRep = askDataRep;
_ticketBlackCodeRep=ticketBlackCodeRep;
}
#region 车公司资料板块
///
/// 车公司信息查询
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task QueryCarData(QueryCarDataDto dto)
{
try
{
Result LocalGuide = await _carDataRep.QueryCarData(dto);
if (LocalGuide.Code == 0)
{
return Ok(JsonView(true, "查询成功", LocalGuide.Data));
}
else
{
return Ok(JsonView(false, LocalGuide.Msg));
}
}
catch (Exception)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 车公司资料下拉框数据
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task QueryCarSelect()
{
try
{
var CarData = _carDataRep.QueryDto().ToList();
if (CarData.Count == 0)
{
return Ok(JsonView(false, "暂无数据!"));
}
CarData.Add(new CarDataSelectView { Id = 0, UnitArea = "全部" });
CarData = CarData.Where((x, i) => CarData.FindIndex(z => z.UnitArea == x.UnitArea) == i).ToList();
CarData = CarData.OrderBy(x => x.Id).ToList();
List data = new List();
foreach (CarDataSelectView car in CarData)
{
if (!string.IsNullOrWhiteSpace(car.UnitArea))
{
data.Add(car);
}
}
return Ok(JsonView(true, "查询成功", data));
}
catch (Exception)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 车公司信息添加
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task AddCarData(AddCarDataDto dto)
{
try
{
if (dto.UnitArea == "")
{
return Ok(JsonView(false, "请检查单位区域是否填写!"));
}
if (dto.UnitName == "")
{
return Ok(JsonView(false, "请检查单位名称是否填写!"));
}
if (dto.Contact == "")
{
return Ok(JsonView(false, "请检查单位联系人是否填写!"));
}
if (dto.ContactTel == "")
{
return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
}
var carDada = _carDataRep.QueryDto(a => a.UnitArea == dto.UnitArea && a.UnitName == dto.UnitName && a.Contact == dto.Contact && a.ContactTel == dto.ContactTel).ToList();
if (carDada.Count != 0)
{
return Ok(JsonView(false, "该信息已存在,请勿重复添加!"));
}
Res_CarData _CarData = _mapper.Map(dto);
int id = await _carDataRep.AddAsyncReturnId(_CarData);
if (id == 0)
{
return Ok(JsonView(false, "添加失败!"));
}
return Ok(JsonView(true, "添加成功", new { Id = id }));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 车公司信息修改
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task UpCarData(UpCarDataDto dto)
{
try
{
if (dto.UnitArea == "")
{
return Ok(JsonView(false, "请检查单位区域是否填写!"));
}
if (dto.UnitName == "")
{
return Ok(JsonView(false, "请检查单位名称是否填写!"));
}
if (dto.Contact == "")
{
return Ok(JsonView(false, "请检查单位联系人是否填写!"));
}
if (dto.ContactTel == "")
{
return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
}
bool res = await _carDataRep.UpdateAsync(a => a.Id == dto.Id, a => new Res_CarData
{
UnitArea = dto.UnitArea,
UnitName = dto.UnitName,
Address = dto.Address,
Contact = dto.Contact,
ContactTel = dto.ContactTel,
ContactEmail = dto.ContactEmail,
ContactFax = dto.ContactFax,
CarDes = dto.CarDes,
CarPicPaths = dto.CarPicPaths,
OtherInfo = dto.OtherInfo,
Score = dto.Score,
QualificationScore = dto.QualificationScore,
CarAgeScore = dto.CarAgeScore,
CleanImgScore = dto.CleanImgScore,
SmellScore = dto.SmellScore,
WaterPaperScore = dto.WaterPaperScore,
HardwareScore = dto.HardwareScore,
TimeScore = dto.TimeScore,
SafetyScore = dto.SafetyScore,
DrivingAgeScore = dto.DrivingAgeScore,
Remark = dto.Remark,
});
if (!res) { return Ok(JsonView(false, "修改失败!")); }
return Ok(JsonView(true, "修改成功"));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 车公司信息删除
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task DelCarData(DelCarDataDto dto)
{
try
{
bool res = await _carDataRep.SoftDeleteByIdAsync(dto.Id.ToString(), dto.DeleteUserId);
if (!res) { return Ok(JsonView(false, "删除失败!")); }
return Ok(JsonView(true, "删除成功"));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
#endregion
#region 导游地接资料板块
///
/// 导游地接资料查询
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task QueryLocalGuide(QueryLocalGuide dto)
{
try
{
Result LocalGuide = await _localGuideDataRep.QueryLocalGuide(dto);
if (LocalGuide.Code == 0)
{
return Ok(JsonView(true, "查询成功", LocalGuide.Data));
}
else
{
return Ok(JsonView(false, LocalGuide.Msg));
}
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 导游地接资料下拉框数据
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task QueryLocalGuideSelect()
{
try
{
var LocalGuide = _carDataRep.QueryDto().ToList();
if (LocalGuide.Count == 0)
{
return Ok(JsonView(false, "暂无数据!"));
}
LocalGuide.Add(new QueryLocalGuideSelectView { Id = 0, UnitArea = "全部" });
LocalGuide = LocalGuide.Where((x, i) => LocalGuide.FindIndex(z => z.UnitArea == x.UnitArea && z.UnitArea != "") == i).ToList();
LocalGuide = LocalGuide.OrderBy(x => x.Id).ToList();
List data = new List();
foreach (QueryLocalGuideSelectView Local in LocalGuide)
{
if (!string.IsNullOrWhiteSpace(Local.UnitArea))
{
data.Add(Local);
}
}
return Ok(JsonView(true, "查询成功", data));
}
catch (Exception)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 导游地接信息操作(Status:1.新增,2.修改)
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task OperationLocalGuide(LocalGuideOperationDto dto)
{
try
{
if (dto.UnitArea == "")
{
return Ok(JsonView(false, "请检查单位区域是否填写!"));
}
if (dto.UnitName == "")
{
return Ok(JsonView(false, "请检查单位名称是否填写!"));
}
if (dto.Contact == "")
{
return Ok(JsonView(false, "请检查单位联系人是否填写!"));
}
if (dto.ContactTel == "")
{
return Ok(JsonView(false, "请检查联系方式是否填写正确!"));
}
Result result = await _localGuideDataRep.LocalGuideOperation(dto);
if (result.Code != 0)
{
return Ok(JsonView(false, result.Msg));
}
return Ok(JsonView(true, result.Msg));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 导游地接信息操作(删除)
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task DelLocalGuide(LocalGuideDelDto dto)
{
try
{
var res = await _localGuideDataRep.SoftDeleteByIdAsync(dto.Id.ToString(), dto.DeleteUserId);
if (!res)
{
return Ok(JsonView(false, "删除失败"));
}
return Ok(JsonView(true, "删除成功!"));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
#endregion
#region 机场三字码信息
///
/// 机场三字码查询
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task QueryThreeCode(QueryThreeCodeDto dto)
{
try
{
Result LocalGuide = await _ThreeCodeRep.QueryThreeCode(dto);
if (LocalGuide.Code == 0)
{
return Ok(JsonView(true, "查询成功", LocalGuide.Data));
}
else
{
return Ok(JsonView(false, LocalGuide.Msg));
}
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 机场三字码数据城市下拉框数据
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task QueryThreeCodeSelect()
{
try
{
var ThreeCode = _carDataRep.QueryDto().ToList();
if (ThreeCode.Count == 0)
{
return Ok(JsonView(false, "暂无数据!"));
}
ThreeCode.Add(new ThreeCodeSelectView { Id = 0, City = "全部" });
ThreeCode = ThreeCode.Where((x, i) => ThreeCode.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
ThreeCode = ThreeCode.OrderBy(x => x.Id).ToList();
List data = new List();
foreach (ThreeCodeSelectView _ThreeCode in ThreeCode)
{
if (!string.IsNullOrWhiteSpace(_ThreeCode.City))
{
data.Add(_ThreeCode);
}
}
return Ok(JsonView(true, "查询成功", data));
}
catch (Exception)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 机场三字码资料操作(Status:1.新增,2.修改)
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task OperationThreeCode(ThreeCodeOperationDto dto)
{
try
{
if (dto.Three == "")
{
return Ok(JsonView(false, "请检查三字码是否填写!"));
}
if (dto.Country == "")
{
return Ok(JsonView(false, "请检查国家是否填写!"));
}
if (dto.City == "")
{
return Ok(JsonView(false, "请检查城市是否填写正确!"));
}
if (dto.AirPort == "")
{
return Ok(JsonView(false, "请检查机场是否填写正确!"));
}
Result result = await _ThreeCodeRep.ThreeCodeOperation(dto);
if (result.Code != 0)
{
return Ok(JsonView(false, result.Msg));
}
return Ok(JsonView(true, result.Msg));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 机场三字码资料操作(删除)
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task DelThreeCode(ThreeCodeDelDto dto)
{
try
{
var res = await _ThreeCodeRep.SoftDeleteByIdAsync(dto.Id.ToString(), dto.DeleteUserId);
if (!res)
{
return Ok(JsonView(false, "删除失败"));
}
return Ok(JsonView(true, "删除成功!"));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
#endregion
#region 代理出票合作方资料
///
/// 代理出票合作方资料
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task QueryAirTicketAgent(DtoBase dto)
{
try
{
List res_AirTicketAgents = _airTicketAgentRep.Query(a => a.IsDel == 0).ToList();
if (res_AirTicketAgents.Count != 0)
{
res_AirTicketAgents = res_AirTicketAgents.OrderByDescending(a => a.CreateTime).ToList();
if (dto.PageSize == 0 && dto.PageIndex == 0)
{
return Ok(JsonView(true, "查询成功!", res_AirTicketAgents));
}
else
{
int count = res_AirTicketAgents.Count;
float totalPage = (float)count / dto.PageSize;//总页数
if (totalPage == 0) totalPage = 1;
else totalPage = (int)Math.Ceiling((double)totalPage);
List _AirTicketAgent = new List();
for (int i = 0; i < dto.PageSize; i++)
{
var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
if (RowIndex < res_AirTicketAgents.Count)
{
_AirTicketAgent.Add(res_AirTicketAgents[RowIndex]);
}
else
{
break;
}
}
return Ok(JsonView(true, "查询成功!", new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = _AirTicketAgent }));
}
}
else
{
return Ok(JsonView(false, "暂无数据!"));
}
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 代理出票合作方资料操作(Status:1.新增,2.修改)
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task OpAirTicketAgent(OpAirTicketAgentDto dto)
{
try
{
if (dto.Account == "")
{
return Ok(JsonView(false, "请检查代理商账户是否填写!"));
}
if (dto.Bank == "")
{
return Ok(JsonView(false, "请检查代理商银行是否填写!"));
}
if (dto.Name == "")
{
return Ok(JsonView(false, "请检查代理商名称是否填写正确!"));
}
Result result = await _airTicketAgentRep.OpAirTicketAgent(dto);
if (result.Code != 0)
{
return Ok(JsonView(false, result.Msg));
}
return Ok(JsonView(true, result.Msg));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 代理出票合作方资料操作(删除)
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task DelAirTicketAgent(DelBaseDto dto)
{
try
{
var res = await _airTicketAgentRep.SoftDeleteByIdAsync(dto.Id.ToString(), dto.DeleteUserId);
if (!res)
{
return Ok(JsonView(false, "删除失败"));
}
return Ok(JsonView(true, "删除成功!"));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
#endregion
#region 酒店资料数据
///
/// 酒店信息查询
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task QueryHotelData(QueryHotelDataDto dto)
{
try
{
Result hotelData = await _hotelDataRep.QueryHotelData(dto);
if (hotelData.Code == 0)
{
return Ok(JsonView(true, "查询成功", hotelData.Data));
}
else
{
return Ok(JsonView(false, hotelData.Msg));
}
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 酒店资料下拉框数据
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task QueryHotelDataSelect()
{
try
{
var HotelData = _carDataRep.QueryDto().ToList();
if (HotelData.Count == 0)
{
return Ok(JsonView(false, "暂无数据!"));
}
HotelData.Add(new QueryHotelDataSelect { Id = 0, City = "全部" });
HotelData = HotelData.Where((x, i) => HotelData.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
HotelData = HotelData.OrderBy(x => x.Id).ToList();
List data = new List();
foreach (QueryHotelDataSelect Hotel in HotelData)
{
if (!string.IsNullOrWhiteSpace(Hotel.City))
{
data.Add(Hotel);
}
}
return Ok(JsonView(true, "查询成功", data));
}
catch (Exception)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 酒店资料操作(Status:1.新增,2.修改)
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task OperationHotelData(OperationHotelDto dto)
{
try
{
if (dto.City == "")
{
return Ok(JsonView(false, "请检查酒店所在城市是否填写!"));
}
if (dto.Name == "")
{
return Ok(JsonView(false, "请检查酒店名称是否填写!"));
}
if (dto.Address == "")
{
return Ok(JsonView(false, "请检查酒店地址是否填写正确!"));
}
if (dto.Tel == "")
{
return Ok(JsonView(false, "请检查酒店联系方式是否填写正确!"));
}
Result result = await _hotelDataRep.OperationHotelData(dto);
if (result.Code != 0)
{
return Ok(JsonView(false, result.Msg));
}
return Ok(JsonView(true, result.Msg));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 酒店资料操作(删除)
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task DelHotelData(DelHotelDataDto dto)
{
try
{
var res = await _hotelDataRep.SoftDeleteByIdAsync(dto.Id.ToString(), dto.DeleteUserId);
if (!res)
{
return Ok(JsonView(false, "删除失败"));
}
return Ok(JsonView(true, "删除成功!"));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
#endregion
#region 签证费用资料
///
/// 签证费用资料查询
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task QueryCountryFeeCost(DtoBase dto)
{
try
{
if (dto.PortType == 1)
{
var CountryFee = _countryFeeRep.QueryDto().ToList();
if (CountryFee.Count == 0)
{
return Ok(JsonView(false, "暂无数据!"));
}
CountryFee = CountryFee.OrderByDescending(s => s.CreateTime).ToList();
return Ok(JsonView(true, "查询成功", CountryFee));
}
else if (dto.PortType == 2)
{
var CountryFee = _countryFeeRep.QueryDto().ToList();
if (CountryFee.Count == 0)
{
return Ok(JsonView(false, "暂无数据!"));
}
CountryFee = CountryFee.OrderByDescending(s => s.CreateTime).ToList();
return Ok(JsonView(true, "查询成功", CountryFee));
}
else
{
return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
}
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 签证费用资料操作(Status:1.新增,2.修改)
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task OperationCountryFeeCost(OperationCountryFeeCostDto dto)
{
try
{
if (dto.VisaContinent == "")
{
return Ok(JsonView(false, "请检查州名是否填写!"));
}
if (dto.VisaCountry == "")
{
return Ok(JsonView(false, "请检查国家名是否填写!"));
}
if (dto.VisaTime == "1")
{
return Ok(JsonView(false, "请检一般签证时间是否填写正确!"));
}
if (dto.UrgentTime == "1")
{
return Ok(JsonView(false, "请检加急时间是否填写正确!"));
}
if (dto.VisaPrice == 0)
{
return Ok(JsonView(false, "请检查签证费用是否填写正确,小数点后可1到2位!"));
}
if (dto.VisaPrice == 1)
{
return Ok(JsonView(false, "请检查签证加急费用是否填写正确,小数点后可1到2位!"));
}
Result result = await _countryFeeRep.OperationCountryFeeCost(dto);
if (result.Code != 0)
{
return Ok(JsonView(false, result.Msg));
}
return Ok(JsonView(true, result.Msg));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 签证费用资料操作(删除)
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task DelCountryFeeCost(DelCountryFeeCostDto dto)
{
try
{
var res = await _countryFeeRep.SoftDeleteByIdAsync(dto.Id.ToString(), dto.DeleteUserId);
if (!res)
{
return Ok(JsonView(false, "删除失败"));
}
return Ok(JsonView(true, "删除成功!"));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
#endregion
#region 物料信息、供应商维护
#region 供应商
///
/// 物料供应商查询
///
/// Json序列化
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task PostSearchItemVendor(JsonDtoBase _jsonDto)
{
if (string.IsNullOrEmpty(_jsonDto.Paras))
{
return Ok(JsonView(false, "参数为空"));
}
Search_ResItemVendorDto _ItemVendorDto = System.Text.Json.JsonSerializer.Deserialize(_jsonDto.Paras);
if (_ItemVendorDto != null)
{
if (_ItemVendorDto.SearchType == 2) //获取列表
{
Res_ItemVendorListView rstList = _resItemInfoRep.GetVendorList(_ItemVendorDto);
return Ok(rstList);
}
else
{
Res_ItemVendorView rstInfo = _resItemInfoRep.getVendorInfo(_ItemVendorDto);
return Ok(rstInfo);
}
}
else
{
return Ok(JsonView(false, "参数反序列化失败"));
}
return Ok(JsonView(false));
}
///
/// 创建/编辑/删除供应商信息
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task PostEditItemVendor(Edit_ResItemVendorDto _dto)
{
bool rst = false;
if (_dto.EditType >= 0)
{
if (string.IsNullOrEmpty(_dto.VendorFullName))
{
return Ok(JsonView(false, "全称未填写"));
}
if (string.IsNullOrEmpty(_dto.VendorLinker))
{
return Ok(JsonView(false, "联系人未填写"));
}
if (string.IsNullOrEmpty(_dto.VendorMobile))
{
return Ok(JsonView(false, "联系人手机号未填写"));
}
if (string.IsNullOrEmpty(_dto.BusRange))
{
return Ok(JsonView(false, "经营范围未选择"));
}
if (_dto.EditType == 0)
{
var checkEmpty = _resItemInfoRep.Query(s => s.FullName == _dto.VendorFullName).First();
if (checkEmpty != null)
{
return Ok(JsonView(false, "已存在同名供应商"));
}
rst = await _resItemInfoRep.addVendorInfo(_dto);
}
else if (_dto.EditType == 1)
{
if (_dto.VendorId > 0)
{
Res_ItemVendor _entity = _mapper.Map(_dto);
rst = await _resItemInfoRep.updVendorInfo(_entity);
}
else
{
return Ok(JsonView(false, "供应商不存在"));
}
}
}
else
{
if (_dto.VendorId < 1 || _dto.SysUserId < 1)
{
return Ok(JsonView(false, "用户Id或供应商Id不存在"));
}
Res_ItemVendor _entity = _mapper.Map(_dto);
rst = await _resItemInfoRep.delVendorInfo(_entity);
}
return Ok(JsonView(rst));
}
#endregion
#region 物料信息
///
/// 物料信息查询
///
/// Json序列化
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task PostSearchItemInfo(string paras)
{
if (string.IsNullOrEmpty(paras))
{
return Ok(JsonView(false, "参数为空"));
}
Search_ItemInfoDto _ItemInfoDto = System.Text.Json.JsonSerializer.Deserialize(paras);
if (_ItemInfoDto != null)
{
if (_ItemInfoDto.SearchType == 2) //获取列表
{
Res_ItemInfoListView rstList = _resItemInfoRep.GetItemList(_ItemInfoDto);
return Ok(rstList);
}
else
{
Res_ItemInfoView rstInfo = _resItemInfoRep.getItemInfo(_ItemInfoDto);
return Ok(rstInfo);
}
}
else
{
return Ok(JsonView(false, "参数反序列化失败"));
}
return Ok(JsonView(false));
}
///
/// 创建/编辑/删除物料信息
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task PostEditItemInfo(Edit_ResItemInfoDto _dto)
{
bool rst = false;
if (_dto.EditType >= 0)
{
if (_dto.VendorId < 1)
{
return Ok(JsonView(false, "未选择供应商"));
}
if (string.IsNullOrEmpty(_dto.ItemName))
{
return Ok(JsonView(false, "物料名称为空"));
}
if (_dto.ItemTypeId < 1)
{
return Ok(JsonView(false, "未选择物料类型"));
}
if (_dto.SysUserId < 1)
{
return Ok(JsonView(false, "当前操作用户Id为空"));
}
if (_dto.CurrRate <= 0)
{
return Ok(JsonView(false, "物料录入价格不能小于等于0"));
}
if (_dto.EditType == 0)
{
//判断物料名称、类型、供应商全部重复
var checkEmpty = _resItemInfoRep.Query(s => s.ItemName == _dto.ItemName && s.ItemTypeId == _dto.ItemTypeId && s.VendorId == _dto.VendorId).First();
if (checkEmpty != null)
{
return Ok(JsonView(false, "已存在重复物料信息"));
}
Res_ItemDetailInfo _entity = _mapper.Map(_dto);
DateTime dtNow = DateTime.Now;
_entity.CreateUserId = _dto.SysUserId;
_entity.IsDel = 0;
_entity.MaxRate = _dto.CurrRate;
_entity.MaxDt = dtNow;
_entity.CurrRate = _dto.CurrRate;
_entity.CurrDt = dtNow;
_entity.MinRate = _dto.CurrRate;
_entity.MinDt = dtNow;
rst = await _resItemInfoRep.AddAsync(_entity) > 0;
}
else if (_dto.EditType == 1)
{
if (_dto.ItemId > 0)
{
Res_ItemDetailInfo _entity = _mapper.Map(_dto);
_entity.Id = _dto.ItemId;
rst = await _resItemInfoRep.updItemInfo(_entity);
}
else
{
return Ok(JsonView(false, "供应商不存在"));
}
}
}
else
{
if (_dto.ItemId < 1 || _dto.SysUserId < 1)
{
return Ok(JsonView(false, "用户Id或物料信息Id不存在"));
}
Res_ItemDetailInfo _entity = _mapper.Map(_dto);
rst = await _resItemInfoRep.delItemInfo(_entity);
}
return Ok(JsonView(rst));
}
#endregion
#region 物料类型获取
#endregion
#endregion
#region 备忘录
///
/// 备忘录查询
///
/// Json序列化
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task PostSearchMemo(JsonDtoBase _jsonDto)
{
if (string.IsNullOrEmpty(_jsonDto.Paras))
{
return Ok(JsonView(false, "参数为空"));
}
Search_ResMemoDto _memoDto = JsonConvert.DeserializeObject(_jsonDto.Paras);
if (_memoDto != null)
{
if (_memoDto.SearchType == 2)
{
//获取列表
string sqlWhere = string.Format(" Where IsDel=0 ");
#region SqlWhere
if (!string.IsNullOrEmpty(_memoDto.Abstracts))
{
sqlWhere += string.Format(@" And m.Abstracts Like '%{0}%' ", _memoDto.Abstracts);
}
if (!string.IsNullOrEmpty(_memoDto.Title))
{
sqlWhere += string.Format(@" And m.Title Like '%{0}%' ", _memoDto.Title);
}
if (_memoDto.ReadLevel > 0)
{
sqlWhere += string.Format(@" And m.ReadLevel = {0} ", _memoDto.ReadLevel);
}
#endregion
int currPIndex = (((_memoDto.PageIndex > 0) ? (_memoDto.PageIndex - 1) : 0) * _memoDto.PageSize) + 1;
int currPSize = (((_memoDto.PageIndex > 0) ? (_memoDto.PageIndex - 1) : 0) + 1) * _memoDto.PageSize;
string sql = string.Format(@" Select * From(Select ROW_NUMBER() Over(order By m.Id desc) as RowNumber,
m.Id as MemoId,d.DepName as DepartmentName,m.ReadLevel,m.Title,m.Abstracts,
m.LastedEditDt,m.LastedEditorId
From Res_Memo as m With(Nolock) Inner Join Sys_Users as u With(Nolock) On m.CreateUserId=u.Id
Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id {2}
) as tb Where tb.RowNumber Between {0} And {1} ", currPIndex, currPSize, sqlWhere);
Res_MemoListView rst = new Res_MemoListView();
rst.CurrPageIndex = currPIndex;
rst.CurrPageSize = currPSize;
List dataSource = _carDataRep._sqlSugar.SqlQueryable(sql).ToList();
Dictionary userDic = new Dictionary();
foreach (var item in dataSource)
{
if (userDic.ContainsKey(item.LastedEditorId))
{
item.LastedEditor = userDic[item.LastedEditorId];
}
else
{
Sys_Users _sysUser = _carDataRep.Query(s => s.Id == item.LastedEditorId).First();
userDic[item.LastedEditorId] = _sysUser.CnName;
item.LastedEditor = _sysUser.CnName;
}
}
rst.DataList = new List(dataSource);
if (rst.DataList.Count > 0)
{
string sqlCount = string.Format(@" Select Id From Res_Memo as m With(Nolock) {0} ", sqlWhere);
int dataCount = _carDataRep._sqlSugar.SqlQueryable(sqlCount).Count();
rst.DataCount = dataCount;
}
return Ok(JsonView(rst));
}
else
{
//获取对象
string sqlSingle = string.Format(@" Select
m.Id as MemoId,d.DepName as DepartmentName,m.ReadLevel,m.Title,m.Abstracts,
m.LastedEditDt,m.LastedEditor,m.MDFilePath
From Res_Memo as m With(Nolock) Inner Join Sys_Users as u With(Nolock) On m.CreateUserId=u.Id
Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _memoDto.MemoId);
Res_MemoView _result = _carDataRep._sqlSugar.SqlQueryable(sqlSingle).First();
if (_result != null)
{
Sys_Users _sysUser = _carDataRep.Query(s => s.Id == _result.LastedEditorId).First();
_result.LastedEditor = _sysUser.CnName;
_result.MarkDownContent = new IOOperatorHelper().Read(_result.MDFilePath);
return Ok(JsonView(_result));
}
}
}
else
{
return Ok(JsonView(false, "参数反序列化失败"));
}
return Ok(JsonView(false));
}
///
/// 创建/编辑/删除备忘录信息
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task PostEditMemo(Edit_ResMemoDto _dto)
{
bool rst = false;
if (_dto.SysUserId < 1)
{
return Ok(JsonView(false, "操作人失效"));
}
Sys_Users _sysUser = _resItemInfoRep.Query(s => s.Id == _dto.SysUserId).First();
if (_sysUser == null)
{
return Ok(JsonView(false, "操作人失效02"));
}
if (_dto.EditType >= 0)
{
if (_dto.ReadLevel < 1)
{
return Ok(JsonView(false, "未知的阅读等级"));
}
if (string.IsNullOrEmpty(_dto.Title.Trim()))
{
return Ok(JsonView(false, "标题不能为空"));
}
if (string.IsNullOrEmpty(_dto.Content.Trim()))
{
return Ok(JsonView(false, "正文内容不能为空"));
}
//新增备忘录
DateTime dtNow = DateTime.Now;
string dir = AppSettingsHelper.Get("MemoCurrPath");
string fileName = dtNow.ToString("yyyyMMddHHmmss") + _dto.Title + ".md";
string content = JsonConvert.SerializeObject(_dto.Content);
if (_dto.EditType == 0)//新增
{
string savePath = new IOOperatorHelper().Write_CoverFile(content, dir, fileName);
if (savePath.Length > 0)
{
Res_MemoInfo _insert = new Res_MemoInfo();
_insert.Abstracts = _dto.Abstracts;
_insert.Title = _dto.Title;
_insert.DepartmentId = _sysUser.DepId;
_insert.CreateUserId = _sysUser.Id;
_insert.LastedEditDt = dtNow;
_insert.LastedEditor = _sysUser.Id;
_insert.MDFilePath = savePath;
_insert.ReadLevel = _dto.ReadLevel;
_insert.Title = _dto.Title;
int result = await _resItemInfoRep.AddAsync(_insert);
return Ok(JsonView(result > 0));
}
else
{
return Ok(JsonView(false, "路径保存失败"));
}
}
else//修改
{
if (_dto.MemoId < 1)
{
return Ok(JsonView(false, "MemoId不存在"));
}
Res_MemoInfo _source = _resItemInfoRep.Query(s => s.Id == _dto.MemoId).First();
if (_source == null)
{
return Ok(JsonView(false, "MemoInfo不存在"));
}
//修改
string sourcePath = _source.MDFilePath;
string recycDir = AppSettingsHelper.Get("MemoRecycleBinPath");
new IOOperatorHelper().MoveFile(sourcePath, recycDir);
string savePath = new IOOperatorHelper().Write_CoverFile(content, dir, fileName);
if (savePath.Length > 0)
{
var result = await _resItemInfoRep._sqlSugar.Updateable()
.SetColumns(it => it.LastedEditDt == DateTime.Now)
.SetColumns(it => it.LastedEditor == _sysUser.Id)
.SetColumns(it => it.Abstracts == _dto.Abstracts)
.SetColumns(it => it.MDFilePath == savePath)
.SetColumns(it => it.ReadLevel == _dto.ReadLevel)
.SetColumns(it => it.Title == _dto.Title)
.Where(s => s.Id == _source.Id)
.ExecuteCommandAsync();
return Ok(JsonView(result > 0));
}
}
}
else
{
//删除
if (_dto.MemoId < 1)
{
return Ok(JsonView(false, "MemoId不存在"));
}
Res_MemoInfo _source = _resItemInfoRep.Query(s => s.Id == _dto.MemoId).First();
if (_source == null)
{
return Ok(JsonView(false, "MemoInfo不存在"));
}
//修改
string sourcePath = _source.MDFilePath;
string recycDir = AppSettingsHelper.Get("MemoRecycleBinPath");
new IOOperatorHelper().MoveFile(sourcePath, recycDir);
var result = await _resItemInfoRep._sqlSugar.Updateable()
.SetColumns(it => it.IsDel == 1)
.SetColumns(it => it.DeleteUserId == _sysUser.Id)
.SetColumns(it => it.DeleteTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
.Where(s => s.Id == _source.Id)
.ExecuteCommandAsync();
return Ok(JsonView(result > 0));
}
return Ok(JsonView(rst));
}
#endregion
#region 商邀资料
///
/// 商邀资料查询
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task QueryInvitationOfficialActivityData(QueryInvitationOfficialActivityDataDto dto)
{
try
{
Result groupData = await _InvitationOfficialActivityDataRep.QueryInvitationOfficialActivityData(dto);
if (groupData.Code != 0)
{
return Ok(JsonView(false, groupData.Msg));
}
return Ok(JsonView(true, groupData.Msg, groupData.Data));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 根据商邀资料Id查询信息
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task QueryInvitationOfficialActivityById(QueryInvitationOfficialActivityByIdDto dto)
{
try
{
Result groupData = await _InvitationOfficialActivityDataRep.QueryInvitationOfficialActivityById(dto);
if (groupData.Code != 0)
{
return Ok(JsonView(false, groupData.Msg));
}
return Ok(JsonView(true, groupData.Msg, groupData.Data));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 商邀资料操作(Status:1.新增,2.修改)
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task OpInvitationOfficialActivity(OpInvitationOfficialActivityDto dto)
{
try
{
Result groupData = await _InvitationOfficialActivityDataRep.OpInvitationOfficialActivity(dto);
if (groupData.Code != 0)
{
return Ok(JsonView(false, groupData.Msg));
}
return Ok(JsonView(true, groupData.Msg, groupData.Data));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 删除商邀资料信息
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task DelInvitationOfficialActivity(DelBaseDto dto)
{
try
{
var res = await _InvitationOfficialActivityDataRep.SoftDeleteByIdAsync(dto.Id.ToString(), dto.DeleteUserId);
if (!res)
{
return Ok(JsonView(false, "删除失败"));
}
return Ok(JsonView(true, "删除成功!"));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
#endregion
#region 公务出访
///
/// 获取团组所有信息,绑定下拉框
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task GetGroupAllList(OfficialActivitiesByDiIdDto dto)
{
List _DelegationInfos = _sqlSugar.Queryable().Where(a => a.IsDel == 0).OrderBy(a => a.CreateTime, OrderByType.Desc).ToList();
List data = await _sqlSugar.Queryable().Where(a => a.IsDel == 0 && a.STid == 38).ToListAsync();
List _DeleFile = _sqlSugar.Queryable().Where(a => a.Diid == dto.DiId && a.IsDel == 0 && a.Category == 970).ToList();
return Ok(JsonView(true, "查询成功!", new { Delegation = _DelegationInfos, SetData = data, DeleFile = _DeleFile }));
}
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task QueryOfficialActivitiesByDiId(OfficialActivitiesByDiIdDto dto)
{
try
{
Result groupData = await _officialActivitiesRep.QueryOfficialActivitiesByDiId(dto);
if (groupData.Code != 0)
{
return Ok(JsonView(false, groupData.Msg));
}
return Ok(JsonView(true, groupData.Msg, groupData.Data));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 根据公务出访数据Id查询数据
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task QueryOfficialActivitiesById(OfficialActivitiesDiIdDto dto)
{
try
{
Result groupData = await _officialActivitiesRep.QueryOfficialActivitiesById(dto);
if (groupData.Code != 0)
{
return Ok(JsonView(false, groupData.Msg));
}
return Ok(JsonView(true, groupData.Msg, groupData.Data));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 公务出访操作(Status:1.新增,2.修改)
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task OpOfficialActivities(OpOfficialActivitiesDto dto)
{
try
{
Result groupData = await _officialActivitiesRep.OpOfficialActivities(dto);
if (groupData.Code != 0)
{
return Ok(JsonView(false, groupData.Msg));
}
return Ok(JsonView(true, groupData.Msg, groupData.Data));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 上传文件
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task UploadOfficialActivities(IFormFile file)
{
try
{
int Type = int.Parse(Request.Headers["Type"]);//1公务方简介,2公务活动图片,3发票
int DiId = int.Parse(Request.Headers["DiId"]);
int CreateUserId = int.Parse(Request.Headers["CreateUserId"]);
if (file != null)
{
var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
//文件名称
string projectFileName = file.FileName;
//上传的文件的路径
string filePath = "";
if (!Directory.Exists(fileDir))
{
Directory.CreateDirectory(fileDir);
}
//上传的文件的路径
filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
using (FileStream fs = System.IO.File.Create(filePath))
{
file.CopyTo(fs);
fs.Flush();
}
Grp_DeleFile d = new Grp_DeleFile();
d.Diid = DiId;
d.Category = 970;
if (Type == 1) d.Kind = 1;
else if (Type == 2) d.Kind = 2;
else if (Type == 3) d.Kind = 3;
d.FileName = projectFileName;
d.FilePath = "";
d.CreateUserId = CreateUserId;
int id = await _sqlSugar.Insertable(d).ExecuteReturnIdentityAsync();
return Ok(JsonView(true, "上传成功!", projectFileName));
}
else
{
return Ok(JsonView(false, "上传失败!"));
}
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 删除文件
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task DelloadOfficialActivities(DelBaseDto dto)
{
try
{
var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
Grp_DeleFile _DeleFile = await _sqlSugar.Queryable().FirstAsync(a => a.Id == dto.Id);
if (_DeleFile != null)
{
string fileName = _DeleFile.FileName;
string filePath = fileDir + "/团组增减款项相关文件/" + fileName;
// 删除该文件
System.IO.File.Delete(filePath);
int id = await _sqlSugar.Updateable().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DeleFile { IsDel = 1, DeleteUserId = dto.DeleteUserId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }).ExecuteCommandAsync();
return Ok(JsonView(true, "取消文件成功!"));
}
else
{
return Ok(JsonView(false, "取消文件失败!"));
}
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 删除公务出访信息
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task DelOfficialActivities(DelBaseDto dto)
{
try
{
var res = await _officialActivitiesRep.SoftDeleteByIdAsync(dto.Id.ToString(), dto.DeleteUserId);
if (!res)
{
return Ok(JsonView(false, "删除失败"));
}
return Ok(JsonView(true, "删除成功!"));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
#endregion
#region 请示数据库
///
/// 查询请示数据库初始化
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task QueryAskData(QueryAskDataDto dto)
{
try
{
Result groupData = await _askDataRep.QueryAskData(dto);
if (groupData.Code != 0)
{
return Ok(JsonView(false, groupData.Msg));
}
return Ok(JsonView(true, groupData.Msg, groupData.Data));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 根据Id查询请示数据库单挑数据
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task QueryAskDataById(QueryAskDataByIdDto dto)
{
try
{
Res_AskData _AskData = await _sqlSugar.Queryable().FirstAsync(a => a.IsDel == 0 && a.Id == dto.id);
if (_AskData==null)
{
return Ok(JsonView(true, "暂无数据!", _AskData));
}
return Ok(JsonView(true, "查询成功!", _AskData));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 请示数据库操作(Status:1.新增,2.修改)
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task OpAskData(OpAskDataDto dto)
{
try
{
Result groupData = await _askDataRep.OpAskData(dto);
if (groupData.Code != 0)
{
return Ok(JsonView(false, groupData.Msg));
}
return Ok(JsonView(true, groupData.Msg, groupData.Data));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 删除请示资料信息
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task DelAskData(DelBaseDto dto)
{
try
{
var res = await _askDataRep.SoftDeleteByIdAsync(dto.Id.ToString(), dto.DeleteUserId);
if (!res)
{
return Ok(JsonView(false, "删除失败"));
}
return Ok(JsonView(true, "删除成功!"));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 导出省外办请示
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task AskAdviceDerive(AskAdviceDerive dto)
{
try
{
string Air = "";//机票信息
string Area = "";//城市
string Area2 = "";//城市
string ClientName = "";//人员
string ClientName2 = "";//人员
int ClientNumber =0;//总人数
string Content = "";//行程安排
string CountryAndDay = "";//各个国家待的天数
string Destination = "";//此行目的
string Destination2 = "";//此行目的
string Duration = "";//出访时间
int Durationdays = 0;//出访天数
int Durationdays2 =0;//出访天数
string Official = "";//对谁的邀请
string Temp = "";//出访任务
string VisitDate = "";//出访日期,多少号到多少号
return Ok(JsonView(true, "导出成功!"));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 导出市外办请示
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task AskCityDerive(AskAdviceDerive dto)
{
try
{
return Ok(JsonView(true, "导出成功!"));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
#endregion
#region 机票黑屏代码
///
/// 根据团组Id查询黑屏代码列表
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task QueryTicketBlackCodeByDiId(QueryTicketBlackCodeByDiIdDto dto)
{
try
{
Result groupData = await _ticketBlackCodeRep.QueryTicketBlackCodeByDiId(dto);
if (groupData.Code != 0)
{
return Ok(JsonView(false, groupData.Msg));
}
return Ok(JsonView(true, groupData.Msg, groupData.Data));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 根据黑屏代码数据Id查询信息
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task QueryTicketBlackCodeById(QueryTicketBlackCodeByIdDto dto)
{
try
{
Result groupData = await _ticketBlackCodeRep.QueryTicketBlackCodeById(dto);
if (groupData.Code != 0)
{
return Ok(JsonView(false, groupData.Msg));
}
return Ok(JsonView(true, groupData.Msg, groupData.Data));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 黑屏代码操作(Status:1.新增,2.修改)
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task OpTicketBlackCode(OpTicketBlackCodeDto dto)
{
try
{
Result groupData = await _ticketBlackCodeRep.OpTicketBlackCode(dto);
if (groupData.Code != 0)
{
return Ok(JsonView(false, groupData.Msg));
}
return Ok(JsonView(true, groupData.Msg, groupData.Data));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
///
/// 删除黑屏代码
///
///
///
[HttpPost]
[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
public async Task DelTicketBlackCode(DelBaseDto dto)
{
try
{
var res = await _ticketBlackCodeRep.SoftDeleteByIdAsync(dto.Id.ToString(), dto.DeleteUserId);
if (!res)
{
return Ok(JsonView(false, "删除失败"));
}
return Ok(JsonView(true, "删除成功!"));
}
catch (Exception ex)
{
return Ok(JsonView(false, "程序错误!"));
throw;
}
}
#endregion
}
}