新增授权码和第三方jar

This commit is contained in:
weizhiqiang 2019-10-12 18:32:55 +08:00
parent 00bbbcf357
commit 5cff2d1c38
48 changed files with 400 additions and 4920 deletions

View file

@ -19,13 +19,6 @@
<dependencies> <dependencies>
<!-- 引入公共模块的依赖 -->
<dependency>
<groupId>com.erp</groupId>
<artifactId>erp-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<!-- 引入redis的依赖 --> <!-- 引入redis的依赖 -->
<dependency> <dependency>
<groupId>com.erp</groupId> <groupId>com.erp</groupId>

17
erp-common/.gitignore vendored
View file

@ -1,17 +0,0 @@
*.class
# Package Files #
*.war
*.ear
class
.idea
*.iml
.settings
*.classpath
/bin
classes
/target/
/.project/
/.metadata/
/logs/

View file

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>erp-common</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View file

@ -1,21 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.erp</groupId>
<artifactId>erp-pro</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>erp-common</artifactId>
<dependencies>
<!-- 引入中文拼音的依赖 -->
<dependency>
<groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId>
<version>2.5.0</version>
</dependency>
</dependencies>
</project>

View file

@ -1,42 +0,0 @@
package com.skyeye.common.constans;
public enum CheckType {
NO("无验证", 0),
EMAIL("Email", 1),
STRLEN("字符长度", 2),
UNSTRCN("禁止中文", 3),
STRCN("仅许中文", 4),
NUM("数值", 5),
TELENUM("电话号码", 6),
PHONENUM("手机号码", 7),
DATE("日期", 8),
IDENTCODE("身份证号", 9),
ZIPCODE("邮政编码", 10),
URL("网址", 11),
TELE_PHONE_NUM("电话或手机号", 12);
private String name;
private int index;
private CheckType(String name, int index) {
this.name = name;
this.index = index;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
}

View file

@ -1,171 +0,0 @@
package com.skyeye.common.constans;
import java.util.Map;
/**
*
* @ClassName: Constans
* @Description: 常量类
* @author 卫志强
* @date 2018年6月7日
*
*/
public class Constants {
/**
* 过滤器过滤文件目录请求项
*/
public static final String[] FILTER_FILE_CATALOG_OPTION = { "/html",
"/css", "/js", "/assets", "/tpl", "/images", "/template", "/static" };
/**
* 过滤器过滤文件后缀请求项
*/
public static final String[] FILTER_FILE_SUFFIX_OPTION = { ".json", ".css",
".js", ".gif", ".jpg", ".eot", ".svg", ".ttf", ".woff", ".woff2",
".mp4", ".rmvb", ".avi", "3gp", ".html", ".less", ".otf", ".scss",
".ico" };
/**
* 服务器远程
*/
public static int MACHINE_USER_USED = 0; //使用中
public static int MACHINE_USER_USE = 1; //可以使用
/**
* IP过滤
*/
public static final String[] FILTER_FILE_IP_OPTION = { "0:0:0:0:0:0:0:1", "127.0.0.1"};
/**
* 过滤器过滤请求类型项
*/
public static final String[] FILTER_FILE_REQUEST_OPTION = { "/post", "/websocket", "/service" };
public static final String[] FILTER_FILE_NO_SESSION_REQUEST_OPTION = { "/service", "/talkwebsocket" };
/**
* 登录页面
*/
public static final String LOGIN_PAGE = "/tpl/index/login.html";
/**
* 控制页面
*/
public static final String INDEX_PAGE = "/tpl/index/index.html";
/**
* 404
*/
public static final String FZF_PAGE = "/tpl/sysmessage/404.html";
/**
* 500
*/
public static final String FZZ_PAGE = "/tpl/sysmessage/500.html";
/**
* 403
*/
public static final String FZT_PAGE = "/tpl/sysmessage/403.html";
/**
* 系统请求参数集合
*/
public static Map<String, Map<String, Object>> REQUEST_MAPPING = null;
/**
* 网页请求发送的contentType格式
*/
public static final String CONENT_TYPE_WEB_REQ = "application/x-www-form-urlencoded";
/**
* json数据请求发送的数据格式
*/
public static final String CONENT_TYPE_JSON_REQ = "application/json";
/**
* 用户状态
*/
public static final String SYS_USER_LOCK_STATE_ISUNLOCK = "0";//未锁定
public static final String SYS_USER_LOCK_STATE_ISLOCK = "1";//锁定
/**
* 菜单类型
*/
public static final String SYS_MENU_TYPE_IS_IFRAME = "iframe";
public static final String SYS_MENU_TYPE_IS_HTML = "html";
/**
* 菜单链接打开类型父菜单默认为1.1打开iframe2打开html
*/
public static final String SYS_MENU_OPEN_TYPE_IS_IFRAME = "1";
public static final String SYS_MENU_OPEN_TYPE_IS_HTML = "2";
/**
* 可以设置长些防止读到运行此次系统检查时的cpu占用率就不准了
*/
public static final int CPUTIME = 5000;
public static final int PERCENT = 100;
public static final int FAULTLENGTH = 10;
//win系统桌面图片列表的redis的key
public static final String SYS_WIN_BG_PIC_REDIS_KEY = "sys_win_bg_pic_redis_key";
public static String getSysWinBgPicRedisKey() {
return SYS_WIN_BG_PIC_REDIS_KEY;
}
//win系统锁屏桌面图片列表的redis的key
public static final String SYS_WIN_LOCK_BG_PIC_REDIS_KEY = "sys_win_lock_bg_pic_redis_key";
public static String getSysWinLockBgPicRedisKey() {
return SYS_WIN_LOCK_BG_PIC_REDIS_KEY;
}
//win系统主题颜色列表的redis的key
public static final String SYS_WIN_THEME_COLOR_REDIS_KEY = "sys_win_theme_color_redis_key";
public static String getSysWinThemeColorRedisKey() {
return SYS_WIN_THEME_COLOR_REDIS_KEY;
}
//消息在redis中已读的key
public static final String SYS_ALWAYS_READ_MESSAGE_BY_ID = "sys_always_read_message_by_id_";
public static String getAlwaysReadMessageById(String id) {
return SYS_ALWAYS_READ_MESSAGE_BY_ID + id;
}
//消息在redis中已删除的key
public static final String SYS_ALWAYS_DEL_MESSAGE_BY_ID = "sys_always_del_message_by_id_";
public static String getAlwaysDelMessageById(String id) {
return SYS_ALWAYS_DEL_MESSAGE_BY_ID + id;
}
//消息在redis中内容的key
public static final String SYS_ALWAYS_CONTENT_MESSAGE_BY_ID = "sys_always_content_message_by_id_";
public static String getAlwaysContentMessageById(String id) {
return SYS_ALWAYS_CONTENT_MESSAGE_BY_ID + id;
}
//聊天获取当前登陆用户信息在redis中的key
public static final String SYS_TALK_USER_THIS_MATN_MATION = "sys_talk_user_this_matn_mation_";
public static String getSysTalkUserThisMainMationById(String id){
return SYS_TALK_USER_THIS_MATN_MATION + id;
}
//聊天获取当前登陆用户拥有的群组列表在redis中的key
public static final String SYS_TALK_USER_HAS_GROUP_LIST_MATION = "sys_talk_user_has_group_list_mation_";
public static String getSysTalkUserHasGroupListMationById(String id){
return SYS_TALK_USER_HAS_GROUP_LIST_MATION + id;
}
//聊天获取分组下的用户列表信息在redis中的key
public static final String SYS_TALK_GROUP_USER_LIST_MATION = "sys_talk_group_user_list_mation_";
public static String getSysTalkGroupUserListMationById(String id){
return SYS_TALK_GROUP_USER_LIST_MATION + id;
}
//获取已经上线的图片类型列表的redis的key
public static final String SYS_EVE_PIC_TYPE_UP_STATE_LIST = "sys_eve_pic_type_up_state_list";
public static String sysEvePicTypeUpStateList() {
return SYS_EVE_PIC_TYPE_UP_STATE_LIST;
}
}

View file

@ -1,131 +0,0 @@
package com.skyeye.common.constans;
public enum QuType {
YESNO("是非题", "yesno", 0, "", ""),
RADIO("单选题", "radio", 1, "dw_qu_radio", "qu_id"),
CHECKBOX("多选题", "checkbox", 2, "dw_qu_checkbox", "qu_id"),
FILLBLANK("填空题", "fillblank", 3, "", ""),
MULTIFILLBLANK("多项填空题", "multi-fillblank", 4, "dw_qu_multi_fillblank", "qu_id"), // 组合填空题
ANSWER("多行填空题", "answer", 5, "", ""), // 原问答题
BIGQU("大题", "bigqu", 6, "", ""),
ENUMQU("枚举题", "enumqu", 7, "", ""),
SCORE("评分题", "score", 8, "dw_qu_score", "qu_id"),
ORDERQU("排序题", "orderby", 9, "dw_qu_orderby", "qu_id"),
PROPORTION("比重题", "proportion", 10, "", ""),
CHENRADIO("矩阵单选题", "chen-radio", 11, "dw_qu_chen_column,dw_qu_chen_row", "qu_id,qu_id"),
CHENFBK("矩阵填空题", "chen-fbk", 12, "dw_qu_chen_column,dw_qu_chen_row", "qu_id,qu_id"),
CHENCHECKBOX("矩阵多选题", "chen-checkbox", 13, "dw_qu_chen_column,dw_qu_chen_row", "qu_id,qu_id"),
COMPCHENRADIO("复合矩阵单选题", "comp-chen-radio", 14, "", ""),
UPLOADFILE("文件上传题", "sendfile", 15, "", ""),
PAGETAG("分页标记", "pagetag", 16, "", ""),
PARAGRAPH("段落说明", "paragraph", 17, "", ""),
CHENSCORE("矩阵评分题", "chen-score", 18, "dw_qu_chen_column,dw_qu_chen_row", "qu_id,qu_id"),
COMPRADIO("复合单选", "comp-radio", 19, "", ""),
COMPCHECKBOX("复合多选", "comp-checkbox", 20, "", "");
private String cnName;
private String actionName;
private int index;
private String tableName;
private String questionId;
QuType(String cnName, String actionName, int index, String tableName, String questionId) {
this.cnName = cnName;
this.actionName = actionName;
this.index = index;
this.tableName = tableName;
this.questionId = questionId;
}
public String getCnName() {
return cnName;
}
public void setCnName(String cnName) {
this.cnName = cnName;
}
public String getActionName() {
return actionName;
}
public void setActionName(String actionName) {
this.actionName = actionName;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
public String getQuestionId() {
return questionId;
}
public void setQuestionId(String questionId) {
this.questionId = questionId;
}
public static String getActionName(int index){
for (QuType q : QuType.values()){
if(q.getIndex() == index){
return q.actionName;
}
}
return null;
}
public static String getCName(int index){
for (QuType q : QuType.values()){
if(q.getIndex() == index){
return q.cnName;
}
}
return null;
}
public static String getTableName(int index){
for (QuType q : QuType.values()){
if(q.getIndex() == index){
return q.tableName;
}
}
return null;
}
public static String getQuestionId(int index){
for (QuType q : QuType.values()){
if(q.getIndex() == index){
return q.questionId;
}
}
return null;
}
public static int getIndex(String actionName){
for (QuType q : QuType.values()){
if(q.getActionName().replaceAll("-", "").equals(actionName.toLowerCase())){
return q.index;
}
}
return -1;
}
}

View file

@ -1,79 +0,0 @@
package com.skyeye.common.object;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
/**
* request 对象的相关操作
* @author 卫志强
* @version 1.0
* @created 2017年07月02日 上午8:25:43
*/
public class GetRequestJsonUtils {
/***
* 获取 request json 字符串的内容
*
* @param request
* @return : <code>byte[]</code>
* @throws IOException
*/
public static String getRequestJsonString(HttpServletRequest request) throws IOException {
String submitMehtod = request.getMethod();
// GET
if (submitMehtod.equals("GET")) {
return new String(request.getQueryString().getBytes("iso-8859-1"),"utf-8").replaceAll("%22", "\"");
// POST
} else {
return getRequestPostStr(request);
}
}
/**
* 描述:获取 post 请求的 byte[] 数组
* <pre>
* 举例
* </pre>
* @param request
* @return
* @throws IOException
*/
public static byte[] getRequestPostBytes(HttpServletRequest request) throws IOException {
int contentLength = request.getContentLength();
if(contentLength<0){
return null;
}
byte buffer[] = new byte[contentLength];
for (int i = 0; i < contentLength;) {
int readlen = request.getInputStream().read(buffer, i,
contentLength - i);
if (readlen == -1) {
break;
}
i += readlen;
}
return buffer;
}
/**
* 描述:获取 post 请求内容
* <pre>
* 举例
* </pre>
* @param request
* @return
* @throws IOException
*/
public static String getRequestPostStr(HttpServletRequest request) throws IOException {
byte buffer[] = getRequestPostBytes(request);
String charEncoding = request.getCharacterEncoding();
if (charEncoding == null) {
charEncoding = "UTF-8";
}
return new String(buffer, charEncoding);
}
}

View file

@ -1,317 +0,0 @@
package com.skyeye.common.object;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.alibaba.fastjson.JSON;
import com.skyeye.common.constans.Constants;
import com.skyeye.common.util.ToolUtil;
public class InputObject extends PutObject implements Serializable{
/**
* @Fields serialVersionUID : 标识
*/
private static final long serialVersionUID = 1L;
public static Set<String> keySet;
private static Map<String, Object> USER_MATION = null;//用户信息
private static List<Map<String, Object>> USER_DESKTOP_MENU_MATION = null;//用户桌面菜单信息
private static List<Map<String, Object>> USER_ALL_MENU_MATION = null;//用户全部菜单信息
/**
* 网页请求content-type为application/x-www-form-urlencoded
* @throws Exception
*/
public static String setParams() throws Exception{
//以Map集合存储页面表单传递过来的所有参数的键值对
String key = getRequest().getParameter("sessionKey");
String contentType = getRequest().getContentType();
if(contentType == null){
Map<String, String[]> formMap = getRequest().getParameterMap();
return setParamsToMapReToStr(key, formMap);
}else{
if(contentType.contains(Constants.CONENT_TYPE_WEB_REQ)){//网页端请求
Map<String, String[]> formMap = getRequest().getParameterMap();
return setParamsToMapReToStr(key, formMap);
}else if(contentType.indexOf(Constants.CONENT_TYPE_JSON_REQ)!=-1){//json数据请求
String str = GetRequestJsonUtils.getRequestJsonString(getRequest());
ThreadCache.setPostRequestParams(str);
try{
String allUse = Constants.REQUEST_MAPPING.get(key).get("allUse").toString();
Map<String, Object> map = JSON.parseObject(str);
if("1".equals(allUse) || "2".equals(allUse)){//需要登录才能访问
if(!map.containsKey("userToken")){//usertoken键不存在
return "缺失重要参数";
}
}
}catch(Exception e){
Map<String, Object> formMap = ToolUtil.getUrlParams(str);
return setParamsObjToMapReStr(key, formMap);
}
}else{
Map<String, String[]> formMap = getRequest().getParameterMap();
return setParamsToMapReToStr(key, formMap);
}
}
return null;
}
@SuppressWarnings("unchecked")
public static String setParamsToMapReToStr(String key, Map<String, String[]> formMap){
List<Map<String, Object>> propertys = (List<Map<String, Object>>) Constants.REQUEST_MAPPING.get(key).get("list");
String allUse = Constants.REQUEST_MAPPING.get(key).get("allUse").toString();
if("1".equals(allUse) || "2".equals(allUse)){//需要登录才能访问
if(!formMap.containsKey("userToken")){//usertoken键不存在
return "缺失重要参数";
}
}
for(Map<String, Object> item : propertys){
if(!formMap.containsKey(item.get("id"))){//键不存在
return "缺失参数";
}else{
String [] ref = item.get("ref").toString().split(",");
String [] value = (String[]) formMap.get(item.get("id").toString());
StringBuffer stb = new StringBuffer();
for(int i = 0; i < value.length; i++){
stb.append(value[i]);
}
String resultStr = ToolUtil.containsBoolean(ref, stb.toString());
if(!ToolUtil.isBlank(resultStr)){
return "参数:" + item.get("id").toString() + resultStr;
}
}
}
return null;
}
@SuppressWarnings("unchecked")
public static String setParamsObjToMapReStr(String key, Map<String, Object> formMap) throws Exception{
List<Map<String, Object>> propertys = (List<Map<String, Object>>) Constants.REQUEST_MAPPING.get(key).get("list");
String allUse = Constants.REQUEST_MAPPING.get(key).get("allUse").toString();
if("1".equals(allUse) || "2".equals(allUse)){//需要登录才能访问
if(!formMap.containsKey("userToken")){//usertoken键不存在
return "缺失重要参数";
}
}
for(Map<String, Object> item : propertys){
if(!formMap.containsKey(item.get("id"))){//键不存在
return "缺失参数";
}else{
String [] ref = item.get("ref").toString().split(",");
String value = java.net.URLDecoder.decode(formMap.get(item.get("id").toString()).toString(), "UTF-8").toString();
String resultStr = ToolUtil.containsBoolean(ref, value);
if(!ToolUtil.isBlank(resultStr)){
return "参数:" + item.get("id").toString() + resultStr;
}
}
}
return null;
}
public static Map<String, Object> getMap() throws Exception{
//以Map集合存储页面表单传递过来的所有参数的键值对
String key = getRequest().getParameter("sessionKey");
String contentType = getRequest().getContentType();
if(contentType == null){
Map<String, String[]> formMap = getRequest().getParameterMap();
return setParamsToMap(key, formMap);
}else{
if(contentType.contains(Constants.CONENT_TYPE_WEB_REQ)){//网页端请求
Map<String, String[]> formMap = getRequest().getParameterMap();
return setParamsToMap(key, formMap);
}else if(contentType.indexOf(Constants.CONENT_TYPE_JSON_REQ)!=-1){//json数据请求
String str = ThreadCache.getPostRequestParams();
try{
Map<String, Object> map = new HashMap<>();
String allUse = Constants.REQUEST_MAPPING.get(key).get("allUse").toString();
map = JSON.parseObject(str);
if("1".equals(allUse) || "2".equals(allUse)){//需要登录才能访问
String [] value = (String[]) map.get("userToken");
StringBuffer stb = new StringBuffer();
for(int i = 0; i < value.length; i++){
stb.append(value[i]);
}
map.put("userToken", stb.toString());
}
map.put("urlUseJurisdiction", allUse);//URL访问权限参数
return map;
}catch(Exception e){
Map<String, Object> formMap = ToolUtil.getUrlParams(str);
return setParamsObjToMap(key, formMap);
}
}else{
Map<String, String[]> formMap = getRequest().getParameterMap();
return setParamsToMap(key, formMap);
}
}
}
public Map<String, Object> getParams() throws Exception {
//以Map集合存储页面表单传递过来的所有参数的键值对
String key = getRequest().getParameter("sessionKey");
String contentType = getRequest().getContentType();
if(contentType == null){
Map<String, String[]> formMap = getRequest().getParameterMap();
return setParamsToMap(key, formMap);
}else{
if(contentType.contains(Constants.CONENT_TYPE_WEB_REQ)){//网页端请求
Map<String, String[]> formMap = getRequest().getParameterMap();
return setParamsToMap(key, formMap);
}else if(contentType.indexOf(Constants.CONENT_TYPE_JSON_REQ)!=-1){//json数据请求
String str = ThreadCache.getPostRequestParams();
try{
Map<String, Object> map = new HashMap<>();
String allUse = Constants.REQUEST_MAPPING.get(key).get("allUse").toString();
map = JSON.parseObject(str);
if("1".equals(allUse) || "2".equals(allUse)){//需要登录才能访问
String [] value = (String[]) map.get("userToken");
StringBuffer stb = new StringBuffer();
for(int i = 0; i < value.length; i++){
stb.append(value[i]);
}
map.put("userToken", stb.toString());
}
map.put("urlUseJurisdiction", allUse);//URL访问权限参数
return map;
}catch(Exception e){
Map<String, Object> formMap = ToolUtil.getUrlParams(str);
return setParamsObjToMap(key, formMap);
}
}else{
Map<String, String[]> formMap = getRequest().getParameterMap();
return setParamsToMap(key, formMap);
}
}
}
@SuppressWarnings("unchecked")
public static Map<String, Object> setParamsToMap(String key, Map<String, String[]> formMap){
Map<String, Object> map = new HashMap<>();
List<Map<String, Object>> propertys = (List<Map<String, Object>>) Constants.REQUEST_MAPPING.get(key).get("list");
String allUse = Constants.REQUEST_MAPPING.get(key).get("allUse").toString();
if("1".equals(allUse) || "2".equals(allUse)){//需要登录才能访问
String [] value = (String[]) formMap.get("userToken");
StringBuffer stb = new StringBuffer();
for(int i = 0; i < value.length; i++){
stb.append(value[i]);
}
map.put("userToken", stb.toString());
}
map.put("urlUseJurisdiction", allUse);//URL访问权限参数
for(Map<String, Object> item : propertys){
String [] ref = item.get("ref").toString().split(",");
String [] value = (String[]) formMap.get(item.get("id").toString());
StringBuffer stb = new StringBuffer();
for(int i = 0; i < value.length; i++){
stb.append(value[i]);
}
String resultStr = ToolUtil.containsBoolean(ref, stb.toString());
if(resultStr == null){
map.put(item.get("name").toString(), stb.toString());
}
}
return map;
}
@SuppressWarnings("unchecked")
public static Map<String, Object> setParamsObjToMap(String key, Map<String, Object> formMap) throws Exception{
Map<String, Object> map = new HashMap<>();
List<Map<String, Object>> propertys = (List<Map<String, Object>>) Constants.REQUEST_MAPPING.get(key).get("list");
String allUse = Constants.REQUEST_MAPPING.get(key).get("allUse").toString();
if("1".equals(allUse) || "2".equals(allUse)){//需要登录才能访问
String [] value = (String[]) formMap.get("userToken");
StringBuffer stb = new StringBuffer();
for(int i = 0; i < value.length; i++){
stb.append(value[i]);
}
map.put("userToken", stb.toString());
}
map.put("urlUseJurisdiction", allUse);//URL访问权限参数
for(Map<String, Object> item : propertys){
String [] ref = item.get("ref").toString().split(",");
String value = java.net.URLDecoder.decode(formMap.get(item.get("id").toString()).toString(), "UTF-8").toString();
String resultStr = ToolUtil.containsBoolean(ref, value);
if(resultStr == null){
map.put(item.get("name").toString(), value);
}
}
return map;
}
/**
* 获取登录信息
* @return
* @throws Exception
*/
public Map<String, Object> getLogParams() throws Exception {
return USER_MATION;
}
/**
* 获取桌面菜单信息
* @return
* @throws Exception
*/
public List<Map<String, Object>> getLogDeskTopMenuParams() throws Exception {
return USER_DESKTOP_MENU_MATION;
}
/**
* 获取所有菜单信息
* @return
* @throws Exception
*/
public List<Map<String, Object>> getLogAllMenuParams() throws Exception {
return USER_ALL_MENU_MATION;
}
public static Map<String, Object> getUSER_MATION() {
return USER_MATION;
}
public static void setUSER_MATION(Map<String, Object> uSER_MATION) {
USER_MATION = uSER_MATION;
}
public static List<Map<String, Object>> getUSER_DESKTOP_MENU_MATION() {
return USER_DESKTOP_MENU_MATION;
}
public static void setUSER_DESKTOP_MENU_MATION(List<Map<String, Object>> uSER_DESKTOP_MENU_MATION) {
USER_DESKTOP_MENU_MATION = uSER_DESKTOP_MENU_MATION;
}
public static List<Map<String, Object>> getUSER_ALL_MENU_MATION() {
return USER_ALL_MENU_MATION;
}
public static void setUSER_ALL_MENU_MATION(List<Map<String, Object>> uSER_ALL_MENU_MATION) {
USER_ALL_MENU_MATION = uSER_ALL_MENU_MATION;
}
public void removeSession() throws Exception {
getRequest().getSession().invalidate();
}
public Set<String> getKeyForRequestMap(){
return keySet;
}
public static Set<String> getKeySet() {
return keySet;
}
public static void setKeySet(Set<String> keySet) {
InputObject.keySet = keySet;
}
}

View file

@ -1,24 +0,0 @@
package com.skyeye.common.object;
public class ObjectConstant {
public static final String CONENT_TYPE_WEB_REQ = "application/x-www-form-urlencoded";//网页请求发送的contentType格式
public static final String CONENT_TYPE_JSON_REQ = "application/json";//json数据请求发送的数据格式
public static final int WRONG = -9999;
public static final String WRONG_MESSAGE = "失败";
public static final String REQUIRED = "required";//请求参数非空
public static final String NUM = "num";//请求参数数字校验
public static final String DATE = "date";//请求参数时间校验
public static final String EMAIL = "email";//请求参数邮箱校验
public static final String IDCARD = "idcard";//请求参数证件号校验
public static final String PHONE = "phone";//请求参数手机号校验
public static final String URL = "url";//请求参数url校验
public static final String IP = "ip";//请求参数ip校验
public static final String POSTCODE = "postcode";//请求参数国内邮编校验
public static final String DOUBLE = "double";//请求参数验证小数点后两位,一般用于金钱验证
}

View file

@ -1,117 +0,0 @@
package com.skyeye.common.object;
import java.io.PrintWriter;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSON;
public class OutputObject extends PutObject implements Serializable{
/**
* @Fields serialVersionUID : 标识
*/
private static final long serialVersionUID = 1L;
public static Map<String, Object> object;
public OutputObject(){
object = new HashMap<String, Object>();
setNull();
}
public void settotal(Object total){
OutputObject.object.put("total", total);
}
public void setreturnMessage(Object returnMessage){
OutputObject.object.put("returnMessage", returnMessage);
}
public void setreturnMessage(Object returnMessage, Object returnCode) throws Exception{
OutputObject.object.put("returnMessage", "错误码:" + returnCode + "错误信息:" + returnMessage);
}
public void setreturnCode(Object returnCode){
OutputObject.object.put("returnCode", returnCode);
}
public static void setErroCode(int code){
OutputObject.object.put("error", code);
}
public void setCustomBean(String key, Map<String,Object> bean) throws Exception {
OutputObject.object.put(key, bean);
}
public void setCustomBeans(String key, List<Map<String,Object>> bean) throws Exception {
OutputObject.object.put(key, bean);
}
public void setBean(Map<String,Object> bean) throws Exception {
OutputObject.object.put("bean", bean);
}
public void setBeans(List<Map<String,Object>> beans) throws Exception {
OutputObject.object.put("rows", beans);
}
public static void setCode(int code){
OutputObject.object.put("returnCode", code);
}
public static void setMessage(String Message){
OutputObject.object.put("returnMessage", Message);
}
public static int getCode(){
if(OutputObject.object == null){
object = new HashMap<String, Object>();
setNull();
}
return Integer.parseInt(OutputObject.object.get("returnCode").toString());
}
public static String getMessage(){
return OutputObject.object.get("returnMessage").toString();
}
public static void put(){
Object context = JSON.toJSON(object);
PrintWriter out = null;
getResponse().setCharacterEncoding("UTF-8");
getResponse().setContentType("text/html;charset=UTF-8");
try {
out = getResponse().getWriter();// 获取输入流
if(out != null){
out.print(context);// 将信息发送到前台
out.flush();// 刷新
}
} catch (Exception e) {
} finally {
if(out != null){
out.close();// 关闭输入流
}
}
}
public static void setNull(){
object.put("returnCode", "-9999");
object.put("error", "0");
object.put("returnMessage", "失败");
object.put("total", 0);
object.put("bean", "");
object.put("rows", "");
}
public Map<String, Object> getObject() {
return object;
}
@SuppressWarnings("static-access")
public void setObject(Map<String, Object> map) {
this.object = map;
}
}

View file

@ -1,44 +0,0 @@
package com.skyeye.common.object;
import java.io.Serializable;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class PutObject implements Serializable{
/**
* @Fields serialVersionUID : 标识
*/
private static final long serialVersionUID = 1L;
private static ThreadLocal<HttpServletRequest> _request = new ThreadLocal<HttpServletRequest>();
private static ThreadLocal<HttpServletResponse> _response = new ThreadLocal<HttpServletResponse>();
public PutObject(){
}
public PutObject(HttpServletRequest request, HttpServletResponse response){
_request.set(request);
_response.set(response);
}
public static HttpServletRequest getRequest() {
HttpServletRequest request = _request.get();
return request;
}
public static HttpServletResponse getResponse() {
HttpServletResponse response = _response.get();
return response;
}
public static void removeRequest() {
_request.remove();
_response.remove();
}
}

View file

@ -1,18 +0,0 @@
package com.skyeye.common.object;
public class ThreadCache {
// ThreadLocal里只存储了简单的String对象也可以自己定义对象存储更加复杂的参数
private static ThreadLocal<String> threadLocal = new ThreadLocal<String>();
public static String getPostRequestParams(){
return threadLocal.get();
}
public static void setPostRequestParams(String postRequestParams) {
threadLocal.set(postRequestParams);
}
public static void removePostRequestParams() {
threadLocal.remove();
}
}

View file

@ -1,109 +0,0 @@
package com.skyeye.common.util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import org.apache.commons.lang.StringUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
public class AreaUtil {
/** 获取地区api */
private static final String URL_JD_AREA = "https://d.jd.com/area/get?fid=%d";
/** 初始化省份数据 */
private static final String[] TABLE_PROVINCE = new String[] { "1", "北京", "2", "上海", "3", "天津", "4", "重庆", "5", "河北",
"6", "山西", "7", "河南", "8", "辽宁", "9", "吉林", "10", "黑龙江", "11", "内蒙古", "12", "江苏", "13", "山东", "14", "安徽",
"15", "浙江", "16", "福建", "17", "湖北", "18", "湖南", "19", "广东", "20", "广西", "21", "江西", "22", "四川", "23", "海南",
"24", "贵州", "25", "云南", "26", "西藏", "27", "陕西", "28", "甘肃", "29", "青海", "30", "宁夏", "31", "新疆", "32", "台湾",
"42", "香港", "43", "澳门", "84", "钓鱼岛" };
/**
* 初始化省份数据
*
* @param conn
*/
public static void initArea() {
try {
Connection conn = getConn("127.0.0.1", "3306", "eve", "root", "123456");
for (int nIndex = 0; nIndex < TABLE_PROVINCE.length; nIndex = nIndex + 2) {
int id = Integer.parseInt(TABLE_PROVINCE[nIndex]);
String name = TABLE_PROVINCE[nIndex + 1];
try {
Statement stat = conn.createStatement();
String sql = "INSERT INTO t_area VALUES ('" + ToolUtil.getSurFaceId() + "'," + id + ", '" + name + "', 0, 0)";
stat.execute(sql);
stat.close();
System.out.println("查询:" + name + "--级别0");
initChildArea(conn, id, 1);
} catch (SQLException e) {
e.printStackTrace();
}
}
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 获取各省下级地区
*
* @param conn 数据库连接对象
* @param parentId 所属地区ID
* @param level 地区层级省级0市级1...
*/
public static void initChildArea(Connection conn, int parentId, int level) {
String url = String.format(URL_JD_AREA, parentId);
String text = HttpClient.doGet(url);
if (!StringUtils.isEmpty(text)) {
JSONArray array = JSON.parseArray(text);
if (array != null && array.size() > 0) {
for (int nIndex = 0; nIndex < array.size(); nIndex++) {
JSONObject object = array.getJSONObject(nIndex);
int id = object.getInteger("id");
String name = object.getString("name");
try {
Statement stat = conn.createStatement();
String sql = "INSERT INTO t_area VALUES ('" + ToolUtil.getSurFaceId() + "'," + id + ", '" + name + "'," + parentId + ", " + level + ")";
stat.execute(sql);
stat.close();
System.out.println("查询:" + name + "--级别:" + level);
initChildArea(conn, id, level + 1);
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
}
/**
* 链接数据库
*
* @param dbHost 数据库主机地址
* @param dbPort 数据库端口
* @param dbName 数据库名称
* @param dbUser 数据库用户名称
* @param dbPassword 数据库登录密码
* @return
* @throws Exception
*/
public static Connection getConn(String dbHost, String dbPort, String dbName, String dbUser, String dbPassword) throws Exception {
Class.forName("com.mysql.jdbc.Driver");
Class.forName("com.mysql.jdbc.Driver").newInstance();
String connStr = "jdbc:mysql://" + dbHost + ":" + dbPort + "/" + dbName + "?user=" + dbUser + "&password=" + dbPassword + "&characterEncoding=utf8";
Connection conn = DriverManager.getConnection(connStr);
return conn;
}
public static void main(String[] args) {
initArea();
}
}

View file

@ -1,25 +0,0 @@
package com.skyeye.common.util;
/**
* byte操作类.
* @author Administrator
*
*/
public class Bytes {
/**
* 由于String.subString对汉字处理存在问题把一个汉字视为一个字节)因此在 包含汉字的字符串时存在隐患现调整如下
* @param src 要截取的字符串
* @param start_idx 开始坐标包括该坐标)
* @param end_idx 截止坐标包括该坐标
* @return
*/
public static String substring(String src, int start_idx, int end_idx) {
byte[] b = src.getBytes();
String tgt = "";
for (int i = start_idx; i <= end_idx; i++) {
tgt += (char) b[i];
}
return tgt;
}
}

View file

@ -1,298 +0,0 @@
package com.skyeye.common.util;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.DataFormat;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
public class ExcelUtil {
/**
* 创建excel文档
*
* @param list
* 数据
* @param keys
* list中map的key数组集合
* @param columnNames
* excel的列名
* @throws Exception
*/
public static void createWorkBook(String fileName, String sheetName, List<Map<String, Object>> list, String[] keys,
String columnNames[], String dataType[], HttpServletResponse response) throws Exception {
// 创建excel工作簿
Workbook wb = new HSSFWorkbook();
// 创建第一个sheet并命名
Sheet sheet = wb.createSheet(sheetName);
// 手动设置列宽第一个参数表示要为第几列设第二个参数表示列的宽度n为列高的像素数
for (int i = 0; i < keys.length; i++) {
sheet.setColumnWidth((short) i, (short) (35.7 * 150));
}
// 创建第一行
Row row = sheet.createRow((short) 0);
//获取样式
CellStyle titleStyle = getTextCellStyle(wb, true);//标题style
CellStyle dataStyle = getDataCellStyle(wb, false);//日期style
CellStyle contextStyle = getTextCellStyle(wb, false);//文本style
// 设置列名
for (int i = 0; i < columnNames.length; i++) {
Cell cell = row.createCell(i);
cell.setCellValue(columnNames[i]);
cell.setCellStyle(titleStyle);
}
// 设置格式
if (dataType.length > 0 && dataType != null) {
for (short j = 0; j < 500; j++) {
Row item = sheet.createRow((short) (j + 1));
for (short i = 0; i < dataType.length; i++) {
Cell cellItem = item.createCell(i);
if ("data".equals(dataType[i])) {
cellItem.setCellStyle(dataStyle);// 日期
} else {
cellItem.setCellStyle(contextStyle);
}
}
}
}
if (list != null && !list.isEmpty()) {
// 设置每行每列的值
for (short i = 0; i < list.size(); i++) {
// Row ,Cell 方格 , Row Cell 都是从0开始计数的
// 创建一行在页sheet上
Row row1 = sheet.createRow((short) (i + 1));
// 在row行上创建一个方格
for (short j = 0; j < keys.length; j++) {
Cell cell = row1.createCell(j);
cell.setCellValue(list.get(i).get(keys[j]) == null ? " " : list.get(i).get(keys[j]).toString());
cell.setCellStyle(contextStyle);
}
}
}
// 输出文件
fileWrite(wb, response, fileName);
}
/**
* 获取日期格式的列格式
*
* @param wb
* @param isTitle
* 是否是标题
* @return
*/
public static CellStyle getDataCellStyle(Workbook wb, boolean isTitle) {
CellStyle cellStyle = wb.createCellStyle();
DataFormat format = wb.createDataFormat();
cellStyle.setDataFormat(format.getFormat("yyyy年mm月dd日"));
return getDataStyle(wb, cellStyle, isTitle);
}
/**
* 获取文本格式的列格式
*
* @param wb
* @param isTitle
* 是否是标题
* @return
*/
public static CellStyle getTextCellStyle(Workbook wb, boolean isTitle) {
CellStyle cellStyle = wb.createCellStyle();
return getDataStyle(wb, cellStyle, isTitle);
}
/**
* 获取样式
*
* @param wb
* @param cellStyle
* @param isTitle
* 是否是标题
* @return
*/
public static CellStyle getDataStyle(Workbook wb, CellStyle cellStyle, boolean isTitle) {
if (isTitle) {// 标题
Font f = wb.createFont();
// 创建第一种字体样式用于列名
f.setFontHeightInPoints((short) 15);
f.setColor(IndexedColors.BLACK.getIndex());
f.setBoldweight(Font.BOLDWEIGHT_BOLD);
// 设置第一种单元格的样式用于列名
cellStyle.setFont(f);
cellStyle.setBorderLeft(CellStyle.BORDER_THIN);
cellStyle.setBorderRight(CellStyle.BORDER_THIN);
cellStyle.setBorderTop(CellStyle.BORDER_THIN);
cellStyle.setBorderBottom(CellStyle.BORDER_THIN);
cellStyle.setAlignment(CellStyle.ALIGN_CENTER);
} else {//
// 创建两种字体
Font f2 = wb.createFont();
// 创建第二种字体样式用于值
f2.setFontHeightInPoints((short) 12);
f2.setColor(IndexedColors.BLACK.getIndex());
// 设置第二种单元格的样式用于值
cellStyle.setFont(f2);
cellStyle.setBorderLeft(CellStyle.BORDER_THIN);
cellStyle.setBorderRight(CellStyle.BORDER_THIN);
cellStyle.setBorderTop(CellStyle.BORDER_THIN);
cellStyle.setBorderBottom(CellStyle.BORDER_THIN);
cellStyle.setAlignment(CellStyle.ALIGN_CENTER);
}
return cellStyle;
}
/**
* 输出文件
*
* @param wb
* @param response
* @param fileName
* @throws Exception
*/
public static void fileWrite(Workbook wb, HttpServletResponse response, String fileName) throws Exception {
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
wb.write(os);
} catch (IOException e) {
e.printStackTrace();
}
byte[] content = os.toByteArray();
InputStream is = new ByteArrayInputStream(content);
// 设置response参数可以打开下载页面
response.reset();
response.setContentType("application/vnd.ms-excel;charset=utf-8");
response.setHeader("Content-Disposition",
"attachment;filename=" + new String((fileName + ".xls").getBytes(), "iso-8859-1"));
ServletOutputStream out = response.getOutputStream();
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
bis = new BufferedInputStream(is);
bos = new BufferedOutputStream(out);
byte[] buff = new byte[2048];
int bytesRead;
while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
bos.write(buff, 0, bytesRead);
}
} catch (final IOException e) {
throw e;
} finally {
if (bis != null)
bis.close();
if (bos != null)
bos.close();
}
}
/**
* 读取Excel数据内容
* @param is
* @return 含单元格数据内容的Map对象
*/
public static List<List<String>> readExcelContent(InputStream is) {
List<List<String>> content = new ArrayList<List<String>>();
POIFSFileSystem fs;
Workbook wb;
Sheet sheet;
Row row;
String str = "";
try {
fs = new POIFSFileSystem(is);
wb = new HSSFWorkbook(fs);
sheet = wb.getSheetAt(0);
// 得到总行数
int rowNum = sheet.getLastRowNum();
row = sheet.getRow(0);
int colNum = row.getPhysicalNumberOfCells();
// 正文内容应该从第二行开始,第一行为表头的标题
for (int i = 1; i <= rowNum; i++) {
row = sheet.getRow(i);
int j = 0;
List<String> list = new ArrayList<String>();
while (j < colNum) {
// 每个单元格的数据内容用"-"分割开以后需要时用String类的replace()方法还原数据
// 也可以将每个单元格的数据设置到一个javabean的属性中此时需要新建一个javabean
// str += getStringCellValue(row.getCell((short) j)).trim()
// +
// "-";
str = getCellFormatValue(row.getCell((short) j)).trim();
list.add(str);
j++;
}
content.add(list);
str = "";
}
} catch (IOException e) {
e.printStackTrace();
}
return content;
}
/**
* 根据HSSFCell类型设置数据
*
* @param cell
* @return
*/
private static String getCellFormatValue(Cell cell) {
String cellvalue = "";
if (cell != null) {
// 判断当前Cell的Type
switch (cell.getCellType()) {
// 如果当前Cell的Type为NUMERIC
case Cell.CELL_TYPE_NUMERIC:
case Cell.CELL_TYPE_FORMULA: {
// 判断当前的cell是否为Date
if (DateUtil.isCellDateFormatted(cell)) {
Date date = cell.getDateCellValue();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
cellvalue = sdf.format(date);
}else {
if("yyyy年mm月dd日".equals(cell.getCellStyle().getDataFormatString().replaceAll("\"", ""))){
Date date = cell.getDateCellValue();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
cellvalue = sdf.format(date);
}else{// 如果是纯数字
// 取得当前Cell的数值
cellvalue = String.valueOf(cell.getNumericCellValue());
}
}
break;
}
case Cell.CELL_TYPE_STRING:// 如果当前Cell的Type为STRIN
// 取得当前的Cell字符串
cellvalue = cell.getRichStringCellValue().getString();
break;
default:// 默认的Cell值
cellvalue = " ";
}
} else {
cellvalue = "";
}
return cellvalue;
}
}

View file

@ -1,230 +0,0 @@
package com.skyeye.common.util;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
public class HttpClient {
public static String doGet(String httpurl) {
HttpURLConnection connection = null;
InputStream is = null;
BufferedReader br = null;
String result = null;// 返回结果字符串
try {
// 创建远程url连接对象
URL url = new URL(httpurl);
// 通过远程url连接对象打开一个连接强转成httpURLConnection类
connection = (HttpURLConnection) url.openConnection();
// 设置连接方式get
connection.setRequestMethod("GET");
// 设置连接主机服务器的超时时间15000毫秒
connection.setConnectTimeout(15000);
// 设置读取远程返回的数据时间60000毫秒
connection.setReadTimeout(60000);
// 发送请求
connection.connect();
// 通过connection连接获取输入流
if (connection.getResponseCode() == 200) {
is = connection.getInputStream();
// 封装输入流is并指定字符集
br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
// 存放数据
StringBuffer sbf = new StringBuffer();
String temp = null;
while ((temp = br.readLine()) != null) {
sbf.append(temp);
sbf.append("\r\n");
}
result = sbf.toString();
}
} catch (MalformedURLException e) {
return null;
} catch (IOException e) {
return null;
} finally {
// 关闭资源
if (null != br) {
try {
br.close();
} catch (IOException e) {
return null;
}
}
if (null != is) {
try {
is.close();
} catch (IOException e) {
return null;
}
}
connection.disconnect();// 关闭远程连接
}
return result;
}
public static String doPost(String httpUrl, String param) {
HttpURLConnection connection = null;
InputStream is = null;
OutputStream os = null;
BufferedReader br = null;
String result = null;
try {
URL url = new URL(httpUrl);
// 通过远程url连接对象打开连接
connection = (HttpURLConnection) url.openConnection();
// 设置连接请求方式
connection.setRequestMethod("POST");
// 设置连接主机服务器超时时间15000毫秒
connection.setConnectTimeout(15000);
// 设置读取主机服务器返回数据超时时间60000毫秒
connection.setReadTimeout(60000);
// 默认值为false当向远程服务器传送数据/写数据时需要设置为true
connection.setDoOutput(true);
// 默认值为true当前向远程服务读取数据时设置为true该参数可有可无
connection.setDoInput(true);
// 设置传入参数的格式:请求参数应该是 name1=value1&name2=value2 的形式
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
// 设置鉴权信息Authorization: Bearer da3efcbf-0845-4fe3-8aba-ee040be542c0
connection.setRequestProperty("Authorization", "Bearer da3efcbf-0845-4fe3-8aba-ee040be542c0");
// 通过连接对象获取一个输出流
os = connection.getOutputStream();
// 通过输出流对象将参数写出去/传输出去,它是通过字节数组写出的
os.write(param.getBytes());
// 通过连接对象获取一个输入流向远程读取
if (connection.getResponseCode() == 200) {
is = connection.getInputStream();
// 对输入流对象进行包装:charset根据工作项目组的要求来设置
br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
StringBuffer sbf = new StringBuffer();
String temp = null;
// 循环遍历一行一行读取数据
while ((temp = br.readLine()) != null) {
sbf.append(temp);
sbf.append("\r\n");
}
result = sbf.toString();
}
} catch (MalformedURLException e) {
return null;
} catch (IOException e) {
return null;
} finally {
// 关闭资源
if (null != br) {
try {
br.close();
} catch (IOException e) {
return null;
}
}
if (null != os) {
try {
os.close();
} catch (IOException e) {
return null;
}
}
if (null != is) {
try {
is.close();
} catch (IOException e) {
return null;
}
}
// 断开与远程地址url的连接
connection.disconnect();
}
return result;
}
public static String doPost(String url, Map<String, Object> paramMap) {
CloseableHttpClient httpClient = null;
CloseableHttpResponse httpResponse = null;
String result = "";
// 创建httpClient实例
httpClient = HttpClients.createDefault();
// 创建httpPost远程连接实例
HttpPost httpPost = new HttpPost(url);
// 配置请求参数实例
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000)// 设置连接主机服务超时时间
.setConnectionRequestTimeout(35000)// 设置连接请求超时时间
.setSocketTimeout(60000)// 设置读取数据连接超时时间
.build();
// 为httpPost实例设置配置
httpPost.setConfig(requestConfig);
// 设置请求头
httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded");
// 封装post请求参数
if (null != paramMap && paramMap.size() > 0) {
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
// 通过map集成entrySet方法获取entity
Set<Entry<String, Object>> entrySet = paramMap.entrySet();
// 循环遍历获取迭代器
Iterator<Entry<String, Object>> iterator = entrySet.iterator();
while (iterator.hasNext()) {
Entry<String, Object> mapEntry = iterator.next();
nvps.add(new BasicNameValuePair(mapEntry.getKey(), mapEntry.getValue().toString()));
}
// 为httpPost设置封装好的请求参数
try {
httpPost.setEntity(new UrlEncodedFormEntity(nvps, "UTF-8"));
} catch (UnsupportedEncodingException e) {
return null;
}
}
try {
// httpClient对象执行post请求,并返回响应参数对象
httpResponse = httpClient.execute(httpPost);
// 从响应对象中获取响应内容
HttpEntity entity = httpResponse.getEntity();
result = EntityUtils.toString(entity);
} catch (ClientProtocolException e) {
return null;
} catch (IOException e) {
return null;
} finally {
// 关闭资源
if (null != httpResponse) {
try {
httpResponse.close();
} catch (IOException e) {
return null;
}
}
if (null != httpClient) {
try {
httpClient.close();
} catch (IOException e) {
return null;
}
}
}
return result;
}
}

View file

@ -1,171 +0,0 @@
package com.skyeye.common.util;
import java.lang.management.ManagementFactory;
import java.net.InetAddress;
import java.net.NetworkInterface;
/**
* 名称IdWorker.java
* 描述分布式自增长ID
*
* Twitter的 Snowflake JAVA实现方案
*
* 核心代码为其IdWorker这个类实现其原理结构如下我分别用一个0表示一位分割开部分的作用 1||0---0000000000
* 0000000000 0000000000 0000000000 0 --- 00000 ---00000 ---000000000000
* 在上面的字符串中第一位为未使用实际上也可作为long的符号位接下来的41位为毫秒级时间
* 然后5位datacenter标识位5位机器ID并不算标识符实际是为线程标识
* 然后12位该毫秒内的当前毫秒内的计数加起来刚好64位为一个Long型
* 这样的好处是整体上按照时间自增排序并且整个分布式系统内不会产生ID碰撞由datacenter和机器ID作区分
* 并且效率较高经测试snowflake每秒能够产生26万ID左右完全满足需要
* 64位ID (42(毫秒)+5(机器ID)+5(业务编码)+12(重复累加))
*/
public class IdWorker {
// 时间起始标记点作为基准一般取系统的最近时间一旦确定不能变动
private final static long twepoch = 1288834974657L;
// 机器标识位数
private final static long workerIdBits = 5L;
// 数据中心标识位数
private final static long datacenterIdBits = 5L;
// 机器ID最大值
private final static long maxWorkerId = -1L ^ (-1L << workerIdBits);
// 数据中心ID最大值
private final static long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
// 毫秒内自增位
private final static long sequenceBits = 12L;
// 机器ID偏左移12位
private final static long workerIdShift = sequenceBits;
// 数据中心ID左移17位
private final static long datacenterIdShift = sequenceBits + workerIdBits;
// 时间毫秒左移22位
private final static long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
private final static long sequenceMask = -1L ^ (-1L << sequenceBits);
/* 上次生产id时间戳 */
private static long lastTimestamp = -1L;
// 0并发控制
private long sequence = 0L;
private final long workerId;
// 数据标识id部分
private final long datacenterId;
public IdWorker() {
this.datacenterId = getDatacenterId(maxDatacenterId);
this.workerId = getMaxWorkerId(datacenterId, maxWorkerId);
}
/**
* @param workerId
* 工作机器ID
* @param datacenterId
* 序列号
*/
public IdWorker(long workerId, long datacenterId) {
if (workerId > maxWorkerId || workerId < 0) {
throw new IllegalArgumentException(
String.format("worker Id can't be greater than %d or less than 0", maxWorkerId));
}
if (datacenterId > maxDatacenterId || datacenterId < 0) {
throw new IllegalArgumentException(
String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId));
}
this.workerId = workerId;
this.datacenterId = datacenterId;
}
/**
* 获取下一个ID
*
* @return
*/
public synchronized long nextId() {
long timestamp = timeGen();
if (timestamp < lastTimestamp) {
throw new RuntimeException(String.format(
"Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
}
if (lastTimestamp == timestamp) {
// 当前毫秒内+1
sequence = (sequence + 1) & sequenceMask;
if (sequence == 0) {
// 当前毫秒内计数满了则等待下一秒
timestamp = tilNextMillis(lastTimestamp);
}
} else {
sequence = 0L;
}
lastTimestamp = timestamp;
// ID偏移组合生成最终的ID并返回ID
long nextId = ((timestamp - twepoch) << timestampLeftShift) | (datacenterId << datacenterIdShift)
| (workerId << workerIdShift) | sequence;
return nextId;
}
private long tilNextMillis(final long lastTimestamp) {
long timestamp = this.timeGen();
while (timestamp <= lastTimestamp) {
timestamp = this.timeGen();
}
return timestamp;
}
private long timeGen() {
return System.currentTimeMillis();
}
/**
* 获取 maxWorkerId
*/
protected static long getMaxWorkerId(long datacenterId, long maxWorkerId) {
StringBuffer mpid = new StringBuffer();
mpid.append(datacenterId);
String name = ManagementFactory.getRuntimeMXBean().getName();
if (!name.isEmpty()) {
/*
* GET jvmPid
*/
mpid.append(name.split("@")[0]);
}
/*
* MAC + PID hashcode 获取16个低位
*/
return (mpid.toString().hashCode() & 0xffff) % (maxWorkerId + 1);
}
/**
* 数据标识id部分
*/
protected static long getDatacenterId(long maxDatacenterId) {
long id = 0L;
try {
InetAddress ip = InetAddress.getLocalHost();
NetworkInterface network = NetworkInterface.getByInetAddress(ip);
if (network == null) {
id = 1L;
} else {
byte[] mac = network.getHardwareAddress();
id = ((0x000000FF & (long) mac[mac.length - 1])
| (0x0000FF00 & (((long) mac[mac.length - 2]) << 8))) >> 6;
id = id % (maxDatacenterId + 1);
}
} catch (Exception e) {
System.out.println(" getDatacenterId: " + e.getMessage());
}
return id;
}
public static void main(String[] args) {
// IdWorker idWorker = new IdWorker(31,31);
// System.out.println("idWorker="+idWorker.nextId());
IdWorker id = new IdWorker(0, 1);
// System.out.println("id="+id.nextId());
// System.out.println(id.datacenterId);
// System.out.println(id.workerId);
for (int i = 0; i < 9000; i++) {
System.err.println(id.nextId());
}
}
}

View file

@ -1,247 +0,0 @@
package com.skyeye.common.util;
import java.awt.image.BufferedImage;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.util.Base64;
import java.util.List;
import java.util.Map;
import java.util.Base64.Decoder;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Value;
import com.itextpdf.text.Document;
import com.itextpdf.text.Element;
import com.itextpdf.text.Font;
import com.itextpdf.text.Image;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
public class PDFReport {
static Document document = new Document();// 建立一个Document对象
private static Font keyfont;// 设置字体大小
private static Font textfont;// 设置字体大小
@Value("${IMAGES_PATH}")
private static String tPath;
public PDFReport(File file) {
BaseFont bfChinese;
try {
URL url = PDFReport.class.getResource("simyou.TTF");
bfChinese = BaseFont.createFont(url.getPath(), BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
new Font(bfChinese, 10, Font.BOLD);
keyfont = new Font(bfChinese, 8, Font.BOLD);// 设置字体大小
textfont = new Font(bfChinese, 8, Font.NORMAL);// 设置字体大小
} catch (Exception e) {
e.printStackTrace();
}
document = new Document();
document.setPageSize(PageSize.A4);// 设置页面大小
try {
PdfWriter.getInstance(document, new FileOutputStream(file));
document.open();
} catch (Exception e) {
e.printStackTrace();
}
}
static int maxWidth = 520;
public static PdfPCell createCell(String value, com.itextpdf.text.Font font, int align) {
PdfPCell cell = new PdfPCell();
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell.setHorizontalAlignment(align);
cell.setPhrase(new Phrase(value, font));
return cell;
}
public static PdfPCell createCell(String value, com.itextpdf.text.Font font) {
PdfPCell cell = new PdfPCell();
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setPhrase(new Phrase(value, font));
return cell;
}
public PdfPCell createCell(String value, com.itextpdf.text.Font font, int align, int colspan) {
PdfPCell cell = new PdfPCell();
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell.setHorizontalAlignment(align);
cell.setColspan(colspan);
cell.setPhrase(new Phrase(value, font));
return cell;
}
public static PdfPCell createCell(String value, com.itextpdf.text.Font font, int align, int colspan, boolean boderFlag) {
PdfPCell cell = new PdfPCell();
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell.setHorizontalAlignment(align);
cell.setColspan(colspan);
cell.setPhrase(new Phrase(value, font));
cell.setPadding(3.0f);
if (!boderFlag) {
cell.setBorder(0);
cell.setPaddingTop(15.0f);
cell.setPaddingBottom(8.0f);
}
return cell;
}
public static PdfPTable createTable(int colNumber) {
PdfPTable table = new PdfPTable(colNumber);
try {
table.setTotalWidth(maxWidth);
table.setLockedWidth(true);
table.setHorizontalAlignment(Element.ALIGN_CENTER);
table.getDefaultCell().setBorder(1);
} catch (Exception e) {
e.printStackTrace();
}
return table;
}
public PdfPTable createTable(float[] widths) {
PdfPTable table = new PdfPTable(widths);
try {
table.setTotalWidth(maxWidth);
table.setLockedWidth(true);
table.setHorizontalAlignment(Element.ALIGN_CENTER);
table.getDefaultCell().setBorder(1);
} catch (Exception e) {
e.printStackTrace();
}
return table;
}
public PdfPTable createBlankTable() {
PdfPTable table = new PdfPTable(1);
table.getDefaultCell().setBorder(0);
table.addCell(createCell("", keyfont));
table.setSpacingAfter(20.0f);
table.setSpacingBefore(20.0f);
return table;
}
/**
*
* @Title: generatePDF
* @Description: pdf导出
* @param @param fileName
* @param @param titleName
* @param @param list
* @param @param keys
* @param @param columnNames
* @param @param request
* @param @param response
* @param @param filePath
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
public static void generatePDF(String fileName, String titleName, List<Map<String, Object>> list, String []keys,
String columnNames[], HttpServletRequest request, HttpServletResponse response, String filePath) throws Exception {
//设置图片
String imgUrl = request.getParameter("base64Info");
if (!ToolUtil.isBlank(imgUrl)) {
String[] imgUrlArr = imgUrl.split("base64,");// 拆分base64编码后部分
Decoder decoder = Base64.getDecoder();
byte[] buffer = decoder.decode(imgUrlArr[1]);
String picPath = tPath + "\\images\\upload\\";
File pack = new File(picPath);// 图片文件
if(!pack.isDirectory())//目录不存在
pack.mkdirs();//创建目录
picPath += ToolUtil.getSurFaceId() + ".png";
File file = new File(picPath);// 图片文件
try {
// 生成图片
OutputStream out = new FileOutputStream(file);// 图片输出流
out.write(buffer);
out.flush();// 清空流
out.close();// 关闭流
ByteArrayOutputStream outStream = new ByteArrayOutputStream(); // 将图片写入流中
BufferedImage bufferImg = ImageIO.read(new File(picPath));
ImageIO.write(bufferImg, "PNG", outStream);
//
Image png = Image.getInstance(picPath);
png.setAlignment(Image.ALIGN_CENTER);
png.scaleAbsolute(530, 160);
document.add(png);
} catch (Exception ex) {
ex.printStackTrace();
}
if (file.exists()) {
file.delete();// 删除图片
}
}
//设置表格数据
PdfPTable table = createTable(columnNames.length);
table.addCell(createCell(titleName, keyfont, Element.ALIGN_LEFT, columnNames.length, false));
for(short j = 0; j < columnNames.length; j++){
table.addCell(createCell(columnNames[j], keyfont, Element.ALIGN_CENTER));
}
//设置每行每列的值
for (short i = 0; i < list.size(); i++) {
// 在row行上创建一个方格
for(short j = 0; j < keys.length; j++){
table.addCell(createCell(list.get(i).get(keys[j]) == null?" ": list.get(i).get(keys[j]).toString(), textfont));
}
}
document.add(table);
document.close();
//输出
InputStream in = null;
OutputStream out = null;
File file = new File(filePath);
/* 读取要下载的文件,保存到文件输入流 */
in = new FileInputStream(file);
// 设置response参数可以打开下载页面
response.reset();
response.setContentType("application/vnd.ms-excel;charset=utf-8");
response.setHeader("Content-Disposition", "attachment;filename="+ new String((fileName + ".pdf").getBytes(), "iso-8859-1"));
try {
/* 创建缓冲输出流 */
out = new BufferedOutputStream(response.getOutputStream());
/* 定义缓冲区大小,开始读写 */
byte buffer[] = new byte[2048];
int len = 0;
while ((len = in.read(buffer)) > 0) {
out.write(buffer, 0, len);
}
/* 刷新缓冲区,写出 */
out.flush();
} catch (final IOException e) {
throw e;
} finally {
if (in != null)
in.close();
if (out != null)
out.close();
}
if (file.exists()) {
file.delete();// 删除pdf
}
}
}

View file

@ -1,89 +0,0 @@
package com.skyeye.common.util;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Iterator;
import java.util.Properties;
/**
*
* @ClassName: PropertiesUtil
* @Description: 读写配置文件
* @author 卫志强
* @date 2018年10月08日
*
*/
public class PropertiesUtil {
public static Properties prop = new Properties();
/**
* 取出值
*
* @param k key键
* @param filepath properties文件路径
* @return
*/
public static String getValue(String k, String filepath) {
InputStream in;
try {
in = new BufferedInputStream(new FileInputStream(filepath));
prop.load(in); /// 加载属性列表
Iterator<String> it = prop.stringPropertyNames().iterator();
while (it.hasNext()) {
String key = it.next();
if (key.equals(k)) {
return prop.getProperty(key);
}
}
in.close();
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
/**
* 获取文件中的key-value的size
*
* @param filepath properties文件路径
* @return
*/
public static int getPropertiesSize(String filepath) {
InputStream in;
int size = 0;
try {
in = new BufferedInputStream(new FileInputStream(filepath));
prop.load(in); /// 加载属性列表
Iterator<String> it = prop.stringPropertyNames().iterator();
while (it.hasNext()) {
size++;
}
in.close();
} catch (Exception e) {
e.printStackTrace();
}
return size;
}
/**
* 设置键值
* @param filepath properties文件路径
* @param key key键
* @param value value值
*/
public static void writeProperties(String filepath, String key, String value){
///保存属性到properties文件
FileOutputStream oFile ;
try {
oFile = new FileOutputStream(filepath, true);//true表示追加打开
prop.setProperty(key, value);
prop.store(oFile, "Update IPproperties value");
oFile.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

View file

@ -1,86 +0,0 @@
package com.skyeye.common.util;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 敏感词库初始化
*
* @author 卫志强
*
*/
public class SensitiveWordInit {
/**
* 敏感词库
*/
public HashMap<String, Object> sensitiveWordMap;
/**
* 初始化敏感词
*
* @return
*/
public Map<String, Object> initKeyWord(
List<Map<String, Object>> sensitiveWords) {
try {
// 从敏感词集合对象中取出敏感词并封装到Set集合中
Set<String> keyWordSet = new HashSet<String>();
for (Map<String, Object> map : sensitiveWords) {
keyWordSet.add(map.get("sensitiveWord").toString().trim());
}
// 将敏感词库加入到HashMap中
addSensitiveWordToHashMap(keyWordSet);
} catch (Exception e) {
e.printStackTrace();
}
return sensitiveWordMap;
}
/**
* 封装敏感词库
*
* @param keyWordSet
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
private void addSensitiveWordToHashMap(Set<String> keyWordSet) {
// 初始化HashMap对象并控制容器的大小
sensitiveWordMap = new HashMap(keyWordSet.size());
// 敏感词
String key = null;
// 用来按照相应的格式保存敏感词库数据
Map nowMap = null;
// 用来辅助构建敏感词库
Map<String, String> newWorMap = null;
// 使用一个迭代器来循环敏感词集合
Iterator<String> iterator = keyWordSet.iterator();
while (iterator.hasNext()) {
key = iterator.next();
// 等于敏感词库HashMap对象在内存中占用的是同一个地址所以此nowMap对象的变化sensitiveWordMap对象也会跟着改变
nowMap = sensitiveWordMap;
for (int i = 0; i < key.length(); i++) {
// 截取敏感词当中的字在敏感词库中字为HashMap对象的Key键值
char keyChar = key.charAt(i);
// 判断这个字是否存在于敏感词库中
Object wordMap = nowMap.get(keyChar);
if (wordMap != null) {
nowMap = (Map) wordMap;
} else {
newWorMap = new HashMap<String, String>();
newWorMap.put("isEnd", "0");
nowMap.put(keyChar, newWorMap);
nowMap = newWorMap;
}
// 如果该字是当前敏感词的最后一个字则标识为结尾字
if (i == key.length() - 1) {
nowMap.put("isEnd", "1");
}
}
}
}
}

View file

@ -1,159 +0,0 @@
package com.skyeye.common.util;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
/**
* 敏感词过滤工具类
*
* @author 卫志强
*
*/
public class SensitivewordEngine {
/**
* 敏感词库
*/
@SuppressWarnings("rawtypes")
public static Map sensitiveWordMap = null;
/**
* 只过滤最小敏感词
*/
public static int minMatchTYpe = 1;
/**
* 过滤所有敏感词
*/
public static int maxMatchType = 2;
/**
* 敏感词库敏感词数量
*
* @return
*/
public static int getWordSize() {
if (SensitivewordEngine.sensitiveWordMap == null) {
return 0;
}
return SensitivewordEngine.sensitiveWordMap.size();
}
/**
* 是否包含敏感词
*
* @param txt
* @param matchType
* @return
*/
public static boolean isContaintSensitiveWord(String txt, int matchType) {
boolean flag = false;
for (int i = 0; i < txt.length(); i++) {
int matchFlag = checkSensitiveWord(txt, i, matchType);
if (matchFlag > 0) {
flag = true;
}
}
return flag;
}
/**
* 获取敏感词内容
*
* @param txt
* @param matchType
* @return 敏感词内容
*/
public static Set<String> getSensitiveWord(String txt, int matchType) {
Set<String> sensitiveWordList = new HashSet<String>();
for (int i = 0; i < txt.length(); i++) {
int length = checkSensitiveWord(txt, i, matchType);
if (length > 0) {
// 将检测出的敏感词保存到集合中
sensitiveWordList.add(txt.substring(i, i + length));
i = i + length - 1;
}
}
return sensitiveWordList;
}
/**
* 替换敏感词
*
* @param txt
* @param matchType
* @param replaceChar
* @return
*/
public static String replaceSensitiveWord(String txt, int matchType,
String replaceChar) {
String resultTxt = txt;
Set<String> set = getSensitiveWord(txt, matchType);
Iterator<String> iterator = set.iterator();
String word = null;
String replaceString = null;
while (iterator.hasNext()) {
word = iterator.next();
replaceString = getReplaceChars(replaceChar, word.length());
resultTxt = resultTxt.replaceAll(word, replaceString);
}
return resultTxt;
}
/**
* 替换敏感词内容
*
* @param replaceChar
* @param length
* @return
*/
private static String getReplaceChars(String replaceChar, int length) {
String resultReplace = replaceChar;
for (int i = 1; i < length; i++) {
resultReplace += replaceChar;
}
return resultReplace;
}
/**
* 检查敏感词数量
*
* @param txt
* @param beginIndex
* @param matchType
* @return
*/
@SuppressWarnings("rawtypes")
public static int checkSensitiveWord(String txt, int beginIndex,
int matchType) {
boolean flag = false;
// 记录敏感词数量
int matchFlag = 0;
char word = 0;
Map nowMap = SensitivewordEngine.sensitiveWordMap;
for (int i = beginIndex; i < txt.length(); i++) {
word = txt.charAt(i);
// 判断该字是否存在于敏感词库中
nowMap = (Map) nowMap.get(word);
if (nowMap != null) {
matchFlag++;
// 判断是否是敏感词的结尾字如果是结尾字则判断是否继续检测
if ("1".equals(nowMap.get("isEnd"))) {
flag = true;
// 判断过滤类型如果是小过滤则跳出循环否则继续循环
if (SensitivewordEngine.minMatchTYpe == matchType) {
break;
}
}
} else {
break;
}
}
if (!flag) {
matchFlag = 0;
}
return matchFlag;
}
}

View file

@ -1,112 +0,0 @@
package com.skyeye.common.util;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
/**
* spring工具类 方便在非spring管理环境中获取bean
*
* @author 卫志强
*/
@Component
public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationContextAware {
/** Spring应用上下文环境 */
private static ConfigurableListableBeanFactory beanFactory;
private static ApplicationContext applicationContext = null;
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
SpringUtils.beanFactory = beanFactory;
}
/**
* 获取对象
*
* @param name
* @return Object 一个以所给名字注册的bean的实例
* @throws org.springframework.beans.BeansException
*
*/
@SuppressWarnings("unchecked")
public static <T> T getBean(String name) throws BeansException {
return (T) beanFactory.getBean(name);
}
/**
* 获取类型为requiredType的对象
*
* @param clz
* @return
* @throws org.springframework.beans.BeansException
*
*/
public static <T> T getBean(Class<T> clz) throws BeansException {
T result = (T) beanFactory.getBean(clz);
return result;
}
/**
* 如果BeanFactory包含一个与所给名称匹配的bean定义则返回true
*
* @param name
* @return boolean
*/
public static boolean containsBean(String name) {
return beanFactory.containsBean(name);
}
/**
* 判断以给定名字注册的bean定义是一个singleton还是一个prototype
* 如果与给定名字相应的bean定义没有被找到将会抛出一个异常NoSuchBeanDefinitionException
*
* @param name
* @return boolean
* @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
*
*/
public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
return beanFactory.isSingleton(name);
}
/**
* @param name
* @return Class 注册对象的类型
* @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
*
*/
public static Class<?> getType(String name) throws NoSuchBeanDefinitionException {
return beanFactory.getType(name);
}
/**
* 如果给定的bean名字在bean定义中有别名则返回这些别名
*
* @param name
* @return
* @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
*
*/
public static String[] getAliases(String name) throws NoSuchBeanDefinitionException {
return beanFactory.getAliases(name);
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
if (SpringUtils.applicationContext == null) {
SpringUtils.applicationContext = applicationContext;
}
}
// 获取applicationContext
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,5 +0,0 @@
package com.skyeye.common.util;
public class WxUtil {
}

View file

@ -18,12 +18,6 @@
</properties> </properties>
<dependencies> <dependencies>
<!-- 引入公共模块的依赖 -->
<dependency>
<groupId>com.erp</groupId>
<artifactId>erp-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<!-- 引入redis的依赖 --> <!-- 引入redis的依赖 -->
<dependency> <dependency>
<groupId>com.erp</groupId> <groupId>com.erp</groupId>

View file

@ -122,5 +122,29 @@ public class MaterialController {
public void editMaterialMationById(InputObject inputObject, OutputObject outputObject) throws Exception{ public void editMaterialMationById(InputObject inputObject, OutputObject outputObject) throws Exception{
materialService.editMaterialMationById(inputObject, outputObject); materialService.editMaterialMationById(inputObject, outputObject);
} }
/**
* 获取产品列表信息展示为下拉框
* @param inputObject
* @param outputObject
* @throws Exception
*/
@RequestMapping("/post/MaterialController/queryMaterialListToSelect")
@ResponseBody
public void queryMaterialListToSelect(InputObject inputObject, OutputObject outputObject) throws Exception{
materialService.queryMaterialListToSelect(inputObject, outputObject);
}
/**
* 根据产品规格id和仓库id获取库存
* @param inputObject
* @param outputObject
* @throws Exception
*/
@RequestMapping("/post/MaterialController/queryMaterialTockByNormsIdAndDepotId")
@ResponseBody
public void queryMaterialTockByNormsIdAndDepotId(InputObject inputObject, OutputObject outputObject) throws Exception{
materialService.queryMaterialTockByNormsIdAndDepotId(inputObject, outputObject);
}
} }

View file

@ -114,4 +114,17 @@ public class SupplierController {
public void querySupplierByIdAndInfo(InputObject inputObject, OutputObject outputObject) throws Exception{ public void querySupplierByIdAndInfo(InputObject inputObject, OutputObject outputObject) throws Exception{
supplierService.querySupplierByIdAndInfo(inputObject, outputObject); supplierService.querySupplierByIdAndInfo(inputObject, outputObject);
} }
/**
* 获取供应商列表信息展示为下拉框
* @param inputObject
* @param outputObject
* @throws Exception
*/
@RequestMapping("/post/SupplierController/querySupplierListToSelect")
@ResponseBody
public void querySupplierListToSelect(InputObject inputObject, OutputObject outputObject) throws Exception{
supplierService.querySupplierListToSelect(inputObject, outputObject);
}
} }

View file

@ -53,4 +53,10 @@ public interface MaterialDao {
public void editMaterialNormsById(Map<String, Object> entity) throws Exception; public void editMaterialNormsById(Map<String, Object> entity) throws Exception;
public List<Map<String, Object>> queryMaterialListToSelect(Map<String, Object> params) throws Exception;
public List<Map<String, Object>> queryMaterialUnitByIdToSelect(Map<String, Object> bean) throws Exception;
public Map<String, Object> queryMaterialTockByNormsIdAndDepotId(Map<String, Object> params) throws Exception;
} }

View file

@ -32,4 +32,6 @@ public interface SupplierDao {
public Map<String, Object> querySupplierByEnabled(Map<String, Object> params) throws Exception; public Map<String, Object> querySupplierByEnabled(Map<String, Object> params) throws Exception;
public Map<String, Object> querySupplierByIdAndInfo(Map<String, Object> params) throws Exception; public Map<String, Object> querySupplierByIdAndInfo(Map<String, Object> params) throws Exception;
public List<Map<String, Object>> querySupplierListToSelect(Map<String, Object> params) throws Exception;
} }

View file

@ -23,4 +23,8 @@ public interface MaterialService {
public void editMaterialMationById(InputObject inputObject, OutputObject outputObject) throws Exception; public void editMaterialMationById(InputObject inputObject, OutputObject outputObject) throws Exception;
public void queryMaterialListToSelect(InputObject inputObject, OutputObject outputObject) throws Exception;
public void queryMaterialTockByNormsIdAndDepotId(InputObject inputObject, OutputObject outputObject) throws Exception;
} }

View file

@ -24,4 +24,6 @@ public interface SupplierService {
public void editSupplierByNotEnabled(InputObject inputObject, OutputObject outputObject) throws Exception; public void editSupplierByNotEnabled(InputObject inputObject, OutputObject outputObject) throws Exception;
public void querySupplierByIdAndInfo(InputObject inputObject, OutputObject outputObject) throws Exception; public void querySupplierByIdAndInfo(InputObject inputObject, OutputObject outputObject) throws Exception;
public void querySupplierListToSelect(InputObject inputObject, OutputObject outputObject) throws Exception;
} }

View file

@ -1,18 +1,18 @@
package com.skyeye.service.impl; package com.skyeye.service.impl;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
import com.skyeye.common.object.InputObject; import com.skyeye.common.object.InputObject;
import com.skyeye.common.object.OutputObject; import com.skyeye.common.object.OutputObject;
import com.skyeye.common.util.ToolUtil;
import com.skyeye.dao.CustomerDao; import com.skyeye.dao.CustomerDao;
import com.skyeye.service.CustomerService; import com.skyeye.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
/** /**
* @Author 奈何繁华如云烟 * @Author 奈何繁华如云烟

View file

@ -455,5 +455,37 @@ public class MaterialServiceImpl implements MaterialService{
outputObject.setreturnMessage("数据格式错误"); outputObject.setreturnMessage("数据格式错误");
} }
} }
/**
* 获取产品列表信息展示为下拉框
* @param inputObject
* @param outputObject
* @throws Exception
*/
@Override
public void queryMaterialListToSelect(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> params = inputObject.getParams();
params.put("userId", inputObject.getLogParams().get("id"));
List<Map<String, Object>> beans = materialDao.queryMaterialListToSelect(params);
for(Map<String, Object> bean : beans){
bean.put("unitList", materialDao.queryMaterialUnitByIdToSelect(bean));
}
outputObject.setBeans(beans);
outputObject.settotal(beans.size());
}
/**
* 根据产品规格id和仓库id获取库存
* @param inputObject
* @param outputObject
* @throws Exception
*/
@Override
public void queryMaterialTockByNormsIdAndDepotId(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> params = inputObject.getParams();
params.put("userId", inputObject.getLogParams().get("id"));
Map<String, Object> bean = materialDao.queryMaterialTockByNormsIdAndDepotId(params);
outputObject.setBean(bean);
}
} }

View file

@ -180,4 +180,19 @@ public class SupplierServiceImpl implements SupplierService {
outputObject.setBean(bean); outputObject.setBean(bean);
outputObject.settotal(1); outputObject.settotal(1);
} }
/**
* 获取供应商列表信息展示为下拉框
* @param inputObject
* @param outputObject
* @throws Exception
*/
@Override
public void querySupplierListToSelect(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> params = inputObject.getParams();
params.put("userId", inputObject.getLogParams().get("id"));
List<Map<String, Object>> beans = supplierDao.querySupplierListToSelect(params);
outputObject.setBeans(beans);
outputObject.settotal(beans.size());
}
} }

