Review

数据库:

数据库分区分表读写分离

oracle按照时间创建分区表 https://blog.csdn.net/zhanglei721/article/details/77358846

后端:

Entity

实体类无id注解@Id报错

自增  

@GeneratedValue(strategy = GenerationType.AUTO)

UUID ora-00972标识符过长

Id = UUID.randomUUID().toString().replace("-", "");

转换:

@formula 解释转换的 加注释之后其他地方设置值不会放进去

/**
 * 一级分类
 */

@Column(name = "PRIMARY_TYPE_ID")
private String primaryTypeId;

@Formula("(SELECT t.TYPE_NAME FROM PLAN_MANAGE_TYPE t WHERE t.PLAN_TYPE_ID = PRIMARY_TYPE_ID)")
private String primaryTypeName;

DateStrFormat

Dict字典表 id code title

USER_EIC_SYS.sys_dict_table

USER_EIC_SYS.sys_norm_dict

 Query

private Integer pageIndex = 1;
private Integer pageSize = 10;

public String columns;//字段

private String startissueTime;//起始时间
private String endissueTime;//结束时间

Vo

//获取vo值

public Map<String, String> convert(String filterList) {

        String[] arr = filterList.split(",");

        Map<String, String> map = new HashMap<String, String>();

        for (String s : arr) {

            String key = s.substring(0, 1).toUpperCase() + s.substring(1);

            try {
                Method method = this.getClass().getMethod("get" + key);
                Object value = method.invoke(this);
                if (value == null) {
                    map.put(s, null);
                } else {
                    map.put(s, value.toString());
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

        }
        return map;

    }

Bo 导入

package com.epgis.yjzh.uap.material.demandreport.model.bo;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.UUID;

import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecgframework.poi.excel.annotation.ExcelTarget;

import com.epgis.yjzh.fjdky.utils.DateUtils;
import com.epgis.yjzh.uap.material.demandreport.model.entity.AllocationEntity;

@ExcelTarget("AllocationBo")
public class AllocationBo implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 需求提报时间
	 */
	@Excel(name = "需求提报时间")
	private Date txqtbsj;
	/**
	 * 需求接收方式
	 */
	@Excel(name = "需求接收方式(邮件/传真/电话)")
	private String txqjsfs;
	/**
	 * 物料编码
	 */
	@Excel(name = "物料编码(尽量提供)")
	private String twlbm;
	/**
	 * 总价
	 */
	/*@Excel(name = "总价")
	private String tzj;*/
	/**
	 * 不含税单价
	 */
	@Excel(name = "不含税单价")
	private String tbhdj;
	/**
	 * 物料描述
	 */
	@Excel(name = "物料描述(物资名称型号规格)")
	private String twlms;
	/**
	 * 计量单位
	 */
	@Excel(name = "计量单位")
	private String tjldw;
	/**
	 * 数量
	 */
	@Excel(name = "数量")
	private String tsl;
	/**
	 * 要求到货时间
	 */
	@Excel(name = "要求到货时间")
	private Date tyqdhsj;
	/**
	 * 接货地点
	 */
	@Excel(name = "接货地点、联系人及电话")
	private String tjhdd;
	/**
	 * 供应单位
	 */
	@Excel(name = "供应商/供应单位")
	private String tgydw;
	/**
	 * 供应电话
	 */
	@Excel(name = "供应商/供应单位联系人及电话")
	private String tgydh;
	/**
	 * 供应方式
	 */
	@Excel(name = "供应方式(地区调剂、协议库存、临时采购)")
	private String tgyfs;
	/**
	 * 已供应数量
	 */
	@Excel(name = "已供应数量(根据进度更新)")
	private String tygysl;
	/**
	 * 配送进度
	 */
	@Excel(name = "配送进度(需求受理/发货/运输在途/到货)")
	private String tpsjd;
	/**
	 * 供应组织方
	 */
	@Excel(name = "供应进度说明(针对左边的进度描述供应进度)")
	private String tgyjdsm;
	/**
	 * 调配组织方
	 */
	@Excel(name = "调配组织方(省调配中心/地市调配中心)")
	private String tdpzzf;
	/**
	 * 分地区
	 */
	@Excel(name = "分地区")
	private String tfdq;
	/**
	 * 备注
	 */
	@Excel(name = "备注")
	private String tbz;
	/**
	 * 需求单位
	 */
	@Excel(name = "需求单位(需求来源)")
	private String txqdw;
	/**
	 * 物资二级分类
	 */
	@Excel(name = "物资二级分类")
	private String twzejfl;
	/**
	 * 物资一级分类
	 */
	@Excel(name = "物资一级分类")
	private String twzyjfl;

	public Date getTxqtbsj() {
		return txqtbsj;
	}

	public void setTxqtbsj(Date txqtbsj) {
		this.txqtbsj = txqtbsj;
	}

	public String getTxqjsfs() {
		return txqjsfs;
	}

	public void setTxqjsfs(String txqjsfs) {
		this.txqjsfs = txqjsfs;
	}

	public String getTwlbm() {
		return twlbm;
	}

	public void setTwlbm(String twlbm) {
		this.twlbm = twlbm;
	}

	/*public String getTzj() {
		return tzj;
	}

	public void setTzj(String tzj) {
		this.tzj = tzj;
	}*/

	public String getTbhdj() {
		return tbhdj;
	}

	public void setTbhdj(String tbhdj) {
		this.tbhdj = tbhdj;
	}

	public String getTwlms() {
		return twlms;
	}

	public void setTwlms(String twlms) {
		this.twlms = twlms;
	}

	public String getTjldw() {
		return tjldw;
	}

	public void setTjldw(String tjldw) {
		this.tjldw = tjldw;
	}

	public String getTsl() {
		return tsl;
	}

	public void setTsl(String tsl) {
		this.tsl = tsl;
	}

	public Date getTyqdhsj() {
		return tyqdhsj;
	}

	public void setTyqdhsj(Date tyqdhsj) {
		this.tyqdhsj = tyqdhsj;
	}

	public String getTjhdd() {
		return tjhdd;
	}

	public void setTjhdd(String tjhdd) {
		this.tjhdd = tjhdd;
	}

	public String getTgydw() {
		return tgydw;
	}

	public void setTgydw(String tgydw) {
		this.tgydw = tgydw;
	}

	public String getTgydh() {
		return tgydh;
	}

	public void setTgydh(String tgydh) {
		this.tgydh = tgydh;
	}

	public String getTgyfs() {
		return tgyfs;
	}

	public void setTgyfs(String tgyfs) {
		this.tgyfs = tgyfs;
	}

	public String getTygysl() {
		return tygysl;
	}

	public void setTygysl(String tygysl) {
		this.tygysl = tygysl;
	}

	public String getTpsjd() {
		return tpsjd;
	}

	public void setTpsjd(String tpsjd) {
		this.tpsjd = tpsjd;
	}

	public String getTgyjdsm() {
		return tgyjdsm;
	}

	public void setTgyjdsm(String tgyjdsm) {
		this.tgyjdsm = tgyjdsm;
	}

	public String getTdpzzf() {
		return tdpzzf;
	}

	public void setTdpzzf(String tdpzzf) {
		this.tdpzzf = tdpzzf;
	}

	public String getTfdq() {
		return tfdq;
	}

	public void setTfdq(String tfdq) {
		this.tfdq = tfdq;
	}

	public String getTbz() {
		return tbz;
	}

	public void setTbz(String tbz) {
		this.tbz = tbz;
	}

	public String getTxqdw() {
		return txqdw;
	}

	public void setTxqdw(String txqdw) {
		this.txqdw = txqdw;
	}

	public String getTwzejfl() {
		return twzejfl;
	}

	public void setTwzejfl(String twzejfl) {
		this.twzejfl = twzejfl;
	}

	public String getTwzyjfl() {
		return twzyjfl;
	}

	public void setTwzyjfl(String twzyjfl) {
		this.twzyjfl = twzyjfl;
	}

	public AllocationEntity convert() throws Exception {

		AllocationEntity entity = new AllocationEntity();

		entity.setTxh(UUID.randomUUID().toString());
		entity.setTdrlj(DateUtils.getTime());
		try {
			if (null != this.getTxqtbsj() && !(this.getTxqtbsj().equals(""))) {
				entity.setTxqtbsj(DateUtils.formateDate(this.getTxqtbsj(),"yyyy-MM-dd HH:mm:ss"));
			}
			if ((null != this.getTsl()) && (null != this.getTbhdj())) {
				BigDecimal tsl = new BigDecimal(Double.valueOf(this.getTsl()));
				BigDecimal bhdj = new BigDecimal(Double.valueOf(this.getTbhdj()));
				entity.setTzj(String.valueOf(tsl.multiply(bhdj)));
			}
			if (null != this.getTyqdhsj() && !(this.getTyqdhsj().equals(""))) {
				entity.setTyqdhsj(DateUtils.formateDate(this.getTyqdhsj(),"yyyy-MM-dd HH:mm:ss"));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		entity.setTxqjsfs(this.getTxqjsfs());
		entity.setTwlbm(this.getTwlbm());
		entity.setTbhdj(this.getTbhdj());
		entity.setTwlms(this.getTwlms());
		entity.setTjldw(this.getTjldw());
		entity.setTsl(this.getTsl());
		entity.setTjhdd(this.getTjhdd());
		entity.setTgydw(this.getTgydw());
		entity.setTgydh(this.getTgydh());
		entity.setTgyfs(this.getTgyfs());
		entity.setTygysl(this.getTygysl());
		entity.setTpsjd(this.getTpsjd());
		entity.setTgyjdsm(this.getTgyjdsm());
		entity.setTdpzzf(this.getTdpzzf());
		entity.setTfdq(this.getTfdq());
		entity.setTbz(this.getTbz());
		entity.setTxqdw(this.getTxqdw());
		entity.setTwzejfl(this.getTwzejfl());
		entity.setTwzyjfl(this.getTwzyjfl());

		return entity;
	}
}

Service Impl

QueryCriteria qc = new QueryCriteria();

qc.addFrom(PlanManageEntity.class);

qc.addOrder("create_time", "desc");//按时间排序
/**
     * 筛选参数符号过滤
     * 
     * @param queryFilters
     *            筛选参数
     * @return 过滤后的筛选参数
     */
    private List<QueryFilter> signFilter(List<QueryFilter> queryFilters) {
        List<String> paramByLike = Arrays.asList(new String[] { "planName",
                "authDept" });//模糊查询
        List<String> paramByIn = Arrays.asList(new String[] { "secondTypeId",
        "orgId" });//多选 in
        for (QueryFilter queryFilter : queryFilters) {

            if (queryFilter.getFieldName().equals("startissueTime")) {
                queryFilter.setFieldName("issueTime");
                queryFilter.setOperator(">=");
                queryFilter.setValue(queryFilter.getValue().toString()
                        .replaceAll("[- :]", ""));
                continue;
            }

            if (queryFilter.getFieldName().equals("endissueTime")) {
                queryFilter.setFieldName("issueTime");
                queryFilter.setOperator("<=");
                queryFilter.setValue(queryFilter.getValue().toString()
                        .replaceAll("[- :]", ""));
                continue;
            }

            if (paramByLike.contains(queryFilter.getFieldName())) {
                queryFilter.setOperator("like");
                queryFilter.setValue("%" + queryFilter.getValue().toString()
                        + "%");
                continue;
            }
            
            if (paramByIn.contains(queryFilter.getFieldName())) {
                queryFilter.setOperator("in");
                String ids = queryFilter.getValue().toString(); 
                queryFilter.setValue(ids.replaceAll(" ", "").split(","));
                continue;
            }
        }

        return queryFilters;
    }

Entity convert to Vo

TranslateField.translateField(entity);

BeanUtils.copyProperties(entity, vo);
@Component
public class TranslateField {
	
	private void init() {
		TranslateField.sysNormDictService = sysNormDictService;
    }
	
	private static SysNormDictService sysNormDictService;
	
	public static void setSysNormDictService(SysNormDictService sysNormDictService) {
		TranslateField.sysNormDictService = sysNormDictService;
	}
	
	public static void translateField(Object obj) {
        try {
        	if(null == obj) {
        		return;
        	}
            Class cls = obj.getClass();
            for (Field field : cls.getDeclaredFields()) {
                if (!field.isAccessible()) {
                    field.setAccessible(true);
                }
                //注解
                Annotation[] annotations = field.getAnnotations();
                for(Annotation annotation : annotations) {
                	Object value = null;
                	String methodName = null;
                	if(DateStrFormat.class == annotation.annotationType()) {
                		 DateStrFormat date = field.getAnnotation(DateStrFormat.class);
                		 value = field.get(obj);
                		 if(null != value) {
                			 value = transDate(value.toString(),date.pattern()); 
                			 methodName = field.getName().substring(0, 1).toUpperCase() + (field.getName().substring(1));
                		 }
                	} else if(Dict.class == annotation.annotationType()) {
                		 Dict dict = field.getAnnotation(Dict.class);
            			 String type = dict.type();
            			 String name = dict.name();
            			 String methodcode = name.substring(0, 1).toUpperCase() + (name.substring(1));
            			 Method method = getMethod("get"+methodcode,cls);
            			 Object o = method.invoke(obj);
            			 value = null!=o&&!"".equals(o.toString())?o.toString():"";
            			 value = transDic(value.toString(),type);
            			 methodName = field.getName().substring(0, 1).toUpperCase() + (field.getName().substring(1));
                	}
                	if(null != methodName && !"".equals(value)) {
        				Method method = getMethod("set" + methodName,cls);
        				method.invoke(obj,new Object[]{value});
                	}
                }

            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
	
	private static String transDate(String value,String format) throws Exception {
		if(StringUtils.isNotBlank(value) && value.contains("-")) {
			return value.replaceAll("[- :]", "");
		} else if(StringUtils.isNotBlank(value) && "yyyy-MM-dd".equals(format)) {
			return DateUtils.getDateFormat(value,
					"yyyyMMdd", format);
		} else if(StringUtils.isNotBlank(value)) {
			return DateUtils.getDateFormat(value,
					"yyyyMMddHHmmss", format);
		}
		return "";
	}
	
	private static String transDic(String value,String type) {
		 Map map = sysNormDictService.getDictByType(type,value);
		if(null != map && map.size()>0) {
			return (String)map.get("NAME");
		}
		return "";
	}
	
	private static Method getMethod(String methodName,Class cls) {
		Method[] methods = cls.getMethods();
		for(Method method : methods) {
			if(methodName.equals(method.getName())){
				return method;
			}
		}
		return null;
	}
}

 Controller

RequestMethod:GET/POST/PUT/DELETE

@RequestMapping(value = "/", method = RequestMethod.GET)

@ResponseBody

 

 @RequestParam

@RequestParam(value = "planId", required = true) String planId

返回值Result:code msg data

public static R result(int code, String msg, Object data) {
    R r = new R();
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("code", code);
    map.put("msg", msg);
    map.put("data", data);
    r.putAll(map);
    return r;
}
R getById(@RequestParam(value = "planId", required = true) String planId) {
    try {
        PlanManageVo vo = planManageService.getById(planId);
        return R.result(200, "success", vo);
    } catch (Exception e) {
        e.printStackTrace();
        return R.error();
	}
}

导出 easypoi

/**
	 * 导出word
	 * 
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(value = "/exportWord", method = RequestMethod.GET)
	public R exportWord(HttpServletRequest request,
			HttpServletResponse response, PlanManageQuery query) {
		try {
			String columns = query.getColumns();
			query.setColumns(null);

			List<PlanManageVo> data = planManageService.getByQueryFilter(query);

			List<Map<String, String>> dataResult = PlanManageExportUtils
					.sourceData(data, columns);
			Map<String, String> map = PlanManageExportUtils
					.getWordColumn(columns);

			XWPFDocument word = ExportUtils.getDoc("预案管理表", map, dataResult);

			response.addHeader("Content-disposition", "attachment;filename="
					+ new String("预案管理表.docx".getBytes("gb2312"), "ISO8859-1"));
			response.setContentType("octets/stream;charset=UTF-8");
			ServletOutputStream out = response.getOutputStream();

			word.write(out);
			return R.ok();
		} catch (Exception e) {
			e.printStackTrace();
			return R.error();
		}
	}
/**
	 * 导出Excel文档
	 * 
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(value = "/exportExcel", method = RequestMethod.GET)
	public R exportExcel(HttpServletRequest request,
			HttpServletResponse response, PlanManageQuery query) {
		try {
			String columns = query.getColumns();
			query.setColumns(null);

			List<PlanManageVo> data = planManageService.getByQueryFilter(query);

			List<ExcelExportEntity> entityList = PlanManageExportUtils
					.newAddExcel(columns);
			List<Map<String, String>> dataResult = PlanManageExportUtils
					.sourceData(data, columns);

			ExportParams exportParams = new ExportParams("预案管理表", null,
					ExcelType.XSSF);
			Workbook workBook = ExcelExportUtil.exportExcel(exportParams,
					entityList, dataResult);

			response.addHeader("Content-disposition", "attachment;filename="
					+ new String("预案管理表.xls".getBytes("gb2312"),
							"ISO8859-1"));
			response.setContentType("octets/stream;charset=UTF-8");
			ServletOutputStream out = response.getOutputStream();

			workBook.write(out);
			return R.ok();
		} catch (Exception e) {
			e.printStackTrace();
			return R.error();
		}
	}

Util 

/**
 * 
 * 导出工具类
 */
public class PlanManageExportUtils {

	private PlanManageExportUtils() {

	}

	/**
	 * 创建需要导出的列名
	 * 
	 * @param filterList
	 *            需要导出的列名
	 * @return
	 */
	public static List<ExcelExportEntity> newAddExcel(String filterList) {

		String[] arrFilter = filterList.split(",");
		Map<String, String> map = getCloums();

		List<ExcelExportEntity> entityList = new ArrayList<ExcelExportEntity>();

		Set<String> cloums = map.keySet();

		for (String filter : arrFilter) {
			for (String cloum : cloums) {
				if (filter.equals(cloum)) {
					String value = map.get(cloum);
					entityList.add(new ExcelExportEntity(value, cloum, 50));
					break;
				}
			}
		}

		return entityList;

	}

	/**
	 * 填充数据
	 * 
	 * @param list
	 *            数据
	 * @param filterList
	 *            需要填充的列
	 * @return
	 */
	public static List<Map<String, String>> sourceData(List<PlanManageVo> list,
			String filterList) {

		List<Map<String, String>> data = new ArrayList<Map<String, String>>();

		for (PlanManageVo vo : list) {
			data.add(vo.convert(filterList));
		}

		return data;
	}

	public static Map<String, String> getWordColumn(String filterList) {
		Map<String, String> wordMap = new LinkedHashMap<String, String>();
		String[] arrFilter = filterList.split(",");
		Map<String, String> map = getCloums();

		List<ExcelExportEntity> entityList = new ArrayList<ExcelExportEntity>();

		Set<String> cloums = map.keySet();

		for (String filter : arrFilter) {
			for (String cloum : cloums) {
				if (filter.equals(cloum)) {
					wordMap.put(cloum, map.get(cloum));
					break;
				}
			}
		}

		return wordMap;
	}

	private static Map<String, String> getCloums() {
		Map<String, String> map = new HashMap<String, String>();
		map.put("planId", "预案id");
		map.put("orgId", "机构id");
		map.put("orgName", "机构");
		map.put("primaryTypeId", "一级分类");
		map.put("primaryTypeName", "一级分类");
		map.put("secondTypeId", "二级分类");
		map.put("secondTypeName", "二级分类");
		map.put("planName", "预案名称");
		map.put("issueTime", "发布时间");
		map.put("isRecord", "是否政府备案");
		map.put("isRecordName", "是否政府备案");
		map.put("revisionCycle", "修订周期");
		map.put("revisionCycleName", "修订周期");
		map.put("authDept", "负责编制部门");
		map.put("isDelete", "是否删除(0否1是)");
		map.put("standby1", "备用字段");
		map.put("standby2", "备用字段");
		map.put("standby3", "备用字段");
		map.put("createTime", "创建时间");
		map.put("createUser", "创建人");
		map.put("createDept", "创建部门");
		return map;
	}

	public static XWPFDocument mergeWord(XWPFDocument document,
			XWPFDocument doucDocument2) throws Exception {

		XWPFDocument src1Document = document;

		XWPFParagraph p = src1Document.createParagraph();

		// 设置分页符

		p.setPageBreak(true);

		CTBody src1Body = src1Document.getDocument().getBody();

		XWPFDocument src2Document = doucDocument2;

		CTBody src2Body = src2Document.getDocument().getBody();

		XWPFParagraph p2 = src2Document.createParagraph();

		XmlOptions optionsOuter = new XmlOptions();

		optionsOuter.setSaveOuter();

		String appendString = src2Body.xmlText(optionsOuter);

		String srcString = src1Body.xmlText();

		String prefix = srcString.substring(0, srcString.indexOf(">") + 1);

		String mainPart = srcString.substring(srcString.indexOf(">") + 1,
				srcString.lastIndexOf("<"));

		String sufix = srcString.substring(srcString.lastIndexOf("<"));

		String addPart = appendString.substring(appendString.indexOf(">") + 1,
				appendString.lastIndexOf("<"));

		CTBody makeBody = CTBody.Factory.parse(prefix + mainPart + addPart
				+ sufix);

		src1Body.set(makeBody);

		return src1Document;

	}

}

导入

/**
	 * 导入
	 * 
	 * @throws Exception
	 */
	@RequestMapping(value = "/import", method = RequestMethod.POST)
	public @ResponseBody
	R importExcel(@RequestParam("file") MultipartFile file) throws Exception {

		ImportParams params = new ImportParams();
		// params.setStartSheetIndex(1);

		File tempFile = TempFile.createTempFile("province", ".xls");
		file.transferTo(tempFile);

		List<VendorBo> list = ExcelImportUtil.importExcel(tempFile,
				VendorBo.class, params);

		tempFile.delete();

		List<VendorEntity> result = new ArrayList<VendorEntity>();

		for (VendorBo bo : list) {

			result.add(bo.convert());
		}

		vendorService.addAllVendor(result);

		return R.result(200, "success", list);
	}

下载

/**
	 * 下载
	 * 
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/download", method = RequestMethod.GET)
	public @ResponseBody
	void getById(HttpServletRequest request, HttpServletResponse response)
			throws IOException {
		String url = request.getSession().getServletContext()
				.getRealPath("WEB-INF/template/gyskc.xls");
		// 设置响应头,控制浏览器下载该文件
		response.setHeader("content-disposition", "attachment;filename="
				+ URLEncoder.encode("供应商库存模板.xls", "UTF-8"));
		// 读取要下载的文件,保存到文件输入流
		FileInputStream in = new FileInputStream(url);
		// 创建输出流
		OutputStream out = response.getOutputStream();
		// 创建缓冲区
		byte buffer[] = new byte[1024];
		int len = 0;
		// 循环将输入流中的内容读取到缓冲区当中
		while ((len = in.read(buffer)) > 0) {
			// 输出缓冲区的内容到浏览器,实现文件下载
			out.write(buffer, 0, len);
		}
		// 关闭文件输入流
		in.close();
		// 关闭输出流
		out.close();
	}

获取路径

String filePath = 
request.getSession().getServletContext()
.getRealPath("WEB-INF/template/zbmoban.xls");

 

上传附件

/**
 * 非结构化平台文件信息表
 * 
 * @author way
 * @email [email protected]
 * @date 2018-11-13 14:10:30
 */
@Controller
@RequestMapping(value = "/tUdsUpload")
public class TUdsUploadController {

	/** 文件打开类型表码配置 */
	public final static String BM_FILE_TYPE = "BM_FILE_TYPE";

	/**
	 * 文件服务器存放上传文件的根地址 相对于文件服务器的根路径而言的
	 */
	public static final String UPLOAD_FILE_ROOT = "upload";
	
	public static final int UPLOAD_FILE_MAX_SIZE = 500;
	
	public static final String[] UPLOAD_FILE_TYPE = new String[]{};
	
	@Autowired
	private TUdsUploadService tUdsUploadService;
	

	/**
	 * 分页查询
	 * 
	 * @param query
	 *            查询条件
	 * @return 查询结果
	 */
	@RequestMapping(value = "/", method = RequestMethod.GET)
	public @ResponseBody
	PageUtils<TUdsUploadVo> queryPage(TUdsUploadQuery query) {
		return tUdsUploadService.queryPage(query);
	}

	/**
	 * 下载附件
	 * 
	 * @param objid
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/download", method = RequestMethod.GET)
	public @ResponseBody
	R getById(HttpServletRequest request,
			HttpServletResponse response,
			@RequestParam(value = "objid", required = true) String objid){
		try {
			if("dev".equals(Configuration.getInstance().getValue("SYSTEM.TYPE"))) {
				TUdsUploadVo entity = tUdsUploadService.getById(objid);
				tUdsUploadService.updateDownloadNum(objid);

				// 设置响应头,控制浏览器下载该文件
				response.setHeader("content-disposition", "attachment;filename="
						+ URLEncoder.encode(entity.getSrcFilename(), "UTF-8"));
				// 读取要下载的文件,保存到文件输入流
				FileInputStream in = new FileInputStream(entity.getUdsDocumentId());
				// 创建输出流
				OutputStream out = response.getOutputStream();
				// 创建缓冲区
				byte buffer[] = new byte[1024];
				int len = 0;
				// 循环将输入流中的内容读取到缓冲区当中
				while ((len = in.read(buffer)) > 0) {
					// 输出缓冲区的内容到浏览器,实现文件下载
					out.write(buffer, 0, len);
				}
				// 关闭文件输入流
				in.close();
				// 关闭输出流
				out.close();
			} else {
				UapUdsFileController bean = (UapUdsFileController) SpringUtil.getBean("uapUdsFileController");
				bean.downloadFile(request, response,objid);
			}
			return R.ok();
		}catch(Exception e) {
			e.printStackTrace();
			return R.error();
		}
		
	}

	/**
	 * 新增
	 * 
	 * @param request
	 * @param response
	 * @param entity
	 * @throws Exception
	 */
	@RequestMapping(value = "/add")
	public @ResponseBody
	R addTUdsUpload(HttpServletRequest request, HttpServletResponse response){
		try {
			if("dev".equals(Configuration.getInstance().getValue("SYSTEM.TYPE"))) {
				String ownerId = request.getParameter("ownerId");
				String deptId = request.getParameter("deptId");
				MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
				Iterator<String> fileParamList = multipartRequest.getFileNames();
				while (fileParamList.hasNext()) {
					String key = fileParamList.next();
					MultipartFile file = multipartRequest.getFile(key);
					String realFileName = file.getOriginalFilename();
					if (StringUtils.isNotEmpty(realFileName)) {
						String fileType = getFileType(realFileName);
						long fileSize = file.getSize();
						  if (!(validateFileType(fileType))) { throw new
						  Exception("只允许上传文件类型为:" + StringUtils.join(
						  UPLOAD_FILE_TYPE, ",") + "的文件。"); }
						  
						  if (!(validateFileSize(fileSize))) { throw new
						  Exception( "只允许上传文件大小:" +
						  String.valueOf(UPLOAD_FILE_MAX_SIZE) +
						  "MB。"); }
						String relativePath = getSaveRelativePath(realFileName);
						/*
						 * 保存文件到硬盘上
						 */
						File saveFilePath = getSaveDiskFile(getDiskPath(relativePath,
								ownerId, request));
						file.transferTo(saveFilePath);
						/**
						 * 保存数据库信息
						 */
						TUdsUploadEntity entity = new TUdsUploadEntity();
						entity.setOwnerId(ownerId);
						entity.setSrcFilename(realFileName);
						entity.setFileSize(String.valueOf(fileSize));
						entity.setFileType(fileType);
						entity.setDownloadNum(0L);
						entity.setCreateTime(DateUtils.getDateFormat(new Date(),
								"yyyyMMddHHmmss"));
						// 先设置路径
						entity.setUdsDocumentId(saveFilePath.getPath());
						entity.setCreatorId(UserContext.getCurrentUserId());
						if (null != deptId && StringUtils.isNotBlank(deptId)) {
							entity.setDeptId(deptId);
						} else {
							entity.setDeptId(UserContext.getCurrentDeptId());
						}
						entity.setCreateTime(DateUtils.getDateFormat(new Date(), "yyyyMMddHHmmss"));
						tUdsUploadService.addTUdsUpload(entity);
					}
				}
			} else {
				UapUdsFileController bean = (UapUdsFileController) SpringUtil.getBean("uapUdsFileController");
				bean.uploadFile(request, response);
			}
			return R.ok();
		} catch(Exception e) {
			e.printStackTrace();
			return R.error();
		}
		
	}

	/**
	 * 删除
	 * 
	 * @param objid
	 */
	@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
	public @ResponseBody
	R deleteTUdsUpload(HttpServletRequest request, HttpServletResponse response,
			@RequestParam(value = "objids", required = true) String objids) {
		try {
			if("dev".equals(Configuration.getInstance().getValue("SYSTEM.TYPE"))) {
				tUdsUploadService.deleteTUdsUpload(objids);
			} else {
				UapUdsFileController bean = (UapUdsFileController) SpringUtil.getBean("uapUdsFileController");
				bean.deleteUploadFile(objids);
			}
			return R.ok();
		} catch(Exception e) {
			e.printStackTrace();
			return R.error();
		}
		
	}

	/**
	 * 取得要保存在硬盘上的文件,如果不存在,则创建
	 * 
	 * @param diskPath
	 * @return
	 */
	public static File getSaveDiskFile(String diskPath) {
		File file = new File(diskPath);
		file.mkdirs();
		return file;
	}

	/**
	 * 根据给定的相对路径来取得该文件在硬盘上的真实路径
	 * 
	 * @param relativePath
	 *            相对于<FILE_SERVER_URL >/<UPLOAD_FILE_ROOT>而言的路径
	 * @param request
	 * @return
	 */
	public static String getDiskPath(String relativePath, String ownerId,
			HttpServletRequest request) {
		return "WebContent/upload/" + ownerId + "/" + relativePath;
	}

	/**
	 * 取得上传文件的保存路径,相对于<FILE_SERVER_URL >/<UPLOAD_FILE_ROOT>而言
	 * 
	 * @return
	 */
	public static String getSaveRelativePath(String saveFileName) {
		Calendar c = Calendar.getInstance();
		int year = c.get(Calendar.YEAR);
		int month = c.get(Calendar.MONTH) + 1;
		return year + "/" + month + "/" + UUID.randomUUID().toString() + "/"
				+ saveFileName;
	}

	/**
	 * 根据给定的文件名取得该文件的类型
	 * 
	 * @param fileName
	 * @return
	 */
	public static String getFileType(String fileName) {
		return fileName.substring(fileName.lastIndexOf(".") + 1,
				fileName.length());
	}
	
	 public static boolean validateFileType(String fileType) {
	        if (StringUtils.isEmpty(fileType)) {
	            return false;
	        } else {
	            String[] uploadFileTypeArray = UPLOAD_FILE_TYPE;
	            if (uploadFileTypeArray != null && uploadFileTypeArray.length != 0) {
	                String[] arr$ = uploadFileTypeArray;
	                int len$ = uploadFileTypeArray.length;

	                for(int i$ = 0; i$ < len$; ++i$) {
	                    String uploadFileType = arr$[i$];
	                    if (fileType.equalsIgnoreCase(uploadFileType)) {
	                        return true;
	                    }
	                }

	                return false;
	            } else {
	                return true;
	            }
	        }
	  }
	 
	 public static boolean validateFileSize(long size) {
	        return size < (long)(UPLOAD_FILE_MAX_SIZE * 1024 * 1024);
	    }

}

 树级接口

public List queryPlanDeptTree() {
    String sql = "select ORG_ID code,SHORT_NAME name,ORG_PARENT_ID pCode from PLAN_MANAGE_ORG where is_delete='0' and ORG_PARENT_ID = ?";
    List<Map> list = this.getEventTypeChildrens(dao.queryForListWithSql(sql,new Object[]{"0"}),sql);
    return list;
}

public List<Map> getEventTypeChildrens(List<Map> list,String sql){
    //数据最终结果
    List<Map> result = new ArrayListMap>();
    //1、循环最高级父节点数据
    for(Map map : list){
    Map tempMap = new HashMap();
    //2、放入json数据
    tempMap.put("label", map.get("name"));
    tempMap.put("id", map.get("code"));
    //tempMap.put("pCode", map.get("pCode"));
    //3、判断是否存在子节点
    List leaf = dao.queryForListWithSql(sql,new Object[]{map.get("code")});
    if(leaf!=null && leaf.size()>0){
    //4、调取自己循环获取子节点
    List<Map> childs =  this.getEventTypeChildrens(dao.queryForListWithSql(sql,new Object[]{map.get("code")}),sql);
    tempMap.put("children", childs);
    }
    result.add(tempMap);
    }
    return result;
}

工具类

uitls.database

public class DataBaseUtil {

	private DataBaseUtil() {
	}

	public static QueryCriteria wrapQuery(QueryCriteria qc,
			List<QueryFilter> queryFilter, String className) {

		if (null != queryFilter && !queryFilter.isEmpty()) {

			CrudUtils.addQCWhere(qc, queryFilter, className);

		}

		return qc;
	}

	public static QueryCriteria wrapPage(RequestCondition queryCondition,
			QueryCriteria qc) {

		int pageIndex = 1;
		int pageSize = 10;

		if (null != queryCondition && null != queryCondition.getPageIndex()
				&& null != queryCondition.getPageSize()) {
			pageIndex = Integer.parseInt(queryCondition.getPageIndex());
			pageSize = Integer.parseInt(queryCondition.getPageSize());
		}
		qc.addPage(pageIndex, pageSize);

		return qc;
	}

	public static int getRecordCount(IHibernateDao iHibernateDao,
			QueryCriteria qc) {

		int count = 0;
		count = iHibernateDao.findAllByCriteriaPageCount(qc, 1);

		return count;
	}

	public static List<QueryFilter> buildFilter(Object obj) {

		List<QueryFilter> queryFilter = new ArrayList<QueryFilter>();

		try {
			if (null != obj) {
				Field[] fields = obj.getClass().getDeclaredFields();
				for (Field field : fields) {
					String key = field.getName().substring(0, 1).toUpperCase()
							+ field.getName().substring(1);
					if ((!key.equals("PageSize") && !key.equals("PageIndex"))
							&& !key.equals("SerialVersionUID")) {
						Method method = obj.getClass().getMethod("get" + key);
						Object value = method.invoke(obj);
						if (null != value
								&& !StringUtils.isEmpty(value.toString())) {

							QueryFilter filter = new QueryFilter();
							filter.setFieldName(field.getName());
							filter.setValue(value);
							filter.setOperator("=");
							filter.setDataType(field.getType().toString());

							queryFilter.add(filter);
						}
					}

				}
			}
		} catch (Exception e) {

		}
		return queryFilter;
	}

}

uitls.page 

/**
 * 
 * @author sundong
 * @date 2018-9-30
 */
public class PageUtils<T> implements Serializable {

	// 成功code
	public static Integer SUCCESS_CODE = 200;

	// 失败code
	public static Integer ERROR_CODE = 500;

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	// 总页数
	private Integer pageTotal;

	// 数据列表
	private List<T> data;

	// 解析提示文本
	private String msg;

	// 接口状态码
	private Integer code;

	/**
	 * 
	 * @param pageTotal
	 *            总页数
	 * @param data
	 *            数据列表
	 * @param msg
	 *            解析提示文本
	 * @param code
	 *            接口状态码
	 */
	public PageUtils(Integer pageTotal, List<T> data, String msg, Integer code) {
		super();
		this.pageTotal = pageTotal;
		this.data = data;
		this.msg = msg;
		this.code = code;
	}

	public Integer getPageTotal() {
		return pageTotal;
	}

	public void setPageTotal(Integer pageTotal) {
		this.pageTotal = pageTotal;
	}

	public List<T> getData() {
		return data;
	}

	public void setData(List<T> data) {
		this.data = data;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

}

uitls.poi 

/**
 * 
 * 导出工具类
 * 
 * @author sundong
 * @date 2018-10-30
 */
public class ExportUtils {
	
	public static final int FIRSTLEVELLENGTH = 3;
	
	public static final int SECONDLEVELLENGTH = 5;
	
	public static final int THRIDLEVELLENGTH = 10;
	
	public static final int FOURTHLEVELLENGTH = 15;
	
	public static final int FIVETHLEVELLENGTH = 30;


	private ExportUtils() {

	}

	public static XWPFDocument getDoc(String title,
			Map<String, String> columns, List<Map<String, String>> data) {

		XWPFDocument document = new XWPFDocument();
		XWPFParagraph titleParagraph = document.createParagraph();
		titleParagraph.setAlignment(ParagraphAlignment.CENTER);

		XWPFRun titleRun = titleParagraph.createRun();
		titleRun.setText(title);
		titleRun.setFontSize(14);

		XWPFTable table = document.createTable();
		
		
		// 样式控制
		CTTbl ttbl = table.getCTTbl();
		CTTblPr tblPr = ttbl.getTblPr() == null ? ttbl.addNewTblPr() : ttbl
				.getTblPr();
		CTTblWidth tblWidth = tblPr.isSetTblW() ? tblPr.getTblW() : tblPr
				.addNewTblW();
		CTJc cTJc = tblPr.addNewJc();
		cTJc.setVal(STJc.Enum.forString("center"));// 表格居中
		tblWidth.setW(new BigInteger("9000"));// 每个表格宽度
		tblWidth.setType(STTblWidth.DXA);

		// 表格创建
		XWPFTableRow tableRowTitle = table.getRow(0);
	
		// 设置标题
		String[] columsTitle = new String[columns.size()];
		Set<Entry<String, String>> entrySet = columns.entrySet();
		int num = 0;
		for (Entry entry : entrySet) {
			if (0==num) {
				tableRowTitle.getCell(0).setText((String) entry.getValue());
			} else {
				tableRowTitle.addNewTableCell().setText(
						(String) entry.getValue());
			}
			columsTitle[num] = (String) entry.getValue();
			++num;
		}
		// 标题设置样式
		for (int i = 0; i < entrySet.size(); i++) {
			tableRowTitle.getCell(i).setColor("99CCFF");
			/*
			 * XWPFParagraph paragraph =
			 * tableRowTitle.getCell(i).addParagraph(); XWPFRun newRun =
			 * paragraph.createRun(); newRun.setBold(true);
			 * newRun.setFontSize(22);
			 * tableRowTitle.getCell(i).setParagraph(paragraph);
			 */
		}
		
		int [] columMaxTextLength = new int[columns.size()];
		// 填充数据
		for (int i = 0; i < data.size(); i++) {
			XWPFTableRow row = table.createRow();
			Map map = data.get(i);
			Iterator<Entry<String, String>> iterator = columns.entrySet()
					.iterator();
			int j = 0;
			while (iterator.hasNext()) {
				Map.Entry<String, String> entry = iterator.next();
				Object value = map.get(entry.getKey());
				XWPFTableCell cell = row.getCell(j);
				if (null != value) {
					cell.setText(value.toString());
					if(columMaxTextLength[j]<value.toString().length()) {
						columMaxTextLength[j] = value.toString().length();
					}
				} else {
					cell.setText("");
				}
				++j;
			}
		}
		
		//固定布局
		if(columns.size()<8) {
			setTableGridCol(table,columMaxTextLength,columsTitle);
		}
		
		return document;
	}

	/**
	 * 创建需要导出的列名
	 * 
	 * @param filterList
	 *            需要导出的列名
	 * @return
	 */
	public static List<ExcelExportEntity> newAddExcel(String filterList,
			Map<String, String> map) {

		String[] arrFilter = filterList.split(",");

		List<ExcelExportEntity> entityList = new ArrayList<ExcelExportEntity>();

		Set<String> cloums = map.keySet();

		for (String filter : arrFilter) {
			for (String cloum : cloums) {
				if (filter.equals(cloum)) {
					String value = map.get(cloum);
					entityList.add(new ExcelExportEntity(value, cloum, 35));
					break;
				}
			}
		}

		return entityList;

	}
	
	/** 
	* @Description: 设置列宽和垂直对齐方式 
	*/  
	public static void setCellWidthAndVAlign(XWPFTableCell cell, String width, STVerticalJc.Enum typeEnum, STJc.Enum vAlign) {
		CTTc cttc = cell.getCTTc();
		CTTcPr cellPr = getCellCTTcPr(cell);
		cellPr.addNewVAlign().setVal(typeEnum);
		cttc.getPList().get(0).addNewPPr().addNewJc().setVal(vAlign);
		CTTblWidth tblWidth = cellPr.isSetTcW() ? cellPr.getTcW() : cellPr.addNewTcW();
		if(!StringUtils.isEmpty(width)){
			tblWidth.setW(new BigInteger(width));
			tblWidth.setType(STTblWidth.DXA);
		}
	}
	
	 /** 
     *  
     * @Description: 得到Cell的CTTcPr,不存在则新建 
     */  
    public static CTTcPr getCellCTTcPr(XWPFTableCell cell) {  
        CTTc cttc = cell.getCTTc();  
        CTTcPr tcPr = cttc.isSetTcPr() ? cttc.getTcPr() : cttc.addNewTcPr();  
        return tcPr;  
    } 
    
    /** 
     * @Description: 设置表格列宽 
     */  
    public static void setTableGridCol(XWPFTable table,int[] colMaxTextSize,String[] columsTitle) {  
        CTTbl ttbl = table.getCTTbl();  
        CTTblGrid tblGrid = ttbl.getTblGrid() != null ? ttbl.getTblGrid()  
                : ttbl.addNewTblGrid();  
        
        //采用固定布局方式,设置列宽
        int [] colWid = resetWidths(colMaxTextSize,columsTitle);
    	CTTbl ctTbl = table.getCTTbl();
        CTTblPr ctTblPr = ctTbl.addNewTblPr();
        CTTblLayoutType layoutType = ctTblPr.addNewTblLayout();
        layoutType.setType(STTblLayoutType.FIXED);
        for (int j = 0, len = colWid.length; j < len; j++) {  
            CTTblGridCol gridCol = tblGrid.addNewGridCol();  
            gridCol.setW(new BigInteger(String.valueOf(colWid[j])));  
        }
    }
    
    public static int[] resetWidths(int[] colMaxTextSize,String[] columsTitle) {
    	double length = 9000;
    	double percent = 0;
    	double[] newColWidths = new double[colMaxTextSize.length];
    	for(int i=0; i<columsTitle.length; i++) {
    		if(colMaxTextSize[i]<columsTitle[i].length()) {
    			colMaxTextSize[i] = columsTitle[i].length();
    		}
    	}
    	//按比例:设置每列列宽
    	for(int j=0; j<colMaxTextSize.length; j++) {
    		if(colMaxTextSize[j]<FIRSTLEVELLENGTH) {
    			newColWidths[j] = 0.7;
    			percent += 0.7;
    		}else if(colMaxTextSize[j]<SECONDLEVELLENGTH) {
    			newColWidths[j] = 1;
    			percent += 1;
    		} else if(colMaxTextSize[j]<THRIDLEVELLENGTH) {
    			newColWidths[j] = 2;
    			percent += 2;
    		} else if(colMaxTextSize[j]<FOURTHLEVELLENGTH) {
    			newColWidths[j] = 3;
    			percent += 3;
    		} else if(colMaxTextSize[j]<FIVETHLEVELLENGTH) {
    			newColWidths[j] = 4;
    			percent += 4;
    		} else {
    			newColWidths[j] = 6;
    			percent += 6;
    		}
    	}
    	double avg = length/percent;
    	//如果按比例设置的列宽有小于700的,将其设置为700,其他的列再按照比例分配列宽
    	for(int j=0; j<colMaxTextSize.length; j++) {
    		if((int)avg*newColWidths[j]<1000 && columsTitle[j].length()>FIRSTLEVELLENGTH) {
    			colMaxTextSize[j] = 1000;
    			length -= 1000;
    			percent -= 1;
    		}else if((int)avg*newColWidths[j]<700){
    			colMaxTextSize[j] = 700;
    			length -= 700;
    			percent -= 0.7;
    		}
    	}
    	avg = length/percent;
    	for(int j=0; j<colMaxTextSize.length; j++) {
    		if(colMaxTextSize[j]!=700 && colMaxTextSize[j]!=1000){
    			colMaxTextSize[j] = (int) (avg*newColWidths[j]);
    		}
    	}
    	return colMaxTextSize;
    }

	/**
	 * 填充数据
	 * 
	 * @param list
	 *            数据
	 * @param filterList
	 *            需要填充的列
	 * @return
	 */
	public static List<Map<String, String>> sourceData(
			List<EmsZstjOmsZhtdmxforfeederVo> list, String filterList) {

		List<Map<String, String>> data = new ArrayList<Map<String, String>>();

		for (EmsZstjOmsZhtdmxforfeederVo vo : list) {
			data.add(vo.convert(filterList));
		}

		return data;
	}

	public static List<Map<String, String>> sourceDataProvince(
			List<ProvinceVo> list, String filterList) {

		List<Map<String, String>> data = new ArrayList<Map<String, String>>();

		for (ProvinceVo vo : list) {
			data.add(vo.convert(filterList));
		}

		return data;
	}

	public static List<Map<String, String>> sourceDataVendor(
			List<VendorVo> list, String filterList) {
		List<Map<String, String>> data = new ArrayList<Map<String, String>>();

		for (VendorVo vo : list) {
			data.add(vo.convert(filterList));
		}

		return data;
	}

	public static List<Map<String, String>> sourceDataSentiment(
			List<SentimentVo> list, String filterList) {
		List<Map<String, String>> data = new ArrayList<Map<String, String>>();

		for (SentimentVo vo : list) {
			data.add(vo.convert(filterList));
		}

		return data;
	}

	public static List<Map<String, String>> sourceDataAllocation(
			List<AllocationVo> list, String filterList) {
		List<Map<String, String>> data = new ArrayList<Map<String, String>>();

		for (AllocationVo vo : list) {
			data.add(vo.convert(filterList));
		}

		return data;
	}

	public static List<Map<String, String>> sourceDataPlans(List<PlansVo> list,
			String filterList) {
		List<Map<String, String>> data = new ArrayList<Map<String, String>>();

		for (PlansVo vo : list) {
			data.add(vo.convert(filterList));
		}

		return data;
	}

	public static List<Map<String, String>> sourceDataTeam(List<TeamVo> list,
			String filterList) {
		List<Map<String, String>> data = new ArrayList<Map<String, String>>();

		for (TeamVo vo : list) {
			data.add(vo.convert(filterList));
		}

		return data;
	}

	public static List<Map<String, String>> sourceDataEmployee(
			List<EmployeeVo> list, String filterList) {
		List<Map<String, String>> data = new ArrayList<Map<String, String>>();

		for (EmployeeVo vo : list) {
			data.add(vo.convert(filterList));
		}

		return data;
	}

	public static List<Map<String, String>> sourceDataEquip(List<EquipVo> list,
			String filterList) {
		List<Map<String, String>> data = new ArrayList<Map<String, String>>();

		for (EquipVo vo : list) {
			data.add(vo.convert(filterList));
		}

		return data;
	}

	public static List<Map<String, String>> sourceDataDetailList(
			List<DetailListVo> list, String filterList) {
		List<Map<String, String>> data = new ArrayList<Map<String, String>>();

		for (DetailListVo vo : list) {
			data.add(vo.convert(filterList));
		}

		return data;
	}

	public static List<Map<String, String>> sourceDataStatusDetail(
			List<StatusDetailVo> list, String filterList) {
		List<Map<String, String>> data = new ArrayList<Map<String, String>>();

		for (StatusDetailVo vo : list) {
			data.add(vo.convert(filterList));
		}

		return data;
	}

	public static List<Map<String, String>> sourceDataSendLog(
			List<SendLogVo> list, String filterList) {
		List<Map<String, String>> data = new ArrayList<Map<String, String>>();

		for (SendLogVo vo : list) {
			data.add(vo.convert(filterList));
		}

		return data;
	}

	public static List<Map<String, String>> sourceDataCommMan(
			List<CommManVo> list, String filterList) {
		List<Map<String, String>> data = new ArrayList<Map<String, String>>();

		for (CommManVo vo : list) {
			data.add(vo.convert(filterList));
		}

		return data;
	}

	public static List<Map<String, String>> sourceDataGroup(
			List<CommGroupVo> list, String filterList) {
		List<Map<String, String>> data = new ArrayList<Map<String, String>>();

		for (CommGroupVo vo : list) {
			data.add(vo.convert(filterList));
		}

		return data;
	}

	public static List<Map<String, String>> sourceDataDmGroup(
			List<EmsDmGroupVo> list, String filterList) {
		List<Map<String, String>> data = new ArrayList<Map<String, String>>();

		for (EmsDmGroupVo vo : list) {
			data.add(vo.convert(filterList));
		}

		return data;
	}

	public static List<Map<String, String>> sourceDataSysUser(
			List<SysUserVo> list, String filterList) {
		List<Map<String, String>> data = new ArrayList<Map<String, String>>();

		for (SysUserVo vo : list) {
			data.add(vo.convert(filterList));
		}

		return data;
	}
	
}

uitls.format

查询转时间戳

if (queryFilter.getFieldName().equals("time")) {
    queryFilter.setValue(queryFilter.getValue().toString().replaceAll("[- :]", ""));
    continue;
}

 转换时间格式

/**
* yyyyMMdd
* yyyyMMddHHmmss 
* yyyy-MM-dd HH:mm:ss
*/
public static Date getDate(String datestr, String inFmt,  String outFmt) 
throws ParseException {
    SimpleDateFormat inDateFormat = new SimpleDateFormat(inFmt);
    inDateFormat.setLenient(true);
    SimpleDateFormat outDateFormat = new SimpleDateFormat(outFmt);
    outDateFormat.setLenient(true);
    String outDate = outDateFormat.format(inDate);
    return outDate;
}
public class DateUtils {
	/** @deprecated */
	public static final int DB_STORE_DATE = 1;
	/** @deprecated */
	public static final int HYPHEN_DISPLAY_DATE = 2;
	/** @deprecated */
	public static final int DOT_DISPLAY_DATE = 3;
	/** @deprecated */
	public static final int CN_DISPLAY_DATE = 4;
	/** @deprecated */
	public static final int DB_LONG_DATE = 5;

	public static String flex2DB(String dateStr) throws ParseException {
		return getDateFormat(dateStr, "yyyy-MM-dd hh", "yyyyMMddhh");
	}

	public static String javascript2DB(String dateStr) throws ParseException {
		return getDateFormat(dateStr, "yyyy-MM-dd", "yyyyMMdd");
	}

	/**
	 * yyyyMMddHHmmss yyyy-MM-dd HH:mm:ss
	 */
	public static String getDateFormat(String datestr, String inFmt,
			String outFmt) throws ParseException {
		if (null == datestr || "".equals(datestr.trim()))
			return datestr;
		if (null == inFmt || "".equals(inFmt.trim()))
			return datestr;
		if (null == outFmt || "".equals(outFmt.trim()))
			outFmt = "yyyyMMdd";
		Date inDate = getDate(datestr, inFmt);
		if (null == inDate) {
			return datestr;
		} else {
			String retu = getDateFormat(inDate, outFmt);
			inDate = null;
			return retu;
		}
	}

	public static String getCurrentTime() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
		String time = sdf.format(new Date());
		return time;
	}

	public static Date getDate(String datestr, String inFmt)
			throws ParseException {
		if (null == datestr || "".equals(datestr.trim()))
			return null;
		if (null == inFmt || "".equals(inFmt.trim()))
			inFmt = "yyyyMMdd";
		Date inDate = null;
		SimpleDateFormat inDateFormat = new SimpleDateFormat(inFmt);
		inDateFormat.setLenient(true);
		inDate = inDateFormat.parse(datestr);
		inDateFormat = null;
		return inDate;
	}

	public static String getDateFormat(Date date, String outFmt) {
		if (null == date)
			return null;
		if (null == outFmt || "".equals(outFmt.trim()))
			outFmt = "yyyyMMdd";
		String retu = null;
		SimpleDateFormat dateFormat = null;
		try {
			dateFormat = new SimpleDateFormat(outFmt);
		} catch (IllegalArgumentException iaex) {
			dateFormat = new SimpleDateFormat("yyyyMMdd");
		}
		retu = dateFormat.format(date);
		dateFormat = null;
		return retu;
	}

	public static String getForeday(int foreDay) {
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		Calendar calendar = new GregorianCalendar();
		calendar.add(Calendar.DATE, foreDay);
		return format.format(calendar.getTime());
	}

	public static String getTodayTime() {
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		return format.format(new Date());
	}

	public static long getHoursSpace(String stime, String etime)
			throws ParseException {
		Date sd = getDate(stime, "yyyy-MM-dd");
		Date ed = getDate(stime, "yyyy-MM-dd");
		return (ed.getTime() - sd.getTime()) / 3600000;
	}

	public static String getCurrentDay8HourString() {
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH");
		Calendar calendar = new GregorianCalendar();
		calendar.set(Calendar.HOUR_OF_DAY, 8);

		return format.format(calendar.getTime());
	}

	public static String getCurrentDay8HourString2() {
		SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHH");
		Calendar calendar = new GregorianCalendar();
		calendar.set(Calendar.HOUR_OF_DAY, 8);

		return format.format(calendar.getTime());
	}

	public static String getCurrentDayString() {
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH");

		return format.format(new Date());
	}

	public static String addOneHour(Date d) {
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH");
		Calendar calendar = new GregorianCalendar();
		calendar.add(Calendar.HOUR_OF_DAY, 1);

		return format.format(d);
	}

	public static String addOneHour2(Date d) {
		SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHH");
		Calendar calendar = new GregorianCalendar();
		calendar.add(Calendar.HOUR_OF_DAY, 1);

		return format.format(d);
	}

	public static String getCurrentDayString2() {
		SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHH");

		return format.format(new Date());
	}

	public static String currentDate(String fms) {
		SimpleDateFormat format = new SimpleDateFormat(fms);

		return format.format(new Date());
	}

	public static String currentDateGoHour(int n, String fms) {
		SimpleDateFormat format = new SimpleDateFormat(fms);

		Calendar calendar = new GregorianCalendar();
		calendar.set(Calendar.HOUR, n);

		return format.format(calendar.getTime());
	}

	/**
	 * 功能描述: 获取当前年份。
	 * 
	 * @return
	 */
	public static int getCurrentYear() {
		return Calendar.getInstance().get(Calendar.YEAR);
	}

	/**
	 * 功能描述: 获取当前月份
	 * 
	 * @return
	 */
	public static int getCurrentMonth() {
		return Calendar.getInstance().get(Calendar.MONTH) + 1;
	}

	/**
	 * 功能描述: 获取当前月份的日
	 * 
	 * @return
	 */
	public static int getCurrentDayOfMonth() {
		return Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
	}

	/**
	 * 功能描述: 将yyyy-MM-dd hh24:mi:ss格式时间转化为时间戳
	 */
	public static long getTime(String dateStr) throws ParseException {
		SimpleDateFormat sdf;
		if (dateStr.indexOf("-") > 0) {
			sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		} else
			sdf = new SimpleDateFormat("yyyyMMddHHmmss");
		Date d;
		d = sdf.parse(dateStr);
		return d.getTime();

	}

	public static String toDisplayStr(String dateStr, int formatType) {
		if (formatType >= 1 && formatType <= 4) {
			if (dateStr != null && dateStr.length() >= 6
					&& dateStr.length() <= 14 && formatType != 1) {
				Object charArr = null;
				char[] charArr1;
				switch (formatType) {
				case 2:
					charArr1 = new char[] { '-', '-', ' ', ':', ':' };
					break;
				case 3:
					charArr1 = new char[] { '.', '.', ' ', ':', ':' };
					break;
				case 4:
					charArr1 = new char[] { '年', '月', ' ', ':', ':' };
					break;
				default:
					charArr1 = new char[] { '-', '-', ' ', ':', ':' };
				}

				try {
					SimpleDateFormat ex = null;
					SimpleDateFormat sdf_2 = null;
					switch (dateStr.length()) {
					case 6:
						ex = new SimpleDateFormat("yyyyMM");
						sdf_2 = new SimpleDateFormat("yyyy\'" + charArr1[0]
								+ "\'MM");
						break;
					case 7:
					case 9:
					case 11:
					case 13:
					default:
						return dateStr;
					case 8:
						ex = new SimpleDateFormat("yyyyMMdd");
						sdf_2 = new SimpleDateFormat("yyyy\'" + charArr1[0]
								+ "\'MM\'" + charArr1[1] + "\'dd");
						break;
					case 10:
						ex = new SimpleDateFormat("yyyyMMddHH");
						sdf_2 = new SimpleDateFormat("yyyy\'" + charArr1[0]
								+ "\'MM\'" + charArr1[1] + "\'dd\'"
								+ "+charArr[2]" + "\'HH");
						break;
					case 12:
						ex = new SimpleDateFormat("yyyyMMddHHmm");
						sdf_2 = new SimpleDateFormat("yyyy\'" + charArr1[0]
								+ "\'MM\'" + charArr1[1] + "\'dd\'"
								+ charArr1[2] + "\'HH\'" + charArr1[3] + "\'mm");
						break;
					case 14:
						ex = new SimpleDateFormat("yyyyMMddHHmmss");
						sdf_2 = new SimpleDateFormat("yyyy\'" + charArr1[0]
								+ "\'MM\'" + charArr1[1] + "\'dd\'"
								+ charArr1[2] + "\'HH\'" + charArr1[3]
								+ "\'mm\'" + charArr1[4] + "\'ss");
					}

					return sdf_2.format(ex.parse(dateStr));
				} catch (ParseException var5) {
					return dateStr;
				}
			} else {
				return StringUtils.toVisualString(dateStr);
			}
		} else {
			throw new IllegalArgumentException("时间格式化类型不是合法的值。");
		}
	}

	public static String getCurrTimeStr(int formatType) {
		return getTimeStr(new Date(), formatType);
	}

	public static String getTimeStr(Date date, int formatType) {
		String formatStr = DateUtils.DateFormat
				.getDatetimeFormatStr(formatType);
		SimpleDateFormat sdf = new SimpleDateFormat(formatStr);
		return sdf.format(date);
	}

	public static String getCurrDateStr(int formatType) {
		return getDateStr(new Date(), formatType);
	}

	public static String getDateStr(Date date, int formatType) {
		if (formatType >= 1 && formatType <= 4) {
			String formatStr = DateUtils.DateFormat
					.getDateFormatStr(formatType);
			SimpleDateFormat sdf = new SimpleDateFormat(formatStr);
			return sdf.format(date);
		} else {
			throw new IllegalArgumentException("时间格式化类型不是合法的值。");
		}
	}

	public static class DateFormat {
		public static final int DB_STORE_DATE = 1;
		public static final int HYPHEN_DISPLAY_DATE = 2;
		public static final int DOT_DISPLAY_DATE = 3;
		public static final int CN_DISPLAY_DATE = 4;
		public static final int DB_LONG_DATE = 5;
		public static final String DB_STORE_DATE_FORMAT = "yyyyMMddHHmmss";
		public static final String HYPHEN_DISPLAY_DATE_FORMAT = "yyyy\'-\'MM\'-\'dd HH:mm:ss";
		public static final String DOT_DISPLAY_DATE_FORMAT = "yyyy.MM.dd HH:mm:ss";
		public static final String CN_DISPLAY_DATE_FORMAT = "yyyy\'年\'MM\'月\'dd\'日\' HH:mm:ss";
		public static final String DB_LONG_DATE_FORMAT = "yyyyMMddHHmmssSS";

		public DateFormat() {
		}

		public static final String getDatetimeFormatStr(int formatType) {
			String formatStr = "yyyy\'-\'MM\'-\'dd HH:mm:ss";
			switch (formatType) {
			case 1:
				formatStr = "yyyyMMddHHmmss";
				break;
			case 2:
				formatStr = "yyyy\'-\'MM\'-\'dd HH:mm:ss";
				break;
			case 3:
				formatStr = "yyyy.MM.dd HH:mm:ss";
				break;
			case 4:
				formatStr = "yyyy\'年\'MM\'月\'dd\'日\' HH:mm:ss";
				break;
			case 5:
				formatStr = "yyyyMMddHHmmssSS";
			}

			return formatStr;
		}

		public static final String getDateFormatStr(int formatType) {
			String formatStr = null;
			switch (formatType) {
			case 1:
				formatStr = "yyyyMMdd";
				break;
			case 2:
				formatStr = "yyyy-MM-dd";
				break;
			case 3:
				formatStr = "yyyy.MM.dd";
				break;
			case 4:
				formatStr = "yyyy\'年\'MM\'月\'dd\'日\'";
			}

			return formatStr;
		}
	}
}

配置 configuration

<?xml version="1.0" encoding="utf-8"?>

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:module="http://www.sgcc.com.cn/schema/platform/module" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd  http://www.sgcc.com.cn/schema/platform/module http://www.sgcc.com.cn/schema/platform/module/module.xsd">  
  <!--JDBC DataSource Example-->  
  <!--JNDI DataSource Example-->  
  <!--   
     <bean id="dataSource"
		class="org.springframework.jndi.JndiObjectFactoryBean">
		<property name="jndiName">
			<value>sguap</value>
		</property>
		<property name="resourceRef">
			<value>true</value>
		</property>
	</bean> 
  -->  
  <module:service id="dataSourceService" beanId="dataSource" targetName="javax.sql.DataSource"/>  
  <bean id="dataSource" name="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="oracle.jdbc.OracleDriver"/>
    <property name="url" value="jdbc:oracle:thin:@192.168.100.105:1521:orcl"/>
    <!-- <property name="url" value="jdbc:oracle:thin:@47.97.190.41:1521:orcl"/> -->
    <property name="username" value="gdprs"/>
    <property name="password" value="geostar_0591"/>
    <property name="maxActive" value="100"/>
    <property name="maxIdle" value="30"/>
    <property name="maxWait" value="5000"/>
    <property name="defaultAutoCommit" value="true"/>
    <property name="removeAbandoned" value="true"/>
    <property name="removeAbandonedTimeout" value="60"/>
    <property name="logAbandoned" value="true"/>
  </bean>
</beans>

猜你喜欢

转载自blog.csdn.net/qq_40279809/article/details/85335561