瀏覽代碼

下载图片

yue 5 年之前
父節點
當前提交
bb2a23251a

+ 2 - 2
src/main/java/com/jeeplus/common/config/Global.java

@@ -109,7 +109,7 @@ public class Global {
 	 */
 	public static String getAttachmentDir(){
 		SystemAuthorizingRealm.Principal principal = (SystemAuthorizingRealm.Principal) UserUtils.getPrincipal();
-		String dir = Global.getUserfilesBaseDir() + Global.USERFILES_BASE_URL + principal ;
+		String dir = Global.getUserfilesBaseDir()  ;
 		FileUtils.createDirectory(dir);
 		return dir;
 	}
@@ -121,7 +121,7 @@ public class Global {
 	public static String getAttachmentUrl(){
 
 		SystemAuthorizingRealm.Principal principal = (SystemAuthorizingRealm.Principal) UserUtils.getPrincipal();
-		return  Servlets.getRequest().getContextPath() + Global.USERFILES_BASE_URL + principal ;
+		return  Servlets.getRequest().getContextPath() ;
 	}
 
 	/**

+ 5 - 1
src/main/java/com/jeeplus/modules/act/web/ActTaskController.java

@@ -173,7 +173,11 @@ public class ActTaskController extends BaseController {
 		// 获取流程实例对象
 		if (act.getProcInsId() != null){
 			if(actTaskService.getProcIns(act.getProcInsId())!=null){
-				act.setProcIns(actTaskService.getProcIns(act.getProcInsId()));
+				try {
+					act.setProcIns(actTaskService.getProcIns(act.getProcInsId()));
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
 			}else{
 				act.setFinishedProcIns(actTaskService.getFinishedProcIns(act.getProcInsId()));
 			}

+ 44 - 0
src/main/java/com/jeeplus/modules/sg/managementcenter/activiti/entity/UploadImages.java

@@ -0,0 +1,44 @@
+package com.jeeplus.modules.sg.managementcenter.activiti.entity;
+
+import com.jeeplus.core.persistence.ActEntity;
+
+public class UploadImages extends ActEntity<UploadImages> {
+    private String imgName;
+    private String path;
+    private String procInsId;
+    private String uId;
+
+    public String getImgName() {
+        return imgName;
+    }
+
+    public void setImgName(String imgName) {
+        this.imgName = imgName;
+    }
+
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
+
+    @Override
+    public String getProcInsId() {
+        return procInsId;
+    }
+
+    @Override
+    public void setProcInsId(String procInsId) {
+        this.procInsId = procInsId;
+    }
+
+    public String getuId() {
+        return uId;
+    }
+
+    public void setuId(String uId) {
+        this.uId = uId;
+    }
+}

+ 19 - 0
src/main/java/com/jeeplus/modules/sg/managementcenter/activiti/mapper/UploadImagesMapper.java

@@ -0,0 +1,19 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.sg.managementcenter.activiti.mapper;
+
+import com.jeeplus.core.persistence.BaseMapper;
+import com.jeeplus.core.persistence.annotation.MyBatisMapper;
+import com.jeeplus.modules.sg.managementcenter.activiti.entity.UploadImages;
+
+/**
+ * 施工交底MAPPER接口
+ * @author
+ * @version 2019-11-08
+ */
+
+@MyBatisMapper
+public interface UploadImagesMapper extends BaseMapper<UploadImages> {
+    
+}

+ 115 - 0
src/main/java/com/jeeplus/modules/sg/managementcenter/activiti/mapper/xml/UploadImagesMapper.xml

@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.jeeplus.modules.sg.managementcenter.activiti.mapper.UploadImagesMapper">
+    
+	<sql id="constructionColumns">
+		a.id AS "id",
+		a.uId AS "uid",
+		a.imgName AS "imgName",
+		a.path AS "path",
+		a.proc_ins_id AS "procInsId",
+		a.create_by AS "createBy.id",
+		a.create_date AS "createDate",
+		a.update_by AS "updateBy.id",
+		a.update_date AS "updateDate",
+		a.remarks AS "remarks",
+		a.del_flag AS "delFlag",
+
+	</sql>
+
+	<select id="get" resultType="com.jeeplus.modules.sg.managementcenter.activiti.entity.UploadImages" >
+		SELECT *
+		FROM xm_upolad_images a
+		WHERE a.uId = #{uId}
+	</select>
+	
+	<select id="findList" resultType="UploadImages" >
+		SELECT *
+		FROM xm_upolad_images a
+		<where>
+			<if test="dataScope != null and dataScope != ''">
+				${dataScope}
+			</if>
+			<if test="uId != null and uId != ''">
+				AND a.uId = #{uId}
+			</if>
+		</where>
+		<choose>
+			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
+				ORDER BY ${page.orderBy}
+			</when>
+			<otherwise>
+				ORDER BY a.update_date DESC
+			</otherwise>
+		</choose>
+	</select>
+	
+	<select id="findAllList" resultType="UploadImages" >
+		SELECT *
+		FROM xm_upolad_images a
+		<where>
+			a.del_flag = #{DEL_FLAG_NORMAL}
+			${dataScope}
+		</where>		
+		<choose>
+			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
+				ORDER BY ${page.orderBy}
+			</when>
+			<otherwise>
+				ORDER BY a.update_date DESC
+			</otherwise>
+		</choose>
+	</select>
+	
+	<insert id="insert">
+		INSERT INTO xm_upolad_images(
+			id,
+			create_by,
+			create_date,
+			update_by,
+			update_date,
+			remarks,
+			del_flag,
+			imgName,
+			path,
+			proc_ins_id,
+			uId
+		) VALUES (
+			#{id},
+			#{createBy.id},
+			#{createDate},
+			#{updateBy.id},
+			#{updateDate},
+			#{remarks},
+			#{delFlag},
+			#{imgName},
+			#{path},
+			#{procInsId},
+			#{uId}
+		)
+	</insert>
+	
+	<update id="update">
+		UPDATE xm_upolad_images SET
+			update_by = #{updateBy.id},
+			update_date = #{updateDate},
+			remarks = #{remarks}
+		WHERE id = #{id}
+	</update>
+
+	<!--物理删除-->
+	<update id="delete">
+		DELETE FROM xm_upolad_images
+		WHERE id = #{id}
+	</update>
+	
+	<!--逻辑删除-->
+	<update id="deleteByLogic">
+		UPDATE xm_upolad_images SET
+			del_flag = #{DEL_FLAG_DELETE}
+		WHERE id = #{id}
+	</update>
+	
+
+	
+</mapper>

+ 51 - 0
src/main/java/com/jeeplus/modules/sg/managementcenter/activiti/service/UploadImagesService.java

@@ -0,0 +1,51 @@
+/**
+ * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.modules.sg.managementcenter.activiti.service;
+
+import com.jeeplus.core.service.CrudService;
+import com.jeeplus.modules.sg.managementcenter.activiti.entity.PersonnelManagement;
+import com.jeeplus.modules.sg.managementcenter.activiti.entity.UploadImages;
+import com.jeeplus.modules.sg.managementcenter.activiti.mapper.PersonnelManagementMapper;
+import com.jeeplus.modules.sg.managementcenter.activiti.mapper.UploadImagesMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+/**
+ * 图片Service
+ * @author
+ * @version 2019-11-08
+ */
+@Service
+@Transactional(readOnly = true)
+public class UploadImagesService extends CrudService<UploadImagesMapper, UploadImages> {
+
+	@Override
+	public UploadImages get(String id) {
+		return super.get(id);
+	}
+
+	@Override
+	public List<UploadImages> findList(UploadImages entity) {
+		return super.findList(entity);
+	}
+
+	@Override
+	public List<UploadImages> findListBy(List<UploadImages> entity) {
+		return super.findListBy(entity);
+	}
+
+	@Override
+	public List<UploadImages> findAllList(UploadImages entity) {
+		return super.findAllList(entity);
+	}
+
+	@Override
+	@Transactional(readOnly = false)
+	public void save(UploadImages entity) {
+		super.save(entity);
+	}
+}

+ 67 - 5
src/main/java/com/jeeplus/modules/sg/managementcenter/activiti/web/DivideController.java

@@ -7,19 +7,27 @@ import com.google.common.collect.Maps;
 import com.jeeplus.common.json.AjaxJson;
 import com.jeeplus.common.utils.DateUtils;
 import com.jeeplus.common.utils.StringUtils;
+import com.jeeplus.core.persistence.Page;
 import com.jeeplus.core.web.BaseController;
 import com.jeeplus.modules.act.service.ActProcessService;
 import com.jeeplus.modules.act.service.ActTaskService;
 import com.jeeplus.modules.sg.managementcenter.activiti.entity.Construction;
 import com.jeeplus.modules.sg.managementcenter.activiti.entity.Disclose;
+import com.jeeplus.modules.sg.managementcenter.activiti.entity.UploadImages;
 import com.jeeplus.modules.sg.managementcenter.activiti.service.ConstructionService;
 import com.jeeplus.modules.sg.managementcenter.activiti.service.DiscloseService;
+import com.jeeplus.modules.sg.managementcenter.activiti.service.UploadImagesService;
+import com.jeeplus.modules.sys.utils.UserUtils;
+import com.jeeplus.modules.test.pic.entity.TestPic;
 import org.activiti.engine.repository.ProcessDefinition;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import java.util.Map;
 
 /**
@@ -40,7 +48,9 @@ public class DivideController extends BaseController {
 	private ActTaskService actTaskService;
 	@Autowired
 	private DiscloseService discloseService;
-	
+	@Autowired
+	private UploadImagesService uploadImagesService;
+
 	@ModelAttribute
 	public Construction get(@RequestParam(required=false) String id) {
 		Construction entity = null;
@@ -59,12 +69,29 @@ public class DivideController extends BaseController {
 		return "modules/sg/managementcenter/activiti/upload";
 	}
 
-	@ResponseBody
-	@RequestMapping(value = "uploadSave")
-	public String uploadSave(Construction construction, Model model,String pic) {
+
+
+	/**
+	 * 图片管理列表页面
+	 */
+	@RequestMapping(value = {"images"})
+	public String list(Construction construction, Model model) {
 		model.addAttribute("construction", construction);
-		return "modules/sg/managementcenter/activiti/upload";
+		return "modules/sg/managementcenter/activiti/uploadList";
 	}
+
+
+	/**
+	 * 文件管理列表数据
+	 */
+	@ResponseBody
+	@RequestMapping(value = "data")
+	public Map<String, Object> data(UploadImages uploadImages, HttpServletRequest request, HttpServletResponse response, Model model) {
+		Page<UploadImages> page = uploadImagesService.findPage(new Page<UploadImages>(request, response), uploadImages);
+		return getBootstrapData(page);
+	}
+
+
 	
 
 	/**
@@ -125,6 +152,41 @@ public class DivideController extends BaseController {
 
 		return j;
 	}
+
+	@ResponseBody
+	@RequestMapping(value = "uploadSave")
+	public AjaxJson uploadSave(Disclose disclose, Model model,String pic) throws Exception{
+		AjaxJson j = new AjaxJson();
+		/**
+		 * 后台hibernate-validation插件校验
+		 */
+		String errMsg = beanValidator(disclose);
+		if (StringUtils.isNotBlank(errMsg)){
+			j.setSuccess(false);
+			j.setMsg(errMsg);
+			return j;
+		}
+
+		/**
+		 * 流程审批
+		 */
+		if (StringUtils.isBlank(disclose.getId())){
+			UploadImages uploadImages = new UploadImages();
+			uploadImages.setPath(pic);
+			uploadImages.setProcInsId(disclose.getAct().getProcDefId());
+			uploadImages.setuId(UserUtils.getUser().getLoginName());
+			uploadImagesService.save(uploadImages);
+			//新增或编辑表单保存
+			// 启动流程
+			ProcessDefinition p = actProcessService.getProcessDefinition(disclose.getAct().getProcDefId());
+			String title = disclose.getCurrentUser().getName()+"在"+ DateUtils.getDateTime()+"发起"+p.getName();
+			actTaskService.startProcess(p.getKey(),  "xm_construction_clarificaiton", disclose.getId(), title);
+			j.setMsg("提交审批成功!");
+			j.getBody().put("targetUrl",  "/act/task/process/");
+		}
+
+		return j;
+	}
 	
 
 

+ 1 - 1
src/main/webapp/webpage/modules/common/fileUpload.jsp

@@ -17,7 +17,7 @@
 				<c:if test="${ readonly == false }">
 				<a class="fa fa-minus-circle remove-this fa-2x file-item pull-right fa-danger" data-id="{{d.file.id}}"></a>
 				</c:if>
-				<a class="fa fa-cloud-download download-this fa-2x file-item pull-right text-info {{d.file.hide}}" data-url="{{d.file.url}}"></a>
+				<a style="display: none" class="fa fa-cloud-download download-this fa-2x file-item pull-right text-info {{d.file.hide}}" data-url="{{d.file.url}}"></a>
 			</div>
 		</div>
 	</script>

+ 0 - 8
src/main/webapp/webpage/modules/sg/managementcenter/activiti/upload.jsp

@@ -19,14 +19,6 @@
 				}
 			});
 