View file

@ -346,5 +346,49 @@
WHERE id = #{id} WHERE id = #{id}
AND delete_flag = '0' AND delete_flag = '0'
</update> </update>
<select id="queryMaterialListToSelect" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.id,
CONCAT(a.`name`, '(', a.model, ')') `name`,
a.unit,
a.unit_name unitName,
a.first_in_unit firstInUnit,
a.first_out_unit firstOutUnit
FROM
erp_material a
WHERE
a.delete_flag = '0'
AND a.tenant_id = #{userId}
AND a.enabled = '1'
</select>
<select id="queryMaterialUnitByIdToSelect" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.id,
b.`name`,
CONVERT(a.estimate_purchase_price, decimal) estimatePurchasePrice
FROM
erp_material_norms a
LEFT JOIN erp_unit b ON a.unit_id = b.id
WHERE
a.meterial_id = #{id}
AND a.delete_flag = '0'
ORDER BY b.number ASC
</select>
<select id="queryMaterialTockByNormsIdAndDepotId" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
IFNULL(SUM(a.oper_number * (CASE b.type WHEN '1' THEN 1 ELSE -1 END)), '0') AS currentTock
FROM
erp_depotitem a,
erp_depothead b
WHERE
a.tenant_id = #{userId}
AND a.depot_id = #{depotId}
AND a.m_unit_id = #{mUnitId}
AND a.header_id = b.id
GROUP BY a.m_unit_id
</select>
</mapper> </mapper>

