Pārlūkot izejas kodu

活动海报修改内容

shenhao 4 gadi atpakaļ
vecāks
revīzija
ea8d1694dd

+ 2 - 0
src/main/java/com/ssj/dao/sys/poster/dao/impl/PosterQueryDaoImpl.java

@@ -79,11 +79,13 @@ public class PosterQueryDaoImpl  implements PosterQueryDao {
         sb.append("   join poster_activity_join b on a.id = b.activity_id ");
         sb.append("   join poster_join t on b.join_id = t.id ");
         sb.append("  WHERE t.`status`=1    ");
+
         List<Object> param = new ArrayList<>();
         if(params.get("name")!=null && StringUtils.isNotEmpty(params.get("name").toString())) {
             sb.append(" and t.name like concat('%',?,'%')  ");
             param.add(params.get("name"));
         }
+        sb.append("  group by a.id   ");
         return dao.findMap(sb.toString(),param.toArray());
     }
 

+ 5 - 4
src/main/java/com/ssj/framework/weixin/util/ImgBean.java

@@ -32,13 +32,14 @@ public class ImgBean {
     /** 
      * 生成新图片到本地 
      */  
-    public static void writeImageLocal(String newImage, BufferedImage img) {  
-        if (newImage != null && img != null) {  
+    public static void writeImageLocal(String newImage, BufferedImage img) {
+        if (newImage != null && img != null) {
             try {  
             	String t_ext = newImage.substring(newImage.lastIndexOf(".") + 1);
-                File outputfile = new File(newImage);  
+                File outputfile = new File(newImage);
                 ImageIO.write(img, t_ext, outputfile);  
-            } catch (IOException e) {  
+            } catch (IOException e) {
+                e.printStackTrace();
             }  
         }  
     }  

+ 23 - 7
src/main/java/com/ssj/service/sys/poster/service/impl/PosterJoinServiceImpl.java

@@ -98,7 +98,12 @@ public class PosterJoinServiceImpl extends BaseServiceImpl<PosterJoin, String> i
 		
 		PosterTemplate posterTemplate=new PosterTemplate();
 		posterTemplate.setBackImg("1.png");
-		
+		posterTemplate.setAddressPosition("856");
+		posterTemplate.setNumberPosition("856");
+		posterTemplate.setLogoPosition("30;34");
+		posterTemplate.setQrcodePosition1("123;123;77;505");
+		posterTemplate.setQrcodePosition2("123;123;300;505");
+
 		PosterJoin posterJoin=new PosterJoin();
 		posterJoin.setLogoImg("2.png");
 		posterJoin.setQrcodeImg1("3.png");
@@ -106,18 +111,21 @@ public class PosterJoinServiceImpl extends BaseServiceImpl<PosterJoin, String> i
 		posterJoin.setName("活动");
 		posterJoin.setPhone("联系人:吴老师 13265096161");
 		posterJoin.setAddress("地址:佛山市南海区桂城融和路号号中铁建水岸花园号号号铺铺铺");//33个字
-		
+
 		String url=runGeneratePosterImg(posterTemplate, posterJoin,"");
 		System.out.println(url);
+
+
 	}
 	
     
 	public static String runGeneratePosterImg(PosterTemplate posterTemplate,PosterJoin posterJoin,String activityName) {
     	try {
-    		String savePath =PropertiesUtil.getValue("file_save_path")+"poster/";
-    		//String savePath="C:/Users/Admin/Desktop/poster/";
+    		String savePath =PropertiesUtil.getValue("file_save_path");
+    		String posterPath ="/poster/";
+    		//String savePath="E:";
 	    	// 按/poster/活动/机构/海报 保存
-	    	String save_path = savePath+activityName+"/";
+	    	String save_path = savePath+posterPath+activityName+"/"+posterJoin.getName()+"/";
 	    	String target_path =  save_path+IdWorker.generateId() + ".png";
 	    	// 创建文件夹
 	    	File f = new File(save_path);
@@ -147,7 +155,10 @@ public class PosterJoinServiceImpl extends BaseServiceImpl<PosterJoin, String> i
 	        g3.drawImage(codeImage, 0, 0, null);
 	        g3.dispose();
 	    	ImgBean.modifyImagetogeter(codeOutput, target_template,Integer.parseInt(qrcodePositions[2]),Integer.parseInt(qrcodePositions[3]));
-	    	
+
+	    	//合成后删除图片
+			File code1File = new File(code);
+			code1File.delete();
 	    	//合成二维码2
 	    	if(StringUtils.isNotEmpty(posterTemplate.getQrcodePosition2())) {
 		    	qrcodePositions=posterTemplate.getQrcodePosition2().split(";");
@@ -165,6 +176,10 @@ public class PosterJoinServiceImpl extends BaseServiceImpl<PosterJoin, String> i
 		        g3.drawImage(codeImage, 0, 0, null);
 		        g3.dispose();
 		    	ImgBean.modifyImagetogeter(codeOutput, target_template,Integer.parseInt(qrcodePositions[2]),Integer.parseInt(qrcodePositions[3]));
+
+				//合成后删除图片
+				File code1File2 = new File(code);
+				code1File2.delete();
 	    	}
 	    	
 	    	//合成联系人
@@ -179,7 +194,8 @@ public class PosterJoinServiceImpl extends BaseServiceImpl<PosterJoin, String> i
 	    		left=(33-posterJoin.getAddress().length())/2*15;
 	    	}
 	    	ImgBean.modifyImage(target_template,"地址:"+posterJoin.getAddress(),left,Integer.parseInt(addressPositions[0]),new Color(220,220,220),new Font("黑体", Font.PLAIN, 15));
-	    	
+
+			//System.out.println("step--生成海报-->ImgBean.writeImageLocal--"+target_path);
 	    	//生成海报
 	    	ImgBean.writeImageLocal(target_path,  source_template);
 	    	

+ 8 - 8
src/main/java/com/ssj/sys/controller/PosterController.java

@@ -111,12 +111,12 @@ public class PosterController extends BaseController {
 			int i = 0;
 			if(Objects.nonNull(list)){
 				for(Map<String,Object> m:list){
-					compressorFiles[i]= MapUtils.getString(m,"name");
+					compressorFiles[i]= file_path+"/poster/"+MapUtils.getString(m,"name");
 					i++;
 				}
 			}
 			zc.compress(compressorFiles);
-			exportResponseHeadSet(response,"");
+			exportResponseHeadSet(response,dataStr);
 			exportFile(response,file_path+zip);
 		} catch (Exception e) {
 			logger.error("异常", e);
@@ -126,7 +126,7 @@ public class PosterController extends BaseController {
 	public void exportResponseHeadSet(HttpServletResponse response,String fileName) throws  Exception{
 		response.setContentType("application/octet-stream;charset=UTF-8");
 		fileName=new String((fileName).getBytes("gb2312"), "iso8859-1");
-		response.setHeader("Content-Disposition", "attachment;filename=" + fileName+"_.zip");
+		response.setHeader("Content-Disposition", "attachment;filename="+fileName+".zip");
 		response.setCharacterEncoding("utf-8");
 	}
 
@@ -392,9 +392,9 @@ public class PosterController extends BaseController {
     public Response activityJoinSave(Model model,String ids,String aid,String templateId)throws Exception {
 		Response response = new  Response();
 		List<String> list = Arrays.asList(ids.split(","));
-		list.forEach(a->
-				posterJoinService.generatePosterImg(posterJoinService.getById(a),aid,templateId)
-		);
+		for(String str:list){
+			posterJoinService.generatePosterImg(posterJoinService.getById(str),aid,templateId);
+		}
 		response.success("成功");
         return response;
     }
@@ -435,9 +435,9 @@ public class PosterController extends BaseController {
 		PosterActivityJoin activityJoin = activityJoinService.getById(id);
 
 		//删除海报文件
-		String file_path = SystemResourceLocator.getValue("file_save_path")+"poster/";
+		String file_path = SystemResourceLocator.getValue("file_save_path")+"/poster/";
 		File file = new File(file_path+activityJoin.getPosterImg());
-		file.deleteOnExit();
+		file.delete();
 
 		activityJoinService.delete(id);
 		response.success("成功");

+ 5 - 5
src/main/java/com/ssj/util/ZipCompressor.java

@@ -56,19 +56,19 @@ public class ZipCompressor {
         }
     }
 
-    private void compress(File file, ZipOutputStream out, String basedir) {
+    private void compress(File file, ZipOutputStream out, String basedir) throws Exception {
         /* 判断是目录还是文件 */
-        if (file.isDirectory()) {
-            //System.out.println("压缩:" + basedir + file.getName());
+        if (file.getCanonicalFile().isDirectory()) {
+            //System.out.println("压缩文件夹:" + basedir + file.getName());
             this.compressDirectory(file, out, basedir);
         } else {
-            //System.out.println("压缩:" + basedir + file.getName());
+            //System.out.println("压缩文件:" + basedir + file.getName());
             this.compressFile(file, out, basedir);
         }
     }
 
     /** 压缩一个目录 */
-    private void compressDirectory(File dir, ZipOutputStream out, String basedir) {
+    private void compressDirectory(File dir, ZipOutputStream out, String basedir) throws Exception {
         if (!dir.exists()){
             return;
         }

+ 1 - 1
src/main/resources/templates/sys/poster/activity_join_add.html

@@ -153,7 +153,7 @@ function save(){
 	}, function(){
 		var url="[[${sysUrl}]]/sys/poster/activityJoin/save";
 		var params ={
-			'id' : ids,
+			'ids' : ids,
             'aid' : '[[${activity.id}]]',
             'templateId' : templateId,
         };

+ 2 - 2
src/main/resources/templates/sys/poster/activity_join_edit.html

@@ -138,8 +138,8 @@ function save(){
 	}, function(){
 		var url="[[${sysUrl}]]/sys/poster/activity/save";
 		var params ={
-			'id' : $("#id").val(),
-            'name' : $("#name").val(),
+			'ids' : $("#id").val(),
+            'aid' : '[[${activity.id}]]',
             'templateId' : templateId,
         };
 		$.post(url,params,function(data){

+ 1 - 1
src/main/resources/templates/sys/poster/activity_join_list.html

@@ -101,7 +101,7 @@
 				</td>
 				<td >
 					<a href="javascript:;" th:onclick="'edit(\''+${item.id}+'\')'" >编辑</a>
-					<a th:href="${imgUrl+item.poster_img}"  class="tablelink">下载</a>
+					<a th:href="${imgUrl+item.poster_img}" download  class="tablelink">下载</a>
 					<a th:href="${'javascript:joinDel(''' + item.id + ''')'}"  class="tablelink">删除</a>
 				</td>
 			</tr>

+ 1 - 1
src/main/resources/templates/sys/poster/activity_list.html

@@ -139,7 +139,7 @@
 		});
 	}
 	function exportAll() {
-		document.getElementById("seachform").action = "[[${sysUrl}]]/sys/poster/activity/exportDetail";
+		document.getElementById("seachform").action = "[[${sysUrl}]]/sys/poster/exportDetail";
 		$("#seachform").submit();
 		window.setTimeout(function(){
 			document.getElementById("seachform").action = "[[${sysUrl}]]/sys/poster/activity/list.html";