-			$("#agree").click(function () {
-				var tuser = $("#tuserName").val();
-				console.log(tuser);
-				if (tuser=="") {
-					jp.error("请选择用户");
-					return;
-				}
-			})
 
 			$('#acceptDate').datetimepicker({
 				format: "YYYY-MM-DD HH:mm:ss"

+ 218 - 0
src/main/webapp/webpage/modules/sg/managementcenter/activiti/uploadList.js

@@ -0,0 +1,218 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<script>
+$(document).ready(function() {
+	$('#testPicTable').bootstrapTable({
+		 
+		  //请求方法
+               method: 'post',
+               //类型json
+               dataType: "json",
+               contentType: "application/x-www-form-urlencoded",
+               //显示检索按钮
+	           showSearch: true,
+               //显示刷新按钮
+               showRefresh: true,
+               //显示切换手机试图按钮
+               showToggle: true,
+               //显示 内容列下拉框
+    	       showColumns: true,
+    	       //显示到处按钮
+    	       showExport: true,
+    	       //显示切换分页按钮
+    	       showPaginationSwitch: true,
+    	       //最低显示2行
+    	       minimumCountColumns: 2,
+               //是否显示行间隔色
+               striped: true,
+               //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)     
+               cache: false,    
+               //是否显示分页(*)  
+               pagination: true,   
+                //排序方式 
+               sortOrder: "asc",  
+               //初始化加载第一页,默认第一页
+               pageNumber:1,   
+               //每页的记录行数(*)   
+               pageSize: 10,  
+               //可供选择的每页的行数(*)    
+               pageList: [10, 25, 50, 100],
+               //这个接口需要处理bootstrap table传递的固定参数,并返回特定格式的json数据  
+               url: "${ctx}/managementcenter/divide/data",
+               //默认值为 'limit',传给服务端的参数为:limit, offset, search, sort, order Else
+               //queryParamsType:'',   
+               ////查询参数,每次调用是会带上这个参数,可自定义                         
+               queryParams : function(params) {
+               	var searchParam = $("#searchForm").serializeJSON();
+               	searchParam.pageNo = params.limit === undefined? "1" :params.offset/params.limit+1;
+               	searchParam.pageSize = params.limit === undefined? -1 : params.limit;
+               	searchParam.orderBy = params.sort === undefined? "" : params.sort+ " "+  params.order;
+                   return searchParam;
+               },
+               //分页方式:client客户端分页,server服务端分页(*)
+               sidePagination: "server",
+               contextMenuTrigger:"right",//pc端 按右键弹出菜单
+               contextMenuTriggerMobile:"press",//手机端 弹出菜单,click:单击, press:长按。
+               contextMenu: '#context-menu',
+               onContextMenuItem: function(row, $el){
+                   if($el.data("item") == "edit"){
+                   		edit(row.id);
+                   }else if($el.data("item") == "view"){
+                       view(row.id);
+                   } else if($el.data("item") == "delete"){
+                        jp.confirm('确认要删除该图片管理记录吗?', function(){
+                       	jp.loading();
+                       	jp.get("${ctx}/test/pic/testPic/delete?id="+row.id, function(data){
+                   	  		if(data.success){
+                   	  			$('#testPicTable').bootstrapTable('refresh');
+                   	  			jp.success(data.msg);
+                   	  		}else{
+                   	  			jp.error(data.msg);
+                   	  		}
+                   	  	})
+                   	   
+                   	});
+                      
+                   } 
+               },
+              
+               onClickRow: function(row, $el){
+               },
+               	onShowSearch: function () {
+			$("#search-collapse").slideToggle();
+		},
+               columns: [{
+		        field: 'path',
+		        title: '图片路径',
+		        sortable: true,
+		        sortName: 'path',
+		        formatter:function(value, row , index){
+		        	var valueArray = value.split("|");
+		        	var labelArray = [];
+		        	for(var i =0 ; i<valueArray.length; i++){
+		        		if(!/\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/.test(valueArray[i]))
+		        		{
+		        			labelArray[i] = "<a href=\""+valueArray[i]+"\" url=\""+valueArray[i]+"\" target=\"_blank\">"+decodeURIComponent(valueArray[i].substring(valueArray[i].lastIndexOf("/")+1))+"</a>"
+		        		}else{
+		        			labelArray[i] = '<img   onclick="jp.showPic(\''+valueArray[i]+'\')"'+' height="50px" src="'+valueArray[i]+'">';
+		        		}
+		        	}
+		        	return labelArray.join(" ");
+		        }
+		       
+		    }]
+		});
+		
+		  
+	  if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){//如果是移动端
+
+		 
+		  $('#testPicTable').bootstrapTable("toggleView");
+		}
+	  
+	  $('#testPicTable').on('check.bs.table uncheck.bs.table load-success.bs.table ' +
+                'check-all.bs.table uncheck-all.bs.table', function () {
+            $('#remove').prop('disabled', ! $('#testPicTable').bootstrapTable('getSelections').length);
+            $('#view,#edit').prop('disabled', $('#testPicTable').bootstrapTable('getSelections').length!=1);
+        });
+		  
+		$("#btnImport").click(function(){
+			jp.open({
+			    type: 2,
+                area: [500, 200],
+                auto: true,
+			    title:"导入数据",
+			    content: "${ctx}/tag/importExcel" ,
+			    btn: ['下载模板','确定', '关闭'],
+				    btn1: function(index, layero){
+					  jp.downloadFile('${ctx}/test/pic/testPic/import/template');
+				  },
+			    btn2: function(index, layero){
+				        var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
+						iframeWin.contentWindow.importExcel('${ctx}/test/pic/testPic/import', function (data) {
+							if(data.success){
+								jp.success(data.msg);
+								refresh();
+							}else{
+								jp.error(data.msg);
+							}
+                            jp.close(index);
+                        });//调用保存事件
+                    return false;
+				  },
+				 
+				  btn3: function(index){ 
+					  jp.close(index);
+	    	       }
+			}); 
+		});
+		
+		
+	 $("#export").click(function(){//导出Excel文件
+			jp.downloadFile('${ctx}/test/pic/testPic/export');
+	  });
+
+		    
+	  $("#search").click("click", function() {// 绑定查询按扭
+		  $('#testPicTable').bootstrapTable('refresh');
+		});
+	 
+	 $("#reset").click("click", function() {// 绑定查询按扭
+		  $("#searchForm  input").val("");
+		  $("#searchForm  select").val("");
+		  $("#searchForm  .select-item").html("");
+		  $('#testPicTable').bootstrapTable('refresh');
+		});
+		
+		
+	});
+		
+  function getIdSelections() {
+        return $.map($("#testPicTable").bootstrapTable('getSelections'), function (row) {
+            return row.id
+        });
+    }
+  
+  function deleteAll(){
+
+		jp.confirm('确认要删除该图片管理记录吗?', function(){
+			jp.loading();  	
+			jp.get("${ctx}/test/pic/testPic/deleteAll?ids=" + getIdSelections(), function(data){
+         	  		if(data.success){
+         	  			$('#testPicTable').bootstrapTable('refresh');
+         	  			jp.success(data.msg);
+         	  		}else{
+         	  			jp.error(data.msg);
+         	  		}
+         	  	})
+          	   
+		})
+  }
+
+    //刷新列表
+  function refresh(){
+  	$('#testPicTable').bootstrapTable('refresh');
+  }
+  
+   function add(){
+	  jp.openSaveDialog('新增图片管理', "${ctx}/test/pic/testPic/form",'800px', '500px');
+  }
+
+
+  
+   function edit(id){//没有权限时,不显示确定按钮
+       if(id == undefined){
+	      id = getIdSelections();
+	}
+	jp.openSaveDialog('编辑图片管理', "${ctx}/test/pic/testPic/form?id=" + id, '800px', '500px');
+  }
+  
+ function view(id){//没有权限时,不显示确定按钮
+      if(id == undefined){
+             id = getIdSelections();
+      }
+        jp.openViewDialog('查看图片管理', "${ctx}/test/pic/testPic/form?id=" + id, '800px', '500px');
+ }
+
+
+
+</script>

+ 50 - 0
src/main/webapp/webpage/modules/sg/managementcenter/activiti/uploadList.jsp

@@ -0,0 +1,50 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/webpage/include/taglib.jsp"%>
+<html>
+<head>
+	<title>图片管理管理</title>
+	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
+	<meta name="decorator" content="ani"/>
+	<%@ include file="/webpage/include/bootstraptable.jsp"%>
+	<%@include file="/webpage/include/treeview.jsp" %>
+	<%@include file="uploadList.js" %>
+</head>
+<body>
+	<div class="wrapper wrapper-content">
+	<div class="panel panel-primary">
+	<div class="panel-heading">
+		<h3 class="panel-title">文件管理列表</h3>
+	</div>
+	<div class="panel-body">
+	
+	<!-- 搜索 -->
+	<div id="search-collapse" class="collapse">
+		<div class="accordion-inner">
+			<form:form id="searchForm" modelAttribute="construction" class="form form-horizontal well clearfix">
+				<input type="hidden" value="">
+		 <div class="col-xs-12 col-sm-6 col-md-4">
+<%--			<div style="margin-top:26px">
+			  <a  id="search" class="btn btn-primary btn-rounded  btn-bordered btn-sm"><i class="fa fa-search"></i> 查询</a>
+			  <a  id="reset" class="btn btn-primary btn-rounded  btn-bordered btn-sm" ><i class="fa fa-refresh"></i> 重置</a>
+			 </div>--%>
+	    </div>	
+	</form:form>
+	</div>
+	</div>
+	
+	<!-- 工具栏 -->
+	<div id="toolbar">
+
+		    </div>
+		
+	<!-- 表格 -->
+	<table id="testPicTable"   data-toolbar="#toolbar"></table>
+
+    <!-- context menu -->
+    <ul id="context-menu" class="dropdown-menu">
+    </ul>  
+	</div>
+	</div>
+	</div>
+</body>
+</html>