View file

@ -272,4 +272,17 @@
AND s.type = 1 AND s.type = 1
ORDER BY s.id DESC LIMIT 0,1 ORDER BY s.id DESC LIMIT 0,1
</select> </select>
<select id="querySupplierListToSelect" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.id,
a.supplier `name`
FROM
erp_supplier a
WHERE
a.tenant_id = #{userId}
AND a.delete_flag = '0'
AND a.type = '1'
</select>
</mapper> </mapper>

View file

@ -125,6 +125,12 @@
<property id="materialNormsStr" name="materialNormsStr" ref="required" var="产品规格字符串" /> <property id="materialNormsStr" name="materialNormsStr" ref="required" var="产品规格字符串" />
<property id="rowId" name="id" ref="required" var="产品id" /> <property id="rowId" name="id" ref="required" var="产品id" />
</url> </url>
<url id="material010" path="/post/MaterialController/queryMaterialListToSelect" val="获取产品列表信息展示为下拉框" allUse="2">
</url>
<url id="material011" path="/post/MaterialController/queryMaterialTockByNormsIdAndDepotId" val="根据产品规格id和仓库id获取库存" allUse="2">
<property id="depotId" name="depotId" ref="required" var="仓库id"/>
<property id="mUnitId" name="mUnitId" ref="required" var="规格id"/>
</url>
<!-- 产品结束 --> <!-- 产品结束 -->
<!-- 其他入库开始 --> <!-- 其他入库开始 -->

