Commit 3ff6093a authored by 吴春's avatar 吴春

提交代码

parent 3c95394c
using System;
using System.Collections.Generic;
using System.Text;
using Mall.Common.Plugin;
namespace Mall.Common.Enum.TradePavilion
{
/// <summary>
/// 品牌下载枚举列表
/// </summary>
public enum BusinessExportEnum
{
/// <summary>
/// 品牌分类
/// </summary>
[EnumField("品牌分类")]
ClassName = 1,
/// <summary>
/// 品牌全名
/// </summary>
[EnumField("品牌全名")]
FullBrandName = 2,
/// <summary>
/// 品牌名
/// </summary>
[EnumField("品牌名")]
BrandName = 3,
/// <summary>
/// 品牌视频
/// </summary>
[EnumField("品牌视频")]
VideoUrl = 4,
/// <summary>
/// 店铺数量
/// </summary>
[EnumField("店铺数量")]
ShopNum = 5,
/// <summary>
/// 建筑面积
/// </summary>
[EnumField("建筑面积")]
BuiltUpArea = 6,
/// <summary>
/// 需求面积
/// </summary>
[EnumField("需求面积")]
AreaRequirement = 7,
/// <summary>
/// 客群定位
/// </summary>
[EnumField("客群定位")]
CustomerType = 8,
/// <summary>
/// 品牌定位
/// </summary>
[EnumField("品牌定位")]
BrandType = 9,
/// <summary>
/// 拓店区域
/// </summary>
[EnumField("拓店区域")]
StoreExpansion = 10,
/// <summary>
/// 商铺性质
/// </summary>
[EnumField("商铺性质")]
ProjectType = 11,
/// <summary>
/// 店铺开口尺寸
/// </summary>
[EnumField("店铺开口尺寸")]
IsShopSize = 12,
/// <summary>
/// 燃气
/// </summary>
[EnumField("燃气")]
RanQi = 13,
/// <summary>
/// 排烟量
/// </summary>
[EnumField("排烟量")]
PaiYan = 14,
/// <summary>
/// 电量
/// </summary>
[EnumField("电量")]
IsDianLiang = 15,
/// <summary>
/// 上下水
/// </summary>
[EnumField("上下水")]
Plumbing = 16,
/// <summary>
/// 管径
/// </summary>
[EnumField("管径")]
Caliber = 17,
/// <summary>
/// 排污
/// </summary>
[EnumField("排污")]
Sewage = 18,
/// <summary>
/// 空调
/// </summary>
[EnumField("空调")]
KongTiao = 19,
/// <summary>
/// 新风
/// </summary>
[EnumField("新风")]
XinFeng = 20,
/// <summary>
/// 广告
/// </summary>
[EnumField("广告")]
Advertising = 21,
/// <summary>
/// 其他
/// </summary>
[EnumField("其他")]
Other = 22,
/// <summary>
/// Logo
/// </summary>
[EnumField("Logo")]
Logo = 23,
}
}
......@@ -3,7 +3,10 @@ using NPOI.HSSF.Util;
using NPOI.SS.UserModel;
using NPOI.SS.Util;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
namespace Mall.Common.Plugin
{
......@@ -19,7 +22,7 @@ namespace Mall.Common.Plugin
/// <param name="list">模板数据</param>
/// <param name="isTempLate">是否模板导出</param>
/// <param name="tempLatePath">模板文件路劲</param>
public static byte[] ToExcel(List<ExcelDataSource> list,bool isTempLate=false,string tempLatePath="")
public static byte[] ToExcel(List<ExcelDataSource> list, bool isTempLate = false, string tempLatePath = "")
{
HSSFWorkbook workbook = null;
HSSFSheet sheet = null;
......@@ -217,6 +220,9 @@ namespace Mall.Common.Plugin
}
}
/// <summary>
/// 模板导出
/// </summary>
......@@ -248,6 +254,7 @@ namespace Mall.Common.Plugin
//单元格样式
HSSFCellStyle fCellStyle = (HSSFCellStyle)workbook.CreateCellStyle();
//循环添加行
foreach (var item in list)
{
......@@ -264,6 +271,57 @@ namespace Mall.Common.Plugin
//循环添加列
foreach (var subItem in item.ExcelRows)
{
if (subItem.Pic == 1 && !string.IsNullOrWhiteSpace(subItem.Value))
{
HSSFPatriarch patriarch = (HSSFPatriarch)sheet.CreateDrawingPatriarch();
//System.Net.WebRequest request = System.Net.WebRequest.Create(subItem.Value);
//System.Net.WebResponse response = request.GetResponse();
//Stream responseStream = response.GetResponseStream();
try
{
//byte[] bytes = new byte[1024];
//int osize = responseStream.Read(bytes, 0, (int)bytes.Length);
//while (osize > 0)
//{
// responseStream.Write(bytes, 0, osize);
// osize = responseStream.Read(bytes, 0, (int)bytes.Length);//读取当前字节流的总长度
//}
//responseStream.Flush();
int pictureIdx = workbook.AddPicture(bytes, PictureType.JPEG);
// byte[] bytes = System.IO.File.ReadAllBytes(subItem.Value);
// int pictureIdx = workbook.AddPicture(bytes, PictureType.JPEG);
// 插图片的位置 HSSFClientAnchor(dx1,dy1,dx2,dy2,col1,row1,col2,row2) 后面再作解释
HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, columnsIndex, rowIndex, columnsIndex + 1, rowIndex + 1);
//把图片插到相应的位置
HSSFPicture pict = (HSSFPicture)patriarch.CreatePicture(anchor, pictureIdx);
}
finally
{
// 释放资源
//if (responseStream != null) responseStream.Close();
//if (response != null) { response.Close(); response.Dispose(); }
//if (request != null) { request.Abort(); }
}
// SetPic(workbook, patriarch, subItem.Value, sheet, rowIndex, columnsIndex);
}
else
{
var cell = dataRow.CreateCell(columnsIndex);
fCellStyle.WrapText = true;
......@@ -401,6 +459,8 @@ namespace Mall.Common.Plugin
}
cell.SetCellValue(subItem.Value == null ? "" : subItem.Value);
}
}
rowIndex++;
}
......@@ -414,6 +474,40 @@ namespace Mall.Common.Plugin
}
private static void SetPic(HSSFWorkbook workbook, HSSFPatriarch patriarch, string path, ISheet sheet, int rowline, int col)
{
try
{
if (string.IsNullOrEmpty(path)) return;
System.Net.WebRequest request = System.Net.WebRequest.Create(path);
System.Net.WebResponse response = request.GetResponse();
Stream responseStream = response.GetResponseStream();
int buffersize = 1024;
byte[] buffer = new byte[buffersize];
int count = responseStream.Read(buffer, 0, buffersize);
while (count > 0)
{
count = responseStream.Read(buffer, 0, buffersize);
}
int pictureIdx = workbook.AddPicture(buffer, PictureType.JPEG);
// byte[] bytes = System.IO.File.ReadAllBytes(path);
// int pictureIdx = workbook.AddPicture(bytes, PictureType.JPEG);
// 插图片的位置 HSSFClientAnchor(dx1,dy1,dx2,dy2,col1,row1,col2,row2) 后面再作解释
HSSFClientAnchor anchor = new HSSFClientAnchor(70, 10, 0, 0, col, rowline, col + 1, rowline + 1);
//把图片插到相应的位置
HSSFPicture pict = (HSSFPicture)patriarch.CreatePicture(anchor, pictureIdx);
}
catch (System.Exception ex)
{
return;
}
}
#region [颜色:16进制转成RGB]
/// <summary>
/// [颜色:16进制转成RGB]
......@@ -505,11 +599,13 @@ namespace Mall.Common.Plugin
/// <param name="colspan">跨列(默认一列,不跨列)</param>
/// <param name="rowspan">跨行(默认一行,不跨行)</param>
/// <param name="selfBgColorIndex">自定义单元格背景颜色(索引)</param>
public ExcelColumn(string value = "", int colspan = 1, int rowspan = 1, short selfBgColorIndex = 0)
/// <param name="isPic">0-不是图片,1-是图片</param>
public ExcelColumn(string value = "", int colspan = 1, int rowspan = 1, short selfBgColorIndex = 0, int isPic = 0)
{
this.Value = value;
this.Colspan = colspan;
this.Rowspan = rowspan;
this.Pic = isPic;
this.SelfBgColorIndex = selfBgColorIndex;
}
......@@ -580,6 +676,11 @@ namespace Mall.Common.Plugin
/// 字体大小
/// </summary>
public short FontSize { get; set; }
/// <summary>
/// 1-是图片
/// </summary>
public int Pic { get; set; }
}
/// <summary>
......
......@@ -27,5 +27,10 @@ namespace Mall.Model.Extend.TradePavilion
/// 收藏id
/// </summary>
public int CollectId { get; set; }
/// <summary>
/// 导出枚举ids
/// </summary>
public List<int> ExcelEnumIds { get; set; }
}
}
......@@ -137,6 +137,11 @@ WHERE 1=1
{
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.BrandClassId), query.BrandClassId);
}
if (query.ProjectType.HasValue && query.ProjectType > 0)
{
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.ProjectType), (int)query.ProjectType);
}
}
return Get<RB_Brand_Extend>(builder.ToString(), parameters).FirstOrDefault();
}
......@@ -167,10 +172,6 @@ WHERE 1=1
{
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.TenantId), query.TenantId);
}
if (query.ID > 0)
{
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.ID), query.ID);
}
if (query.MallBaseId > 0)
{
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.MallBaseId), query.MallBaseId);
......@@ -184,6 +185,44 @@ WHERE 1=1
{
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.BrandClassId), query.BrandClassId);
}
if (query.ProjectType.HasValue && query.ProjectType > 0)
{
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.ProjectType), (int)query.ProjectType);
}
if (query.RanQi > -1)
{
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.RanQi), query.RanQi);
}
if (query.KongTiao > -1)
{
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.KongTiao), query.KongTiao);
}
if (query.XinFeng > -1)
{
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.XinFeng), query.XinFeng);
}
if (query.Plumbing > -1)
{
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.Plumbing), query.Plumbing);
}
if (query.Caliber > -1)
{
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.Caliber), query.Caliber);
}
if (query.Sewage > -1)
{
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.Sewage), query.Sewage);
}
if (query.PaiYan > -1)
{
builder.AppendFormat(" AND a.{0}={1} ", nameof(RB_Brand_Extend.PaiYan), query.PaiYan);
}
if (!string.IsNullOrEmpty(query.DianLiang))
{
builder.AppendFormat(" AND a.{0} LIKE @DianLiang ", nameof(RB_Brand_Extend.DianLiang));
parameters.Add("DianLiang", "%" + query.DianLiang.Trim() + "%");
}
}
return Get<RB_Brand_Extend>(builder.ToString(), parameters).ToList();
}
......
......@@ -871,7 +871,8 @@ namespace Mall.WebApi.Controllers.TradePavilion
{
item.BannerList = JsonConvert.DeserializeObject<List<string>>(item.Banner);
}
else {
else
{
item.BannerList = new List<string>();
}
}
......@@ -1134,7 +1135,13 @@ namespace Mall.WebApi.Controllers.TradePavilion
};
query.MallBaseId = RequestParm.MallBaseId;
query.TenantId = RequestParm.TenantId;
query.RanQi = -1;
query.KongTiao = -1;
query.XinFeng = -1;
query.Plumbing = -1;
query.Caliber = -1;
query.PaiYan = -1;
query.Sewage = -1;
var extModel = carrierModule.GetBrand(query);
if (!string.IsNullOrWhiteSpace(extModel.Banner))
......@@ -1171,6 +1178,9 @@ namespace Mall.WebApi.Controllers.TradePavilion
var list = carrierModule.GetBrandClassList(query);
return ApiResult.Success(data: list);
}
#endregion
#region 关注
......@@ -1186,9 +1196,9 @@ namespace Mall.WebApi.Controllers.TradePavilion
JObject jobj = JObject.Parse(RequestParm.msg.ToString());
var query = new RB_Collect_Extend()
{
Id=jobj.GetInt("Id"),
Type=jobj.GetInt("Type"),
SourceId=jobj.GetInt("SourceId"),
Id = jobj.GetInt("Id"),
Type = jobj.GetInt("Type"),
SourceId = jobj.GetInt("SourceId"),
};
query.TenantId = userInfo.TenantId;
query.MallBaseId = userInfo.MallBaseId;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment