update接口开发

This commit is contained in:
路 范
2021-09-22 17:04:44 +08:00
parent 6bd974588e
commit 7337c82f3b
26 changed files with 580 additions and 190 deletions

View File

@@ -7,6 +7,7 @@ using Furion.DataEncryption;
using Furion.FriendlyException;
using Furion.JsonSerialization;
using Furion.UnifyResult;
using ImageMagick;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.StaticFiles;
using Newtonsoft.Json.Linq;
@@ -32,6 +33,144 @@ namespace Ewide.NbzsZheliban.Service
db = repository.Context;
_jsonSerializer = jsonSerializer;
}
/// <summary>
/// 获取当前用户信息
/// </summary>
/// <returns></returns>
[HttpPost("/userinfo")]
[Microsoft.AspNetCore.Authorization.AllowAnonymous]
public dynamic GetUserInfo([FromBody] JObject args)
{
var ticket = args.GetJsonValue("ticket", isThrowExp: true);
var userinfoObj = GetInfoByTicket(ticket);
return new ZhelibanUserInfo
{
CardId = userinfoObj["idnum"].ToString(),
Name = userinfoObj["username"].ToString()
};
}
/// <summary>
/// 被征收人关联的项目列表
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
[HttpPost("/project/list")]
[Microsoft.AspNetCore.Authorization.AllowAnonymous]
public async Task<dynamic> PrjList([FromBody] JObject args)
{
var ticket = args.GetJsonValue("ticket", isThrowExp: true);
//var ticket = Request.Query["ticket"];
var userinfoObj = GetInfoByTicket(ticket);
var cardno = userinfoObj["idnum"].ToString();
var username = userinfoObj["username"].ToString();
//修改测试数据
db.Ado.ExecuteCommand("update InvestigateTable set ExpropriatedCardNo='" + cardno + "' where id ='FF010DD7-C938-46AC-85DD-FAF9DC128BFD' ");
return await GetInfoByCardNoAsync(cardno, username);
}
/// <summary>
/// 被征收人关联的项目列表
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
[HttpPost("/project/list2")]
[Microsoft.AspNetCore.Authorization.AllowAnonymous]
public async Task<dynamic> PrjList2([FromBody] JObject args)
{
var cardno = "341203199206303411";
var username = "张三丰";
return await GetInfoByCardNoAsync(cardno, username);
}
/// <summary>
/// 住宅调查表
/// </summary>
/// <param name="cardno"></param>
/// <returns></returns>
private async Task<List<Dcbs>> GetzzDcbsAsync(string cardno)
{
//住宅调查表
return await db.Ado.SqlQueryAsync<Dcbs>("select ID dcbId,ProjectId PrjId from InvestigateTable b where b.ExpropriatedCardNo=@ExpropriatedCardNo", new List<SugarParameter> { new SugarParameter("ExpropriatedCardNo", cardno, System.Data.DbType.String) }.ToArray());
}
/// <summary>
/// 非住宅调查表
/// </summary>
/// <param name="cardno"></param>
/// <returns></returns>
private async Task<List<Dcbs>> GetfzzDcbsAsync(string cardno)
{
//非住宅调查表
return await db.Ado.SqlQueryAsync<Dcbs>("select ID dcbId,ProjectId PrjId from NonResidentialInvestigateTable b where b.PropertyRightCardNo=@ExpropriatedCardNo", new List<SugarParameter> { new SugarParameter("ExpropriatedCardNo", cardno, System.Data.DbType.String) }.ToArray());
}
/// <summary>
/// 项目列表
/// </summary>
/// <param name="list_dcbs"></param>
/// <returns></returns>
private async Task<List<H5IndexPrjModel>> GetPrjListAsync(IEnumerable<Dcbs> list_dcbs)
{
//项目列表
return await db.Ado.SqlQueryAsync<H5IndexPrjModel>("select a.ID Prjid,a.area,a.AreaID,a.HouseAcquisitionDepartment as zsbm,a.CollectDecisionNo1 as year,(isnull(a.CollectDecisionNoHeadName,'')+'['+cast(a.CollectDecisionNo1 as varchar)+']'+ isnull(cast(a.CollectDecisionNo2 as varchar),'')+'号') zsjdh,dbo.get_current_state(a.ID) CurrentState,NAME,CreateRecordTime from Projects a where ID in ('" + string.Join("','", list_dcbs.Select(p => p.PrjId)) + "') ");
}
/// <summary>
/// 分户评估
/// </summary>
/// <param name="InvestigateTableID_param"></param>
/// <returns></returns>
private async Task<List<Fhpgs>> GetFHPGListAsync(string InvestigateTableID_param)
{
//分户评估
return await db.Ado.SqlQueryAsync<Fhpgs>("select d.id,e.ProjectId as PrjId ,d.AssessmentNo,e.HouseAddress,d.countValue,e.id dcbId,d.CreateTime,d.CreateUserName,1 type from InvestigateTable_Assessment d inner join InvestigateTable e on d.InvestigateTableId=e.ID where d.InvestigateTableID in ( " + InvestigateTableID_param + " ) union all select d.id,e.ProjectId as PrjId ,AssessmentNo, e.HouseAddress, d.countValue,e.id dcbId,d.CreateTime,d.CreateUserName,2 type from NonInvestigateTable_Assessment d inner join NonResidentialInvestigateTable e on d.NonInvestigateTableID = e.ID where d.NonInvestigateTableID in ( " + InvestigateTableID_param + " ) ;");
}
/// <summary>
/// 补偿协议
/// </summary>
/// <param name="InvestigateTableID_param"></param>
/// <returns></returns>
private async Task<List<Bcxy>> GetBCXYListAsync(string InvestigateTableID_param)
{
//补偿协议
return await db.Ado.SqlQueryAsync<Bcxy>("select d.id,isnull(d.CollectDecisionNoHeadName,'')+isnull(d.No1,'')+'-'+isnull(d.No2,'')+(case when (d.No3 is null or d.No3 = '') then '' else ('-'+d.No3) end ) XyNo,d.SwitchProductionWay,e.HouseAddress,d.SummationShouldCompensateMoney,e.ProjectId as PrjId,e.id dcbId,d.SignTime,1 type from ResidentialAgreement d inner join InvestigateTable e on d.InvestigateTableId=e.ID where d.InvestigateTableID in ( " + InvestigateTableID_param + " ) union all select d.id,isnull(d.CollectDecisionNoHeadName, '') + isnull(d.No2, '') + '-' + isnull(d.No3, '') XyNo , d.SwitchProductionWay, e.HouseAddress, d.SummationShouldCompensateMoney, e.ProjectId as PrjId,e.id dcbId,d.SignTime,2 type from NonResidentialAgreement d inner join NonResidentialInvestigateTable e on d.NonInvestigateTableID = e.ID where d.NonInvestigateTableID in ( " + InvestigateTableID_param + " ); ");
}
private async Task<H5IndexModel> GetInfoByCardNoAsync(string cardno, string username)
{
var list_zz_dcb = await GetzzDcbsAsync(cardno);
var list_fzz_dcb = await GetfzzDcbsAsync(cardno);
//调查表集合
var list_dcbs = list_zz_dcb.Concat(list_fzz_dcb);
var list_projects = await GetPrjListAsync(list_dcbs);
var InvestigateTableID_param = "'" + string.Join("','", list_dcbs.Select(p => p.dcbId)) + "'";
var list_fhpgs = await GetFHPGListAsync(InvestigateTableID_param);
var list_bcxys = await GetBCXYListAsync(InvestigateTableID_param);
var listAreas = new List<Guid?> { Guid.Parse("B2A0291C-84C7-4D86-A6D5-CB9FCCF4A2D8") };
list_projects.ForEach(p =>
{
p.FhpgList = list_fhpgs.Where(a => a.PrjId == p.PrjId).ToList();
var bcxy = list_bcxys.Where(a => a.PrjId == p.PrjId).ToList();
bcxy.ForEach(a => a.countValue = list_fhpgs.Where(b => b.dcbId == a.dcbId).First().countValue);
p.BcxyList = bcxy;
listAreas.Add(Guid.Parse(p.AreaID));
});
//政策
var list_PoliciesRegulations = await db.Queryable<Entity.PoliciesRegulations>().Where(a => listAreas.Contains(a.AreaID)).Select(b => new PoliciesRegulation
{
ID = b.ID,
Contents = b.Contents,
PublicTime = b.PublicTime,
Title = b.Title,
Area = b.Area
}).ToListAsync();
H5IndexModel h5IndexModel = new()
{
PrjList = list_projects,
IdCard = cardno,
UserName = username,
PoliciesRegulationsLists = new Entity.Extends.PoliciesRegulations { List = list_PoliciesRegulations, TotalCount = list_PoliciesRegulations.Count }
};
return h5IndexModel;
}
private JObject GetInfoByTicket(string ticket)
{
if (string.IsNullOrWhiteSpace(ticket))
@@ -103,79 +242,6 @@ namespace Ewide.NbzsZheliban.Service
return userinfoObj;
}
}
private async Task<H5IndexModel> GetInfoByCardNoAsync(string cardno, string username)
{
//var cardno = args.GetJsonValue("cardno", isThrowExp: true);
//住宅调查表
var list_zz_dcb = await db.Ado.SqlQueryAsync<Dcbs>("select ID dcbId,ProjectId PrjId from InvestigateTable b where b.ExpropriatedCardNo=@ExpropriatedCardNo", new List<SugarParameter> { new SugarParameter("ExpropriatedCardNo", cardno, System.Data.DbType.String) }.ToArray());
//非住宅调查表
var list_fzz_dcb = await db.Ado.SqlQueryAsync<Dcbs>("select ID dcbId,ProjectId PrjId from NonResidentialInvestigateTable b where b.PropertyRightCardNo=@ExpropriatedCardNo", new List<SugarParameter> { new SugarParameter("ExpropriatedCardNo", cardno, System.Data.DbType.String) }.ToArray());
//调查表集合
var list_dcbs = list_zz_dcb.Concat(list_fzz_dcb);
//项目列表
var list_projects = await db.Ado.SqlQueryAsync<H5IndexPrjModel>("select a.ID Prjid,a.area,a.AreaID,a.HouseAcquisitionDepartment as zsbm,a.CollectDecisionNo1 as year,(isnull(a.CollectDecisionNoHeadName,'')+'['+cast(a.CollectDecisionNo1 as varchar)+']'+ isnull(cast(a.CollectDecisionNo2 as varchar),'')+'号') zsjdh,dbo.get_current_state(a.ID) CurrentState,NAME from Projects a where ID in ('" + string.Join("','", list_dcbs.Select(p => p.PrjId)) + "') ");
//分户评估
var InvestigateTableID_param = "'" + string.Join("','", list_dcbs.Select(p => p.dcbId)) + "'";
var list_fhpgs = await db.Ado.SqlQueryAsync<Fhpgs>("select d.id,e.ProjectId as PrjId ,d.AssessmentNo,e.HouseAddress,d.countValue,e.id dcbId,d.CreateTime,d.CreateUserName from InvestigateTable_Assessment d inner join InvestigateTable e on d.InvestigateTableId=e.ID where d.InvestigateTableID in ( " + InvestigateTableID_param + " ) union all select d.id,e.ProjectId as PrjId ,AssessmentNo, e.HouseAddress, d.countValue,e.id dcbId,d.CreateTime,d.CreateUserName from NonInvestigateTable_Assessment d inner join NonResidentialInvestigateTable e on d.NonInvestigateTableID = e.ID where d.NonInvestigateTableID in ( " + InvestigateTableID_param + " ) ;");
//补偿协议
var list_bcxys = await db.Ado.SqlQueryAsync<Bcxy>("select d.id,isnull(d.CollectDecisionNoHeadName,'')+isnull(d.No1,'')+'-'+isnull(d.No2,'')+(case when (d.No3 is null or d.No3 = '') then '' else ('-'+d.No3) end ) XyNo,d.SwitchProductionWay,e.HouseAddress,d.SummationShouldCompensateMoney,e.ProjectId as PrjId,e.id dcbId,d.SignTime from ResidentialAgreement d inner join InvestigateTable e on d.InvestigateTableId=e.ID where d.InvestigateTableID in ( " + InvestigateTableID_param + " ) union all select d.id,isnull(d.CollectDecisionNoHeadName, '') + isnull(d.No2, '') + '-' + isnull(d.No3, '') XyNo , d.SwitchProductionWay, e.HouseAddress, d.SummationShouldCompensateMoney, e.ProjectId as PrjId,e.id dcbId,d.SignTime from NonResidentialAgreement d inner join NonResidentialInvestigateTable e on d.NonInvestigateTableID = e.ID where d.NonInvestigateTableID in ( " + InvestigateTableID_param + " ); ");
var listAreas = new List<Guid?> { Guid.Parse("B2A0291C-84C7-4D86-A6D5-CB9FCCF4A2D8") };
list_projects.ForEach(p =>
{
p.FhpgList = list_fhpgs.Where(a => a.PrjId == p.PrjId).ToList();
var bcxy = list_bcxys.Where(a => a.PrjId == p.PrjId).ToList();
bcxy.ForEach(a => a.countValue = list_fhpgs.Where(b => b.dcbId == a.dcbId).First().countValue);
p.BcxyList = bcxy;
listAreas.Add(Guid.Parse(p.AreaID));
});
//政策
var list_PoliciesRegulations = await db.Queryable<Entity.PoliciesRegulations>().Where(a => listAreas.Contains(a.AreaID)).Select(b => new PoliciesRegulation
{
ID = b.ID,
Contents = b.Contents,
PublicTime = b.PublicTime,
Title = b.Title,
Area = b.Area
}).ToListAsync();
H5IndexModel h5IndexModel = new()
{
PrjList = list_projects,
IdCard = cardno,
UserName = username,
PoliciesRegulationsLists = new Entity.Extends.PoliciesRegulations { List = list_PoliciesRegulations, TotalCount = list_PoliciesRegulations.Count }
};
return h5IndexModel;
}
/// <summary>
/// 被征收人关联的项目列表
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
[HttpPost("/project/list")]
[Microsoft.AspNetCore.Authorization.AllowAnonymous]
public async Task<dynamic> PrjList([FromBody] JObject args)
{
var ticket = args.GetJsonValue("ticket", isThrowExp: true);
//var ticket = Request.Query["ticket"];
var userinfoObj = GetInfoByTicket(ticket);
var cardno = userinfoObj["idnum"].ToString();
var username = userinfoObj["username"].ToString();
return await GetInfoByCardNoAsync(cardno, username);
}
/// <summary>
/// 被征收人关联的项目列表
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
[HttpPost("/project/list2")]
[Microsoft.AspNetCore.Authorization.AllowAnonymous]
public async Task<dynamic> PrjList2([FromBody] JObject args)
{
var cardno = "341203199206303411";
var username = "张三丰";
return await GetInfoByCardNoAsync(cardno, username);
}
/// <summary>
/// 政策详细
/// </summary>
@@ -198,14 +264,15 @@ namespace Ewide.NbzsZheliban.Service
}).FirstAsync();
return entity;
}
/// <summary>
/// 协议详细
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
[HttpPost("/agreement/info")]
[HttpPost("/agreement/info_s")]
[Microsoft.AspNetCore.Authorization.AllowAnonymous]
public async Task<dynamic> AgreementInfo([FromBody] JObject args)
public IActionResult AgreementInfoStream([FromBody] JObject args)
{
var ticket = args.GetJsonValue("ticket", isThrowExp: true);
var id = args.GetJsonGuidValue("id", isThrowExp: true);
@@ -230,44 +297,84 @@ namespace Ewide.NbzsZheliban.Service
}
if (string.IsNullOrEmpty(XyFile))
throw Oops.Oh("未上传附件");
var filePath = App.Configuration["nbzs_domain"] + XyFile;
return filePath;
var filePath = App.Configuration["nbzs_file_path"] + XyFile;
return new FileStreamResult(new FileStream(filePath, FileMode.Open), "application/octet-stream") { FileDownloadName = new FileInfo(filePath).Name };
}
/// <summary>
/// 协议详细
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
[HttpPost("/agreement/info_p")]
[Microsoft.AspNetCore.Authorization.AllowAnonymous]
public dynamic AgreementInfoPicture([FromBody] JObject args)
{
var ticket = args.GetJsonValue("ticket", isThrowExp: true);
var id = args.GetJsonGuidValue("id", isThrowExp: true);
JObject userInfoObj = GetInfoByTicket(ticket);
var XyFile = "";
//住宅
var entity_zz = db.Queryable<Entity.ResidentialAgreement>().Where(p => p.ID == id).Select(p => new { p.ID, p.XyFile }).First();
if (entity_zz != null)
{
XyFile = entity_zz.XyFile;
}
//非住宅
else
{
var entity_fzz = db.Queryable<Entity.NonResidentialAgreement>().Where(p => p.ID == id).Select(p => new { p.ID, p.XyFile }).First();
if (entity_fzz != null)
{
XyFile = entity_fzz.XyFile;
}
else
throw Oops.Oh("ID错误");
}
if (string.IsNullOrEmpty(XyFile))
throw Oops.Oh("未上传附件");
var pics = new List<string>();
var nbzs_file_path = App.Configuration["nbzs_file_path"];
var nbzs_domain = App.Configuration["nbzs_domain"];
var filePath = nbzs_file_path + XyFile;
var pdfFile = new FileInfo(filePath);
if (File.Exists(pdfFile.Directory + "\\lock"))
{
var picCount = pdfFile.Directory.GetFiles(pdfFile.Name + "-*.jpg").Length;
for (int i = 0; i < picCount; i++)
{
pics.Add(nbzs_domain + XyFile + "-" + i + ".jpg");
}
}
else
{
MagickReadSettings settings = new MagickReadSettings();
settings.Density = new Density(400, 400); //设置质量
using (MagickImageCollection images = new MagickImageCollection())
{
try
{
images.Read(filePath, settings);
for (int i = 0; i < images.Count; i++)
{
MagickImage image = (MagickImage)images[i];
image.Format = MagickFormat.Jpg;
var imagename = filePath + "-" + i + ".jpg";
image.Write(imagename);
pics.Add(nbzs_domain + XyFile + "-" + i + ".jpg");
if (i == 0)
{
File.WriteAllText(pdfFile.Directory.FullName + "\\lock", "lock");
}
}
}
catch (Exception ex)
{
throw Oops.Oh(ex.Message);
}
}
}
return new { pics, pdf = nbzs_domain + XyFile };
}
///// <summary>
///// 协议详细
///// </summary>
///// <param name="args"></param>
///// <returns></returns>
//[HttpPost("/agreement/info")]
//[Microsoft.AspNetCore.Authorization.AllowAnonymous]
//public IActionResult AgreementInfo([FromBody] JObject args)
//{
// var ticket = args.GetJsonValue("ticket", isThrowExp: true);
// var id = args.GetJsonGuidValue("id", isThrowExp: true);
// JObject userInfoObj = GetInfoByTicket(ticket);
// var XyFile = "";
// //住宅
// var entity_zz = db.Queryable<Entity.ResidentialAgreement>().Where(p => p.ID == id).Select(p => new { p.ID, p.XyFile }).First();
// if (entity_zz != null)
// {
// XyFile = entity_zz.XyFile;
// }
// //非住宅
// else
// {
// var entity_fzz = db.Queryable<Entity.NonResidentialAgreement>().Where(p => p.ID == id).Select(p => new { p.ID, p.XyFile }).First();
// if (entity_fzz != null)
// {
// XyFile = entity_fzz.XyFile;
// }
// else
// throw Oops.Oh("ID错误");
// }
// if (string.IsNullOrEmpty(XyFile))
// throw Oops.Oh("未上传附件");
// var filePath = App.Configuration["nbzs_file_path"] + XyFile;
// return new FileStreamResult(new FileStream(filePath, FileMode.Open), "application/octet-stream") { FileDownloadName = new FileInfo(filePath).Name };
//}
/// <summary>
/// 分布评估详细
/// </summary>
@@ -275,95 +382,98 @@ namespace Ewide.NbzsZheliban.Service
/// <returns></returns>
[HttpPost("/house_estimate/info")]
[Microsoft.AspNetCore.Authorization.AllowAnonymous]
public async Task<dynamic> HouseEstimateInfo([FromBody] JObject args)
public dynamic HouseEstimateInfo([FromBody] JObject args)
{
var ticket = args.GetJsonValue("ticket", isThrowExp: true);
var id = args.GetJsonGuidValue("id", isThrowExp: true);
var type = args.GetJsonIntValue("type", isThrowExp: true);
JObject userInfoObj = GetInfoByTicket(ticket);
var entity_zz = db.Queryable<Entity.InvestigateTable_Assessment>().Where(p => p.ID == id).First();
if (entity_zz != null)
//var cardno = userInfoObj["idnum"].ToString();
FHPG jzlrModel = null;
if (type == 1)
{
if (entity_zz.ValuationMethod == 0)
{
return null;
}
else
throw Oops.Oh(199, "请使用文件接口");
jzlrModel = db.Ado.SqlQuery<FHPG>("select a.ID,b.HouseAddress,a.ValuationMethod,a.AssessmentNo,a.HousingAssessmentValue,a.countValue,a.AttachedAssessedValue,a.DecorateAssessedValue,a.Remark,a.ExceedLandMoney,a.AtticAssessedValue,1 Type from InvestigateTable_Assessment a inner join InvestigateTable b on a.InvestigateTableID=b.ID where a.ID=@ID", new { ID = id }).FirstOrDefault();
}
else if (type == 2)
{
//非住宅
jzlrModel = db.Ado.SqlQuery<FHPG>("select b.HouseAddress,a.ValuationMethod,a.AssessmentNo,a.HousingAssessmentValue,a.countValue,a.AttachedAssessedValue,a.DecorateAssessedValue,a.Remark,a.ExceedLandMoney,2 Type from NonInvestigateTable_Assessment a inner join NonResidentialInvestigateTable b on a.NonInvestigateTableID=b.ID where a.ID=@ID", new { ID = id }).FirstOrDefault();
}
if (jzlrModel.ValuationMethod == 0)
{
return jzlrModel;
}
else
{
var entity_fzz = db.Queryable<Entity.NonInvestigateTable_Assessment>().Where(p => p.ID == id).First();
if (entity_fzz != null)
{
if (entity_fzz.ValuationMethod == 0)
{
return null;
}
else
throw Oops.Oh(199, "请使用文件接口");
}
else
throw Oops.Oh("ID错误");
return GetHouseEstimateFile(Guid.Parse(jzlrModel.Id), jzlrModel.Type, jzlrModel.ValuationMethod);
}
}
/// <summary>
/// 分布评估详细
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
[HttpPost("/house_estimate/file")]
[Microsoft.AspNetCore.Authorization.AllowAnonymous]
public IActionResult HouseEstimateInfoFile([FromBody] JObject args)
private dynamic GetHouseEstimateFile(Guid id, int type, int ValuationMethod)
{
var ticket = args.GetJsonValue("ticket", isThrowExp: true);
var id = args.GetJsonGuidValue("id", isThrowExp: true);
JObject userInfoObj = GetInfoByTicket(ticket);
var entity_zz = db.Queryable<Entity.InvestigateTable_Assessment>().Where(p => p.ID == id).First();
if (entity_zz != null)
var fileUrl = "";
if (type == 1)
{
switch (entity_zz.ValuationMethod)
//住宅
var entity_zz = db.Queryable<Entity.InvestigateTable_Assessment>().Where(p => p.ID == id).Select(p => new { p.ID, p.File }).First();
if (entity_zz != null)
{
//pdf上传
case 1:
case 2:
if (!string.IsNullOrEmpty(entity_zz.File))
fileUrl = entity_zz.File;
}
}
else if (type == 2)
{
//非住宅
var entity_fzz = db.Queryable<Entity.NonInvestigateTable_Assessment>().Where(p => p.ID == id).Select(p => new { p.ID, p.File }).First();
if (entity_fzz != null)
{
fileUrl = entity_fzz.File;
}
}
if (string.IsNullOrEmpty(fileUrl))
throw Oops.Oh("未评估或未上传附件");
var pics = new List<string>();
var nbzs_file_path = App.Configuration["nbzs_file_path"];
var nbzs_domain = App.Configuration["nbzs_domain"];
var filePath = nbzs_file_path + fileUrl;
var pdfFile = new FileInfo(filePath);
if (File.Exists(pdfFile.Directory + "\\lock"))
{
var picCount = pdfFile.Directory.GetFiles(pdfFile.Name + "-*.jpg").Length;
for (int i = 0; i < picCount; i++)
{
pics.Add(nbzs_domain + fileUrl + "-" + i + ".jpg");
}
}
else
{
MagickReadSettings settings = new MagickReadSettings();
settings.Density = new Density(400, 400); //设置质量
using (MagickImageCollection images = new MagickImageCollection())
{
try
{
images.Read(filePath, settings);
for (int i = 0; i < images.Count; i++)
{
var filePath = App.Configuration["nbzs_file_path"] + entity_zz.File;
return new FileStreamResult(new FileStream(filePath, FileMode.Open), "application/octet-stream") { FileDownloadName = new FileInfo(filePath).Name };
}
else
throw Oops.Oh("未上传文件");
//金额录入
default:
throw Oops.Oh("无文件");
}
}
else
{
var entity_fzz = db.Queryable<Entity.NonInvestigateTable_Assessment>().Where(p => p.ID == id).First();
if (entity_fzz != null)
{
switch (entity_fzz.ValuationMethod)
{
//pdf上传
case 1:
if (!string.IsNullOrEmpty(entity_fzz.File))
MagickImage image = (MagickImage)images[i];
image.Format = MagickFormat.Jpg;
var imagename = filePath + "-" + i + ".jpg";
image.Write(imagename);
pics.Add(nbzs_domain + fileUrl + "-" + i + ".jpg");
if (i == 0)
{
var filePath = App.Configuration["nbzs_file_path"] + entity_fzz.File;
return new FileStreamResult(new FileStream(filePath, FileMode.Open), "application/octet-stream") { FileDownloadName = new FileInfo(filePath).Name };
File.WriteAllText(pdfFile.Directory.FullName + "\\lock", "lock");
}
else
throw Oops.Oh("未上传文件");
//金额录入
default:
throw Oops.Oh("无文件");
}
}
catch (Exception ex)
{
throw Oops.Oh(ex.Message);
}
}
else
throw Oops.Oh("ID错误");
}
throw Oops.Oh("出错了");
return new { ValuationMethod, pics, pdf = nbzs_domain + fileUrl };
}
}
}