View file

@ -109,6 +109,8 @@
<url id="supplier008" path="/post/SupplierController/querySupplierByIdAndInfo" val="查看供应商详情" allUse="1"> <url id="supplier008" path="/post/SupplierController/querySupplierByIdAndInfo" val="查看供应商详情" allUse="1">
<property id="rowId" name="id" ref="required" var="供应商ID"></property> <property id="rowId" name="id" ref="required" var="供应商ID"></property>
</url> </url>
<url id="supplier009" path="/post/SupplierController/querySupplierListToSelect" val="获取供应商列表信息展示为下拉框" allUse="2">
</url>
<!-- 供应商管理结束--> <!-- 供应商管理结束-->
<!-- 客户信息管理开始 --> <!-- 客户信息管理开始 -->

View file

@ -1,4 +1,4 @@
var assetArticles = new Array(); //用品集合 var material = new Array(); //产品集合
layui.config({ layui.config({
base: basePath, base: basePath,
@ -12,73 +12,50 @@ layui.config({
var $ = layui.$; var $ = layui.$;
var enclosureInfo = ""; //附件id var enclosureInfo = ""; //附件id
var rowNum = 1; //表格的序号 var rowNum = 1; //表格的序号
var typeHtml = ""; var depotHtml = "", materialHtml = "";//仓库
var tockObject = new Array();//根据仓库和规格id查询出来的对应库存信息
var usetableTemplate = $("#usetableTemplate").html(); var usetableTemplate = $("#usetableTemplate").html();
var selOption = getFileContent('tpl/template/select-option.tpl'); var selOption = getFileContent('tpl/template/select-option.tpl');
AjaxPostUtil.request({url: reqBasePath + "login002", params: {}, type: 'json', callback: function(json) { initSupplierHtml();
if(json.returnCode == 0) { //初始化供应商
$("#useTitle").html("用品领用申请单-" + getYMDFormatDate() + '-' + json.bean.userName); function initSupplierHtml() {
$("#useName").html(json.bean.userName); AjaxPostUtil.request({url: reqBasePath + "supplier009", params: {}, type: 'json', callback: function(json) {
initTypeHtml(); if(json.returnCode == 0) {
} else { //加载供应商数据
location.href = "login.html"; $("#supplierId").html(getDataUseHandlebars(selOption, json));
} //初始化仓库
}}); initDepotHtml();
} else {
//初始化用品类别 winui.window.msg(json.returnMessage, {icon: 2, time: 2000});
function initTypeHtml() { }
}});
}
//初始化仓库
function initDepotHtml() {
AjaxPostUtil.request({url: reqBasePath + "storehouse008", params: {}, type: 'json', callback: function(json) { AjaxPostUtil.request({url: reqBasePath + "storehouse008", params: {}, type: 'json', callback: function(json) {
if(json.returnCode == 0) { if(json.returnCode == 0) {
typeHtml = getDataUseHandlebars(selOption, json); //加载类别数据 //加载仓库数据
depotHtml = getDataUseHandlebars(selOption, json);
//初始化产品
initMaterialHtml();
} else {
winui.window.msg(json.returnMessage, {icon: 2, time: 2000});
}
}});
}
//初始化产品
function initMaterialHtml() {
AjaxPostUtil.request({url: reqBasePath + "material010", params: {}, type: 'json', callback: function(json) {
if(json.returnCode == 0) {
material = json.rows;
//加载产品数据
materialHtml = getDataUseHandlebars(selOption, json);
//渲染 //渲染
form.render(); form.render();
//类型加载变化事件
form.on('select(selectTypeProperty)', function(data) {
var thisRowNum = data.elem.id.replace("typeId", "");
var thisRowValue = data.value;
if(!isNull(thisRowValue) && thisRowValue != '请选择') {
if(inPointArray(thisRowValue, assetArticles)) {
//类型对应的用品存在js对象中
var list = getListPointArray(thisRowValue, assetArticles);
resetAssetList(thisRowNum, list); //重置选择行的用品列表
} else {
//类型对应的用品不存在js对象中
AjaxPostUtil.request({url: reqBasePath + "assetarticles018", params: {typeId: thisRowValue}, type: 'json', callback: function(json) {
if(json.returnCode == 0) {
assetArticles.push({
id: thisRowValue,
list: json.rows
});
resetAssetList(thisRowNum, json.rows); //重置选择行的用品列表
} else {
winui.window.msg(json.returnMessage, {icon: 2, time: 2000});
}
}});
}
}
});
//商品加载变化事件
form.on('select(selectAssetarProperty)', function(data) {
var thisRowNum = data.elem.id.replace("assetarId", "");
var thisRowValue = data.value;
var thisRowTypeChooseId = $("#typeId" + thisRowNum).val();
if(!isNull(thisRowValue) && thisRowValue != '请选择') {
var list = getListPointArray(thisRowTypeChooseId, assetArticles);
$.each(list, function(i, item) {
if(item.id === thisRowValue) {
$("#specificationsName" + thisRowNum).html(item.specificationsName);
$("#residualNum" + thisRowNum).html(item.residualNum);
return false;
}
});
} else {
$("#specificationsName" + thisRowNum).html(""); //重置规格为空
$("#residualNum" + thisRowNum).html(""); //重置库存为空
}
});
//初始化一行数据 //初始化一行数据
addRow(); addRow();
} else { } else {
@ -86,6 +63,132 @@ layui.config({
} }
}}); }});
} }
//仓库加载变化事件
form.on('select(selectDepotProperty)', function(data) {
var thisRowNum = data.elem.id.replace("depotId", "");//获取当前行
var thisRowValue = data.value;
loadTockByDepotAndMUnit(thisRowNum);
});
//产品加载变化事件
form.on('select(selectMaterialProperty)', function(data) {
var thisRowNum = data.elem.id.replace("materialId", "");//获取当前行
var thisRowValue = data.value;
if(!isNull(thisRowValue) && thisRowValue != '请选择') {
$.each(material, function(i, item) {
if(thisRowValue == item.id){
$("#unitId" + thisRowNum).html(getDataUseHandlebars(selOption, {rows: item.unitList}));
form.render('select');
return false;
}
});
} else {
$("#unitId" + thisRowNum).html(""); //重置规格为空
form.render('select');
}
loadTockByDepotAndMUnit(thisRowNum);
});
//产品规格加载变化事件
form.on('select(selectUnitProperty)', function(data) {
var thisRowNum = data.elem.id.replace("unitId", "");//获取当前行
var thisRowValue = data.value;
//当前选中的产品id
var chooseMaterialId = $("#materialId" + thisRowNum).val();
if(!isNull(thisRowValue) && thisRowValue != '请选择') {
$.each(material, function(i, item) {
if(chooseMaterialId == item.id){//获取产品
$.each(item.unitList, function(j, bean) {
if(thisRowValue == bean.id){//获取规格
//获取当前行数量
var rkNum = parseInt($("#rkNum" + thisRowNum).val());
$("#unitPrice" + thisRowNum).html(bean.estimatePurchasePrice.toFixed(2));//单价
$("#amountOfMoney" + thisRowNum).html((rkNum * parseFloat(bean.estimatePurchasePrice)).toFixed(2));//金额
return false;
}
});
return false;
}
});
} else {
$("#unitPrice" + thisRowNum).html("");//重置单价为空
$("#amountOfMoney" + thisRowNum).html("");//重置金额为空
}
loadTockByDepotAndMUnit(thisRowNum);
calculatedTotalPrice();
});
/**
* 根据仓库和规格加载库存
* @param rowNum 表格行坐标
*/
function loadTockByDepotAndMUnit(rowNum){
//获取当前选中的仓库
var chooseDepotId = $("#depotId" + rowNum).val();
//获取当前选中的规格
var chooseUnitId = $("#unitId" + rowNum).val();
//当两个都不为空时
if(!isNull(chooseDepotId) && !isNull(chooseUnitId)){
var inTockObject = -1;
$.each(tockObject, function(i, item){
if(item.depotId == chooseDepotId && item.unitId == chooseUnitId){
inTockObject = i;
$("#currentTock" + rowNum).html(item.currentTock);
return false;
}
});
//如果数组中不包含对应的库存
if(inTockObject < 0){
//获取库存
AjaxPostUtil.request({url: reqBasePath + "material011", params: {depotId: chooseDepotId, mUnitId: chooseUnitId}, type: 'json', callback: function(json) {
if(json.returnCode == 0) {
var currentTock = 0;
if(!isNull(json.bean)){
currentTock = json.bean.currentTock;
}
tockObject.push({
depotId: chooseDepotId,
unitId: chooseUnitId,
currentTock: currentTock
});
$("#currentTock" + rowNum).html(currentTock);
} else {
winui.window.msg(json.returnMessage, {icon: 2, time: 2000});
}
}});
}
}else{
//否则重置库存为空
$("#currentTock" + rowNum).html("");
}
}
//数量变化
$("body").on("input", ".rkNum", function() {
calculatedTotalPrice();
});
$("body").on("change", ".rkNum", function() {
calculatedTotalPrice();
});
//计算总价
function calculatedTotalPrice(){
var rowTr = $("#useTable tr");
var allPrice = 0;
$.each(rowTr, function(i, item) {
//获取行坐标
var rowNum = $(item).attr("trcusid").replace("tr", "");
//获取数量
var rkNum = parseInt(isNull($("#rkNum" + rowNum).val()) ? "0" : $("#rkNum" + rowNum).val());
//获取单价
var unitPrice = parseFloat(isNull($("#unitPrice" + rowNum).html()) ? "0" : $("#unitPrice" + rowNum).html());
//输出金额
$("#amountOfMoney" + rowNum).html((rkNum * unitPrice).toFixed(2));
allPrice += rkNum * unitPrice;
});
$("#allPrice").html(allPrice.toFixed(2));
}
form.on('submit(formAddBean)', function(data) { form.on('submit(formAddBean)', function(data) {
//表单验证 //表单验证
@ -135,23 +238,21 @@ layui.config({
var params = { var params = {
title: $("#useTitle").html(), title: $("#useTitle").html(),
remark: $("#remark").val(), remark: $("#remark").val(),
assetArticlesStr: JSON.stringify(tableData) depotheadStr: JSON.stringify(tableData)
}; };
//表单类型为保存为草稿 // AjaxPostUtil.request({url: reqBasePath + "assetarticles019", params: params, type: 'json', callback: function(json) {
params.subType = '1'; // if(json.returnCode == 0) {
AjaxPostUtil.request({url: reqBasePath + "assetarticles019", params: params, type: 'json', callback: function(json) { // parent.layer.close(index);
if(json.returnCode == 0) { // parent.refreshCode = '0';
parent.layer.close(index); // } else {
parent.refreshCode = '0'; // winui.window.msg(json.returnMessage, {icon: 2, time: 2000});
} else { // }
winui.window.msg(json.returnMessage, {icon: 2, time: 2000}); // }});
}
}});
} }
return false; return false;
}); });
//判断选中的品是否也在数组中 //判断选中的品是否也在数组中
function inTableDataArrayByAssetarId(str, array) { function inTableDataArrayByAssetarId(str, array) {
var isIn = false; var isIn = false;
$.each(array, function(i, item) { $.each(array, function(i, item) {
@ -178,16 +279,20 @@ layui.config({
var par = { var par = {
id: "row" + rowNum.toString(), //checkbox的id id: "row" + rowNum.toString(), //checkbox的id
trId: "tr" + rowNum.toString(), //行的id trId: "tr" + rowNum.toString(), //行的id
typeId: "typeId" + rowNum.toString(), //类型id depotId: "depotId" + rowNum.toString(), //仓库id
assetarId: "assetarId" + rowNum.toString(), //用品id materialId: "materialId" + rowNum.toString(), //产品id
specificationsName: "specificationsName" + rowNum.toString(), //规格id unitId: "unitId" + rowNum.toString(), //规格id
residualNum: "residualNum" + rowNum.toString(), //库存id currentTock: "currentTock" + rowNum.toString(), //库存id
useNum: "useNum" + rowNum.toString(), //领用数量id rkNum: "rkNum" + rowNum.toString(), //数量id
unitPrice: "unitPrice" + rowNum.toString(), //单价id
amountOfMoney: "amountOfMoney" + rowNum.toString(), //金额id
remark: "remark" + rowNum.toString() //备注id remark: "remark" + rowNum.toString() //备注id
}; };
$("#useTable").append(getDataUseHandlebars(usetableTemplate, par)); $("#useTable").append(getDataUseHandlebars(usetableTemplate, par));
//赋值给用品类别 //赋值给仓库
$("#" + "typeId" + rowNum.toString()).html(typeHtml); $("#" + "depotId" + rowNum.toString()).html(depotHtml);
//赋值给产品
$("#" + "materialId" + rowNum.toString()).html(materialHtml);
form.render('select'); form.render('select');
form.render('checkbox'); form.render('checkbox');
rowNum++; rowNum++;
@ -205,7 +310,7 @@ layui.config({
} }
} }
//根据类型重置用户列表 //根据仓库和商品重置库存
function resetAssetList(thisRowNum, list) { function resetAssetList(thisRowNum, list) {
var sHtml = getDataUseHandlebars(selOption, { var sHtml = getDataUseHandlebars(selOption, {
rows: list rows: list

View file

@ -8,28 +8,16 @@
<link href="../../assets/lib/winui/css/winui.css" rel="stylesheet" /> <link href="../../assets/lib/winui/css/winui.css" rel="stylesheet" />
</head> </head>
<body> <body>
<div style="margin:0 auto;padding:20px;"> <div style="margin: 0 auto; padding: 20px;">
<form class="layui-form" action="" id="showForm"> <form class="layui-form" action="" id="showForm">
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">标题<i class="red">*</i></label>
<div class="layui-input-block ver-center" id="useTitle">
</div>
</div>
<div class="layui-form-item layui-col-xs6"> <div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">步骤</label> <label class="layui-form-label">供应商<i class="red">*</i></label>
<div class="layui-input-block ver-center"> <div class="layui-input-block">
填单 <select id="supplierId" lay-search win-verify="required"></select>
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">责任人<i class="red">*</i></label>
<div class="layui-input-block ver-center" id="useName">
</div> </div>
</div> </div>
<div class="layui-form-item layui-col-xs12"> <div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">用品<i class="red">*</i></label> <label class="layui-form-label">列表项<i class="red">*</i></label>
<div class="layui-input-block"> <div class="layui-input-block">
<div class="winui-toolbar"> <div class="winui-toolbar">
<div class="winui-tool" style="text-align: left;"> <div class="winui-tool" style="text-align: left;">
@ -40,15 +28,15 @@
<table class="layui-table"> <table class="layui-table">
<thead> <thead>
<tr> <tr>
<th></th> <th style="width: 30px;"></th>
<th>仓库</th> <th style="width: 120px;">仓库</th>
<th>产品(型号)</th> <th style="width: 120px;">产品(型号)</th>
<th>单位</th> <th style="width: 70px;">单位</th>
<th style="width: 50px;">库存</th> <th style="width: 80px;">库存</th>
<th style="width: 50px;">数量</th> <th style="width: 80px;">数量</th>
<th style="width: 50px;">单价</th> <th style="width: 80px;">单价</th>
<th style="width: 50px;">金额</th> <th style="width: 80px;">金额</th>
<th>备注</th> <th style="width: 100px;">备注</th>
</tr> </tr>
</thead> </thead>
<tbody id="useTable" class="insurance-table"> <tbody id="useTable" class="insurance-table">
@ -57,9 +45,15 @@
</div> </div>
</div> </div>
<div class="layui-form-item layui-col-xs12"> <div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">相关描述</label> <label class="layui-form-label">共计金额</label>
<div class="layui-input-block ver-center" id="allPrice">
0.00
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">备注</label>
<div class="layui-input-block"> <div class="layui-input-block">
<textarea id="remark" name="remark" placeholder="请输入相关描述" class="layui-textarea" style="height: 100px;" maxlength="200"></textarea> <textarea id="remark" name="remark" placeholder="请输入备注" class="layui-textarea" style="height: 100px;" maxlength="200"></textarea>
</div> </div>
</div> </div>
<div class="layui-form-item layui-col-xs12"> <div class="layui-form-item layui-col-xs12">
@ -75,11 +69,13 @@
<script type="text/x-handlebars-template" id="usetableTemplate"> <script type="text/x-handlebars-template" id="usetableTemplate">
<tr trcusid="{{trId}}"> <tr trcusid="{{trId}}">
<td><input type="checkbox" rowId="{{id}}" lay-filter="checkboxProperty" name="tableCheckRow"/></td> <td><input type="checkbox" rowId="{{id}}" lay-filter="checkboxProperty" name="tableCheckRow"/></td>
<td><select id="{{typeId}}" lay-filter="selectTypeProperty" win-verify="required"></select></td> <td><select id="{{depotId}}" lay-filter="selectDepotProperty" lay-search win-verify="required"></select></td>
<td><select id="{{assetarId}}" lay-filter="selectAssetarProperty" win-verify="required"></select></td> <td><select id="{{materialId}}" lay-filter="selectMaterialProperty" lay-search win-verify="required"></select></td>
<td id="{{specificationsName}}"></td> <td><select id="{{unitId}}" lay-filter="selectUnitProperty" lay-search win-verify="required"></select></td>
<td id="{{residualNum}}"></td> <td id="{{currentTock}}"></td>
<td><input type="text" class="layui-input" value="1" id="{{useNum}}" win-verify="required|number"/></td> <td><input type="text" class="layui-input rkNum" value="1" id="{{rkNum}}" win-verify="required|number"/></td>
<td id="{{unitPrice}}"></td>
<td id="{{amountOfMoney}}"></td>
<td><input type="text" class="layui-input" id="{{remark}}"/></td> <td><input type="text" class="layui-input" id="{{remark}}"/></td>
</tr> </tr>
</script> </script>

Binary file not shown.

View file

@ -21,9 +21,11 @@
<!-- 引入公共模块的依赖 --> <!-- 引入公共模块的依赖 -->
<dependency> <dependency>
<groupId>com.erp</groupId> <groupId>ky.com.skyeye</groupId>
<artifactId>erp-common</artifactId> <artifactId>skyeye-common</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.0.2-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${basedir}/lib/skyeye-common-1.0.2-SNAPSHOT.jar</systemPath>
</dependency> </dependency>
</dependencies> </dependencies>

View file

@ -32,22 +32,22 @@ spring.servlet.multipart.max-file-size=10Mb
spring.http.multipart.max-request-size=100Mb spring.http.multipart.max-request-size=100Mb
#redis 1连接信息 #redis 1连接信息
redis.ip1=192.168.0.140 redis.ip1=192.168.1.140
redis.host1=9000 redis.host1=9000
#redis 2连接信息 #redis 2连接信息
redis.ip2=192.168.0.140 redis.ip2=192.168.1.140
redis.host2=9001 redis.host2=9001
#redis 3连接信息 #redis 3连接信息
redis.ip3=192.168.0.140 redis.ip3=192.168.1.140
redis.host3=9002 redis.host3=9002
#redis 4连接信息 #redis 4连接信息
redis.ip4=192.168.0.140 redis.ip4=192.168.1.140
redis.host4=9003 redis.host4=9003
#redis 5连接信息 #redis 5连接信息
redis.ip5=192.168.0.140 redis.ip5=192.168.1.140
redis.host5=9004 redis.host5=9004
#redis 6连接信息 #redis 6连接信息
redis.ip6=192.168.0.140 redis.ip6=192.168.1.140
redis.host6=9005 redis.host6=9005
redis.commandTimeout=1000 redis.commandTimeout=1000

View file

@ -3132,7 +3132,7 @@ hr,
.layui-table th, .layui-table th,
.layui-table td { .layui-table td {
position: relative; position: relative;
padding: 9px 15px; padding: 5px 10px;
min-height: 20px; min-height: 20px;
line-height: 20px; line-height: 20px;
font-size: 14px; font-size: 14px;

View file

@ -18,11 +18,11 @@
</properties> </properties>
<dependencies> <dependencies>
<!-- 引入公共的依赖 --> <!-- 引入redis的依赖 -->
<dependency> <dependency>
<groupId>com.erp</groupId> <groupId>com.erp</groupId>
<artifactId>erp-common</artifactId> <artifactId>erp-redis</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
</dependency> </dependency>

View file

@ -13,7 +13,6 @@
</parent> </parent>
<modules> <modules>
<module>erp-common</module>
<module>erp-redis</module> <module>erp-redis</module>
<module>erp-modular</module> <module>erp-modular</module>
<module>erp-base</module> <module>erp-base</module>