Compare commits

..

2 Commits

Author SHA1 Message Date
gjq
3e830afcce ... 2021-12-31 18:06:55 +08:00
gjq
ac9fb347b4 ..... 2021-12-30 09:10:55 +08:00
52 changed files with 1547 additions and 336 deletions

29
pom.xml
View File

@ -34,7 +34,7 @@
</properties>
<dependencies>
<!-- jsp解析依赖,不加这个访问jsp直接变成下载 -->
<dependency>
<groupId>javax.servlet</groupId>
@ -53,7 +53,7 @@
<artifactId>tomcat-jsp-api</artifactId>
</dependency>
<!-- jsp解析依赖 end -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
@ -74,7 +74,7 @@
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
@ -105,14 +105,14 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<!-- Druid Spring Boot Starter -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid.springboot.version}</version>
</dependency>
<!--mapper-->
<dependency>
<groupId>tk.mybatis</groupId>
@ -126,7 +126,7 @@
</exclusion>
</exclusions>
</dependency>
<!--pagehelper-->
<dependency>
<groupId>com.github.pagehelper</groupId>
@ -170,18 +170,18 @@
<artifactId>kaptcha</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
@ -192,7 +192,7 @@
<artifactId>poi-ooxml</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>ognl</groupId>
<artifactId>ognl</artifactId>
@ -209,8 +209,15 @@
<artifactId>lombok</artifactId>
</dependency>
<!-- 整合 Elasticsearch -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<!-- 测试用, 配置devtools实现热部署 -->
<!--
<!--
会导致ClassCastException异常
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@ -89,7 +89,7 @@ public class MyShiroRealm extends AuthorizingRealm {
return authenticationInfo;
}
*/
//认证
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
@ -103,7 +103,7 @@ public class MyShiroRealm extends AuthorizingRealm {
user.setUserId(syUsers.getUserName());
user.setUsername(syUsers.getUserName());
user.setPassword(syUsers.getUserPassword());
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
// 把ip放入user存入redis缓存里
user.setLoginIpAddress(CommonUtils.getIpAddr(request));

View File

@ -18,16 +18,16 @@ import com.nbclass.system.model.Permission;
import com.nbclass.system.service.PermissionService;
/**
*
*
* @author Leon
* @datetime 2019年4月1日 下午2:47:53
*/
@Service
public class ShiroService {
@Autowired
private PermissionService permissionService;
/**
* 初始化加载权限
* @return
@ -35,7 +35,7 @@ public class ShiroService {
public Map<String, String> loadFilterChainDefinitions() {
// 权限控制map.从数据库获取
Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>();
filterChainDefinitionMap.put("/register", "anon");
filterChainDefinitionMap.put("/login", "anon");
filterChainDefinitionMap.put("/error/**", "anon");
@ -47,7 +47,9 @@ public class ShiroService {
filterChainDefinitionMap.put("/libs/**","anon");
filterChainDefinitionMap.put("/favicon.ico", "anon");
filterChainDefinitionMap.put("/verificationCode", "anon");
filterChainDefinitionMap.put("/test/**", "anon");
filterChainDefinitionMap.put("/api/**" ,"anon"); // 前端接口
filterChainDefinitionMap.put("/", "anon"); // 网站首页
// 静态资源按后缀排除
@ -62,14 +64,14 @@ public class ShiroService {
filterChainDefinitionMap.put("/**/*.woff2", "anon");
filterChainDefinitionMap.put("/**/*.mp3", "anon");
filterChainDefinitionMap.put("/**/*.mp4", "anon");
// filterChainDefinitionMap.put("/**/*.html", "authc,wxOAuthFilter");
// filterChainDefinitionMap.put("/**/*.jsp", "authc,wxOAuthFilter");
filterChainDefinitionMap.put("/**/*.html", "wxOAuthFilter");
filterChainDefinitionMap.put("/mobile/page/**", "wxOAuthFilter");
// 测试放开权限
filterChainDefinitionMap.put("/mobile/api/**", "anon");
//List<Permission> permissionList = permissionService.selectAll(CoreConst.STATUS_VALID); // 迁移此数据库结构不一致不从数据库查权限配置
List<Permission> permissionList = new ArrayList<Permission>();
for(Permission permission : permissionList){
@ -78,9 +80,9 @@ public class ShiroService {
filterChainDefinitionMap.put(permission.getUrl(),perm+",kickout");
}
}
filterChainDefinitionMap.put("/**", "user,kickout");
return filterChainDefinitionMap;
}

View File

@ -93,7 +93,7 @@ public class ShiroConfig {
filtersMap.put("kickout", kickoutSessionControlFilter());
// 企业微信登录拦截器
filtersMap.put("wxOAuthFilter", new WxWorkFilter());
shiroFilterFactoryBean.setFilters(filtersMap);
//拦截器.
Map<String,String> filterChainDefinitionMap = shiroService.loadFilterChainDefinitions();
@ -244,7 +244,7 @@ public class ShiroConfig {
return kickoutSessionControlFilter;
}
private static byte[] getCipherKey(){
byte[] cipherKey = null;
KeyGenerator keygen = null;
@ -257,9 +257,9 @@ public class ShiroConfig {
}
return cipherKey;
}
public static void main(String[] args) throws Exception {
System.out.println("cipherKey="+Base64.encodeToString(getCipherKey()));
}
}
}

View File

@ -133,7 +133,7 @@ public class SystemController{
return ResultUtil.error("用户名或者密码错误!");
}
//更新最后登录时间
userService.updateLastLoginTime((User) SecurityUtils.getSubject().getPrincipal());
// userService.updateLastLoginTime((User) SecurityUtils.getSubject().getPrincipal());
return ResultUtil.success("登录成功!");
}

View File

@ -0,0 +1,126 @@
package com.nbclass.szxgl.config;
import com.alibaba.druid.pool.DruidDataSource;
import lombok.Data;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import javax.sql.DataSource;
import java.sql.SQLException;
/**
* @ProjectName
* @Description: 后台数据源配置类
*/
@Data
@Configuration
@ConfigurationProperties(prefix = "back.datasource.druid")
@MapperScan(basePackages = BackDataBaseConfig.PACKAGE, sqlSessionFactoryRef = "backSqlSessionFactory")
public class BackDataBaseConfig {
/**
* dao层的包路径
*/
static final String PACKAGE = "com.nbclass.szxgl.mapper2";
/**
* mapper文件的相对路径
*/
private static final String MAPPER_LOCATION = "classpath*:mapper/szxgl/*.xml";
@Value("${back.datasource.druid.filters}")
private String filters;
@Value("${back.datasource.druid.driverClassName}")
private String url;
@Value("${back.datasource.druid.url}")
private String username;
@Value("${back.datasource.druid.username}")
private String password;
@Value("${back.datasource.druid.password}")
private String driverClassName;
@Value("${back.datasource.druid.initialSize}")
private int initialSize;
@Value("${back.datasource.druid.minIdle}")
private int minIdle;
@Value("${back.datasource.druid.maxActive}")
private int maxActive;
@Value("${back.datasource.druid.maxWait}")
private long maxWait;
@Value("${back.datasource.druid.timeBetweenEvictionRunsMillis}")
private long timeBetweenEvictionRunsMillis;
@Value("${back.datasource.druid.minEvictableIdleTimeMillis}")
private long minEvictableIdleTimeMillis;
@Value("${back.datasource.druid.validationQuery}")
private String validationQuery;
@Value("${back.datasource.druid.testWhileIdle}")
private boolean testWhileIdle;
@Value("${back.datasource.druid.testOnBorrow}")
private boolean testOnBorrow;
@Value("${back.datasource.druid.testOnReturn}")
private boolean testOnReturn;
@Value("${back.datasource.druid.poolPreparedStatements}")
private boolean poolPreparedStatements;
@Value("${back.datasource.druid.maxPoolPreparedStatementPerConnectionSize}")
private int maxPoolPreparedStatementPerConnectionSize;
@Bean(name = "backDataSource")
public DataSource backDataSource() throws SQLException {
DruidDataSource druid = new DruidDataSource();
// 监控统计拦截的filters
druid.setFilters(filters);
// 配置基本属性
druid.setDriverClassName(driverClassName);
druid.setUsername(username);
druid.setPassword(password);
druid.setUrl(url);
//初始化时建立物理连接的个数
druid.setInitialSize(initialSize);
//最大连接池数量
druid.setMaxActive(maxActive);
//最小连接池数量
druid.setMinIdle(minIdle);
//获取连接时最大等待时间单位毫秒
druid.setMaxWait(maxWait);
//间隔多久进行一次检测检测需要关闭的空闲连接
druid.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
//一个连接在池中最小生存的时间
druid.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
//用来检测连接是否有效的sql
druid.setValidationQuery(validationQuery);
//建议配置为true不影响性能并且保证安全性
druid.setTestWhileIdle(testWhileIdle);
//申请连接时执行validationQuery检测连接是否有效
druid.setTestOnBorrow(testOnBorrow);
druid.setTestOnReturn(testOnReturn);
//是否缓存preparedStatement也就是PSCacheoracle设为truemysql设为false分库分表较多推荐设置为false
druid.setPoolPreparedStatements(poolPreparedStatements);
// 打开PSCache时指定每个连接上PSCache的大小
druid.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
return druid;
}
@Bean(name = "backTransactionManager")
public DataSourceTransactionManager backTransactionManager() throws SQLException {
return new DataSourceTransactionManager(backDataSource());
}
@Bean(name = "backSqlSessionFactory")
public SqlSessionFactory backSqlSessionFactory(@Qualifier("backDataSource") DataSource backDataSource) throws Exception {
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(backDataSource);
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
.getResources(BackDataBaseConfig.MAPPER_LOCATION));
return sessionFactory.getObject();
}
}

View File

@ -0,0 +1,47 @@
package com.nbclass.szxgl.config;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import javax.sql.DataSource;
/**
* 多数据源配置
*/
//@Configuration
//public class DataSourceConfig {
//
// //主数据源配置 ds1数据源
// @Primary
// @Bean(name = "ds1DataSourceProperties")
// @ConfigurationProperties(prefix = "fastdep.datasource.test")
// public DataSourceProperties ds1DataSourceProperties() {
// return new DataSourceProperties();
// }
//
// //主数据源 ds1数据源
// @Primary
// @Bean(name = "ds1DataSource")
// public DataSource ds1DataSource(@Qualifier("ds1DataSourceProperties") DataSourceProperties dataSourceProperties) {
//
// return dataSourceProperties.initializeDataSourceBuilder().build();
// }
//
// //第二个ds2数据源配置
// @Bean(name = "ds2DataSourceProperties")
// @ConfigurationProperties(prefix = "fastdep.datasource.test2")
// public DataSourceProperties ds2DataSourceProperties() {
// return new DataSourceProperties();
// }
//
// //第二个ds2数据源
// @Bean("ds2DataSource")
// public DataSource ds2DataSource(@Qualifier("ds2DataSourceProperties") DataSourceProperties dataSourceProperties) {
// return dataSourceProperties.initializeDataSourceBuilder().build();
// }
//
//}

View File

@ -0,0 +1,32 @@
package com.nbclass.szxgl.config;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.core.JdbcTemplate;
import javax.sql.DataSource;
/**
* JdbcTemplate多数据源配置
* 依赖于数据源配置
*
* @see DataSourceConfig
*/
//@Configuration
//public class JdbcTemplateDataSourceConfig {
//
// //JdbcTemplate主数据源ds1数据源
// @Primary
// @Bean(name = "ds1JdbcTemplate")
// public JdbcTemplate ds1JdbcTemplate(@Qualifier("ds1DataSource") DataSource dataSource) {
// return new JdbcTemplate(dataSource);
// }
//
// //JdbcTemplate第二个ds2数据源
// @Bean(name = "ds2JdbcTemplate")
// public JdbcTemplate ds2JdbcTemplate(@Qualifier("ds2DataSource") DataSource dataSource) {
// return new JdbcTemplate(dataSource);
// }
//}

View File

@ -0,0 +1,48 @@
package com.nbclass.szxgl.config;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import javax.sql.DataSource;
/**
* Mybatis主数据源ds1配置
* 多数据源配置依赖数据源配置
* @see DataSourceConfig
*/
//@Configuration
//@MapperScan(basePackages ="com.nbclass.szxgl.mapper", sqlSessionTemplateRef = "ds1SqlSessionTemplate")
//public class MybatisPlusConfig4ds1 {
//
// //主数据源 ds1数据源
// @Primary
// @Bean("ds1SqlSessionFactory")
// public SqlSessionFactory ds1SqlSessionFactory(@Qualifier("ds1DataSource") DataSource dataSource) throws Exception {
// SqlSessionFactoryBean sqlSessionFactory = new SqlSessionFactoryBean();
// sqlSessionFactory.setDataSource(dataSource);
// sqlSessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().
// getResources("classpath*:mapper/szxgl/*.xml"));
// return sqlSessionFactory.getObject();
// }
//
// @Primary
// @Bean(name = "ds1TransactionManager")
// public DataSourceTransactionManager ds1TransactionManager(@Qualifier("ds1DataSource") DataSource dataSource) {
// return new DataSourceTransactionManager(dataSource);
// }
//
// @Primary
// @Bean(name = "ds1SqlSessionTemplate")
// public SqlSessionTemplate ds1SqlSessionTemplate(@Qualifier("ds1SqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
// return new SqlSessionTemplate(sqlSessionFactory);
// }
//
//}

View File

@ -0,0 +1,45 @@
package com.nbclass.szxgl.config;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import javax.sql.DataSource;
/**
* Mybatis 第二个ds2数据源配置
* 多数据源配置依赖数据源配置
* @see DataSourceConfig
*/
//@Configuration
//@MapperScan(basePackages ="com.nbclass.szxgl.mapper2", sqlSessionTemplateRef = "ds2SqlSessionTemplate")
//public class MybatisPlusConfig4ds2 {
//
// //ds2数据源
// @Bean("ds2SqlSessionFactory")
// public SqlSessionFactory ds2SqlSessionFactory(@Qualifier("ds2DataSource") DataSource dataSource) throws Exception {
// SqlSessionFactoryBean sqlSessionFactory = new SqlSessionFactoryBean();
// sqlSessionFactory.setDataSource(dataSource);
// sqlSessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().
// getResources("classpath*:mapper/szxgl/*.xml"));
// return sqlSessionFactory.getObject();
// }
//
////事务支持
// @Bean(name = "ds2TransactionManager")
// public DataSourceTransactionManager ds2TransactionManager(@Qualifier("ds2DataSource") DataSource dataSource) {
// return new DataSourceTransactionManager(dataSource);
// }
//
// @Bean(name = "ds2SqlSessionTemplate")
// public SqlSessionTemplate ds2SqlSessionTemplate(@Qualifier("ds2SqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
// return new SqlSessionTemplate(sqlSessionFactory);
// }
//
//}

View File

@ -0,0 +1,123 @@
package com.nbclass.szxgl.config;
import com.alibaba.druid.pool.DruidDataSource;
import lombok.Data;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import javax.sql.DataSource;
import java.sql.SQLException;
/**
* @Description: 主数据源配置类
* 前缀为primary.datasource.druid的配置信息
*/
@Data
@Configuration
@ConfigurationProperties(prefix = "primary.datasource.druid")
@MapperScan(basePackages = PrimaryDataBaseConfig.PACKAGE, sqlSessionFactoryRef = "primarySqlSessionFactory")
public class PrimaryDataBaseConfig {
/**
* dao层的包路径
*/
static final String PACKAGE = "com.nbclass.szxgl.mapper";
/**
* mapper文件的相对路径
*/
private static final String MAPPER_LOCATION = "classpath*:mapper/szxgl/*.xml";
private String filters;
private String url;
private String username;
private String password;
private String driverClassName;
private int initialSize;
private int minIdle;
private int maxActive;
private long maxWait;
private long timeBetweenEvictionRunsMillis;
private long minEvictableIdleTimeMillis;
private String validationQuery;
private boolean testWhileIdle;
private boolean testOnBorrow;
private boolean testOnReturn;
private boolean poolPreparedStatements;
private int maxPoolPreparedStatementPerConnectionSize;
/**
* 主数据源使用@Primary注解进行标识
*/
@Primary
@Bean(name = "primaryDataSource")
public DataSource primaryDataSource() throws SQLException {
DruidDataSource druid = new DruidDataSource();
// 监控统计拦截的filters
druid.setFilters(filters);
// 配置基本属性
druid.setDriverClassName(driverClassName);
druid.setUsername(username);
druid.setPassword(password);
druid.setUrl(url);
//初始化时建立物理连接的个数
druid.setInitialSize(initialSize);
//最大连接池数量
druid.setMaxActive(maxActive);
//最小连接池数量
druid.setMinIdle(minIdle);
//获取连接时最大等待时间单位毫秒
druid.setMaxWait(maxWait);
//间隔多久进行一次检测检测需要关闭的空闲连接
druid.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
//一个连接在池中最小生存的时间
druid.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
//用来检测连接是否有效的sql
druid.setValidationQuery(validationQuery);
//建议配置为true不影响性能并且保证安全性
druid.setTestWhileIdle(testWhileIdle);
//申请连接时执行validationQuery检测连接是否有效
druid.setTestOnBorrow(testOnBorrow);
druid.setTestOnReturn(testOnReturn);
//是否缓存preparedStatement也就是PSCacheoracle设为truemysql设为false分库分表较多推荐设置为false
druid.setPoolPreparedStatements(poolPreparedStatements);
// 打开PSCache时指定每个连接上PSCache的大小
druid.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
return druid;
}
/**
* 创建该数据源的事务管理
*/
@Primary
@Bean(name = "primaryTransactionManager")
public DataSourceTransactionManager primaryTransactionManager() throws SQLException {
return new DataSourceTransactionManager(primaryDataSource());
}
/**
* 创建Mybatis的连接会话工厂实例
*/
@Primary
@Bean(name = "primarySqlSessionFactory")
public SqlSessionFactory primarySqlSessionFactory(@Qualifier("primaryDataSource") DataSource primaryDataSource) throws Exception {
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(primaryDataSource); // 设置数据源bean
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
.getResources(PrimaryDataBaseConfig.MAPPER_LOCATION)); // 设置mapper文件路径
return sessionFactory.getObject();
}
}

View File

@ -0,0 +1,23 @@
package com.nbclass.szxgl.controller;
import com.nbclass.szxgl.service.TestService;
import com.nbclass.util.ResultUtil;
import com.nbclass.vo.base.ResponseVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/test")
public class TestController {
@Autowired
private TestService testService;
@GetMapping("/getContent")
public ResponseVo getContent(){
return ResultUtil.success(testService.getContent());
}
}

View File

@ -0,0 +1,51 @@
package com.nbclass.szxgl.controller.mobile;
import com.nbclass.system.controller.BaseController;
import com.nbclass.szxgl.mapper2.DataDictItemMapper;
import com.nbclass.szxgl.service.ElasticSearchService;
import com.nbclass.util.ResultUtil;
import com.nbclass.vo.base.ResponseVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/api")
public class ElasticSearchController extends BaseController {
@Autowired
private ElasticSearchService elasticSearchService;
@Autowired
private DataDictItemMapper dataDictItemMapper;
/**
* 全文检索
* @param tagIds 标签
* @param caseName 项目名称
* @param pageNum
* @param pageSize
* @return
*/
@GetMapping("/getCaseName")
public ResponseVo getCaseName(String tagIds,String caseName,Integer pageNum, Integer pageSize){
Map<String, Object> map = elasticSearchService.getList(tagIds,caseName, pageNum, pageSize);
return ResultUtil.success(map);
}
/**
* 根据参数模糊匹配标签
* @param tagNames
* @return
*/
@GetMapping("/getCaseTags")
public ResponseVo getCaseTags(String tagNames){
List<Map<String,Object>> list = dataDictItemMapper.getTagNames(tagNames);
return ResultUtil.success(list);
}
}

View File

@ -30,7 +30,7 @@ import java.text.SimpleDateFormat;
import java.util.*;
/**
*
*
* @author Leon
* @datetime 2019年4月24日 下午4:27:39
*/
@ -53,7 +53,7 @@ public class ProjectController extends BaseController {
/**
* 获取项目列表
*
*
* @param entity
* @param limit 每页数量
* @param offset 页码
@ -100,7 +100,7 @@ public class ProjectController extends BaseController {
/**
* 根据ID查询项目详情记录
*
*
* @param id
*/
@RequestMapping("/findById")
@ -112,7 +112,7 @@ public class ProjectController extends BaseController {
/**
* 获取项目任务列表
*
*
* @param pid
* @param limit
* @param offset
@ -136,7 +136,7 @@ public class ProjectController extends BaseController {
/**
* 获取项目任务进度日志列表
*
*
* @param taskId
*/
/*
@ -166,7 +166,7 @@ public class ProjectController extends BaseController {
/**
* 添加项目
*
*
* @param p
* @param errors
* @param isSendMsg
@ -278,4 +278,5 @@ public class ProjectController extends BaseController {
service.updateProjectStatus(id, contractno, status);
return ResultUtil.success("success");
}
}

View File

@ -8,10 +8,14 @@ import com.nbclass.exception.ParameterException;
import com.nbclass.holder.SpringContextHolder;
import com.nbclass.system.controller.BaseController;
import com.nbclass.system.model.User;
import com.nbclass.szxgl.mapper.ListTypeMapper;
import com.nbclass.szxgl.model.ListType;
import com.nbclass.szxgl.model.ProjectTask;
import com.nbclass.szxgl.model.ProjectTaskJournal;
import com.nbclass.szxgl.model.SyUsers;
import com.nbclass.szxgl.service.ProjectService;
import com.nbclass.szxgl.service.ProjectTaskService;
import com.nbclass.szxgl.service.SyUsersService;
import com.nbclass.util.PageUtil;
import com.nbclass.util.ResultUtil;
import com.nbclass.vo.base.ResponseVo;
@ -20,10 +24,8 @@ import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.validation.Errors;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.text.SimpleDateFormat;
@ -45,6 +47,12 @@ public class ProjectTaskController extends BaseController {
@Resource
private ProjectTaskService projectTaskService;
@Resource
private ListTypeMapper listTypeMapper;
@Resource
private SyUsersService syUsersService;
@InitBinder
public void initBinder(WebDataBinder binder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
@ -89,12 +97,47 @@ public class ProjectTaskController extends BaseController {
@RequestMapping("/journal/getList")
@ResponseBody
public ResponseVo selectProjectTaskJournalList(String taskId) {
User user = (User) SecurityUtils.getSubject().getPrincipal();
SyUsers syUsers = syUsersService.selectByUsername(user.getUserId());
//根据部门id上级领导
String name = syUsersService.getByIsLeader(syUsers.getDeptId());
boolean result = false;
//判断用户是否上级领导
if(user.getUsername().equals(name)){
result = true;
}
List<ProjectTaskJournal> list = service.getTaskJournalList(taskId);
JSONObject obj = new JSONObject();
obj.put("rows", list);
obj.put("result", result);
return ResultUtil.success("success", obj);
}
/**
* 更新任务评分分数和点评内容
* @param taskId 任务id
* @param score 评分分数
* @param comment 点评内容
* @return
*/
@RequestMapping("/journal/update")
@ResponseBody
public ResponseVo updateProjectTaskJournal(String taskId,Double score,String comment) {
// User user = (User) SecurityUtils.getSubject().getPrincipal();
// if(user==null && SpringContextHolder.isProd()) {
// throw new ParameterException("登录失效,请重新登录!");
// }
ProjectTaskJournal projectTaskJournal = new ProjectTaskJournal();
projectTaskJournal.setScore(score);
projectTaskJournal.setComment(comment);
projectTaskJournal.setId(taskId);
//projectTaskJournal.setCommentId(user.getUserId());
projectTaskJournal.setCommentId("85cde14893fc4c2d805a1876c0718106");
projectTaskJournal.setStatus(1);
service.updateTaskJournal(projectTaskJournal);
return ResultUtil.success("success");
}
/**
* 删除任务
*
@ -119,11 +162,11 @@ public class ProjectTaskController extends BaseController {
@RequestMapping("add")
@ResponseBody
public ResponseVo add(@Valid ProjectTask t, Errors errors, Integer isSendMsg, String[] userIds) {
public ResponseVo add(@Valid ProjectTask t, Errors errors, Integer isSendMsg, String[] userIds,String listValues) {
if (errors.hasErrors()) {
return ResultUtil.error("参数验证失败");
}
projectTaskService.addProjectTask(t, isSendMsg, userIds);
projectTaskService.addProjectTask(t, isSendMsg, userIds,listValues);
return ResultUtil.success("success");
}
@ -182,17 +225,42 @@ public class ProjectTaskController extends BaseController {
* 添加任务进度日志
*
* @param j
* @param listType json数组
* @param errors
* @param speed
*/
@RequestMapping("/myTask/addJournal")
@ResponseBody
public ResponseVo addJournal(@Valid ProjectTaskJournal j,Errors errors,short speed) {
public ResponseVo addJournal(@Valid ProjectTaskJournal j,String listType,Errors errors,short speed) {
if (errors.hasErrors()) {
return ResultUtil.error("参数验证失败");
}
projectTaskService.addProjectTaskJournal(j, speed);
projectTaskService.addProjectTaskJournal(j,listType, speed);
return ResultUtil.success("success");
}
/**
* 获取下拉列表
* @return
*/
@RequestMapping("/myTask/getComboBox")
@ResponseBody
public ResponseVo getComboBox(){
List<ListType> listTypes = listTypeMapper.getComboBox();
return ResultUtil.success(listTypes);
}
/**
* 获取字体类型列表
* @param name 字体类型名称名称
* @return
*/
@RequestMapping("/myTask/getFontType")
@ResponseBody
public ResponseVo getFontType(String name){
List<ListType> listTypes = listTypeMapper.getFontType(name);
return ResultUtil.success(listTypes);
}
}

View File

@ -31,78 +31,78 @@ import com.nbclass.util.HttpUtils;
*/
/*@WebFilter("*.html")*/
public class WxWorkFilter implements Filter {
private static final Logger logger = LoggerFactory.getLogger(WxWorkFilter.class);
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;
response.setHeader("Cache-Control", "no-store");
String httpRequestFullURL = getHttpRequestFullURL(request);
String redirect_uri = ActivityConstants.qywx_api_domain + "/api/oauth?agentid="+ActivityConstants.qywx_agentid+"&redirect_uri="+httpRequestFullURL;
Subject subject = SecurityUtils.getSubject();
// String userkey = (String) request.getSession().getAttribute(ActivityConstants.session_key_user_id);
// logger.info("[企业微信授权拦截器] userkey="+userkey+", requrl: "+httpRequestFullURL);
if(subject.isAuthenticated()){ // 已登录状态
chain.doFilter(request, response);
return;
}
String key = StringUtils.trimToEmpty(request.getParameter("key"));
if("xglgg".equals(key)){ // 测试时传key绕过登录
MyUsernamePasswordToken token = new MyUsernamePasswordToken("liixi"); // 免密登录
token.setRememberMe(true);
try {
subject.login(token);
} catch (AuthenticationException e) {
outPrintError(response, "该登录账号不存在,如有疑问请联系企业管理员!");
return;
}
chain.doFilter(request, response);
return;
}
String code = request.getParameter("code");
if(StringUtils.isBlank(code)){
response.sendRedirect(redirect_uri);
return;
}
String url = ActivityConstants.qywx_api_domain + "/api/oauthInfo?agentid="+ActivityConstants.qywx_agentid+"&code=" + code;
JSONObject result = HttpUtils.httpGet(url);
if(result != null && result.getIntValue("ret") == 0 && StringUtils.isNotBlank(result.getString("userid"))
&& !"null".equalsIgnoreCase(result.getString("userid"))){
logger.info("企业微信授权获取到用户信息: "+result.toString());
String userid = result.getString("userid");
request.getSession().setAttribute(ActivityConstants.session_key_user_id, userid);
// OA系统shiro登录
MyUsernamePasswordToken token = new MyUsernamePasswordToken(userid); // 免密登录
token.setRememberMe(true);
try {
subject.login(token);
} catch (AuthenticationException e) {
outPrintError(response, "该登录账号不存在,如有疑问请联系企业管理员!");
return;
}
}else{
if(result!=null && (result.getIntValue("errcode") == 40029 || result.getIntValue("errcode") == 40163)){
logger.info("授权失败, 将重新跳转到微信授权, RedirectURL : " + redirect_uri);
redirect_uri = CommonUtils.removeParamValue(redirect_uri, "code");
response.sendRedirect(redirect_uri);
return;
}
outPrintError(response, "微信授权失败,你可能未关注该企业号,请关注后重试!");
return;
}
// response.setHeader("Cache-Control", "no-store");
//
// String httpRequestFullURL = getHttpRequestFullURL(request);
// String redirect_uri = ActivityConstants.qywx_api_domain + "/api/oauth?agentid="+ActivityConstants.qywx_agentid+"&redirect_uri="+httpRequestFullURL;
//
// Subject subject = SecurityUtils.getSubject();
//
// // String userkey = (String) request.getSession().getAttribute(ActivityConstants.session_key_user_id);
// // logger.info("[企业微信授权拦截器] userkey="+userkey+", requrl: "+httpRequestFullURL);
//
// if(subject.isAuthenticated()){ // 已登录状态
// chain.doFilter(request, response);
// return;
// }
//
// String key = StringUtils.trimToEmpty(request.getParameter("key"));
// if("xglgg".equals(key)){ // 测试时传key绕过登录
// MyUsernamePasswordToken token = new MyUsernamePasswordToken("liixi"); // 免密登录
// token.setRememberMe(true);
// try {
// subject.login(token);
// } catch (AuthenticationException e) {
// outPrintError(response, "该登录账号不存在,如有疑问请联系企业管理员!");
// return;
// }
// chain.doFilter(request, response);
// return;
// }
//
//
// String code = request.getParameter("code");
// if(StringUtils.isBlank(code)){
// response.sendRedirect(redirect_uri);
// return;
// }
//
// String url = ActivityConstants.qywx_api_domain + "/api/oauthInfo?agentid="+ActivityConstants.qywx_agentid+"&code=" + code;
// JSONObject result = HttpUtils.httpGet(url);
// if(result != null && result.getIntValue("ret") == 0 && StringUtils.isNotBlank(result.getString("userid"))
// && !"null".equalsIgnoreCase(result.getString("userid"))){
// logger.info("企业微信授权获取到用户信息: "+result.toString());
// String userid = result.getString("userid");
// request.getSession().setAttribute(ActivityConstants.session_key_user_id, userid);
//
// // OA系统shiro登录
// MyUsernamePasswordToken token = new MyUsernamePasswordToken(userid); // 免密登录
// token.setRememberMe(true);
// try {
// subject.login(token);
// } catch (AuthenticationException e) {
// outPrintError(response, "该登录账号不存在,如有疑问请联系企业管理员!");
// return;
// }
// }else{
// if(result!=null && (result.getIntValue("errcode") == 40029 || result.getIntValue("errcode") == 40163)){
// logger.info("授权失败, 将重新跳转到微信授权, RedirectURL : " + redirect_uri);
// redirect_uri = CommonUtils.removeParamValue(redirect_uri, "code");
// response.sendRedirect(redirect_uri);
// return;
// }
// outPrintError(response, "微信授权失败,你可能未关注该企业号,请关注后重试!");
// return;
// }
//
chain.doFilter(request, response);
}
@ -120,7 +120,7 @@ public class WxWorkFilter implements Filter {
return requestURL.append('?').append(queryString).toString();
}
}
/**
* 输出错误信息到页面
* @param response
@ -151,5 +151,5 @@ public class WxWorkFilter implements Filter {
}
}
}

View File

@ -11,8 +11,12 @@ import com.nbclass.util.MyMapper;
public interface ListTypeMapper extends MyMapper<ListType> {
public List<ListType> getList(@Param("listType")String listType);
public String getListValue(@Param("listType")String listType,@Param("id")String id);
public String getAreaIdByName(@Param("areaName")String areaName);
}
List<ListType> getComboBox();
List<ListType> getFontType(String name);
}

View File

@ -3,10 +3,12 @@ package com.nbclass.szxgl.mapper;
import java.util.List;
import com.nbclass.szxgl.model.ProjectTaskJournal;
import com.nbclass.szxgl.model.ProjectTaskJournalFontType;
import com.nbclass.util.MyMapper;
import org.apache.ibatis.annotations.Param;
public interface ProjectTaskJournalMapper extends MyMapper<ProjectTaskJournal> {
/**
* 根据任务id获取任务日志进度列表
* @param taskId
@ -15,4 +17,24 @@ public interface ProjectTaskJournalMapper extends MyMapper<ProjectTaskJournal> {
public List<ProjectTaskJournal> getList(String taskId);
public void deleteByTaskId(String projectTaskId);
}
/**
* 更新任务评分分数和点评内容
* @return
*/
void updateTaskJournal(ProjectTaskJournal projectTaskJournal);
/**
* 点评人id获取用户姓名
* @param id
* @return
*/
String getUserName(String id);
/**
* 更新日志字体类型信息
*/
void addTaskFontType(ProjectTaskJournalFontType fontType);
}

View File

@ -0,0 +1,11 @@
package com.nbclass.szxgl.mapper;
import com.nbclass.szxgl.model.ProjectTaskTerm;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ProjectTaskTermMapper {
void addProjectTaskTerm(ProjectTaskTerm projectTaskTerm);
}

View File

@ -8,14 +8,14 @@ import com.nbclass.util.MyMapper;
import org.apache.ibatis.annotations.Param;
public interface QywxUserMapper extends MyMapper<QywxUser> {
List<Map<String, Object>> findByUserId(String userId);
List<Map<String, Object>> findAllByDepartment(String depId);
List<Map<String, Object>> findByDepartment(String depId);
List<Map<String, Object>> findSuperiorLeadersByDepartment(String depId);
/**
@ -25,4 +25,4 @@ public interface QywxUserMapper extends MyMapper<QywxUser> {
*/
List<Map<String, Object>> getUserInfoByUserIds(@Param("userIds") List<String> userIds);
}
}

View File

@ -7,8 +7,15 @@ import com.nbclass.szxgl.model.SyUsers;
import com.nbclass.util.MyMapper;
public interface SyUsersMapper extends MyMapper<SyUsers> {
public SyUsers findByUserName(String userName);
public List<String> findIdByDeptId(String deptId);
}
/**
* 根据部门id上级领导
* @param deptId
* @return
*/
String getByIsLeader(String deptId);
}

View File

@ -0,0 +1,19 @@
package com.nbclass.szxgl.mapper2;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Map;
@Mapper
public interface DataDictItemMapper {
/**
* 根据参数模糊匹配标签
* @param tagNames
* @return
*/
List<Map<String,Object>> getTagNames(String tagNames);
}

View File

@ -0,0 +1,13 @@
package com.nbclass.szxgl.mapper2;
import com.nbclass.szxgl.model.Content;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface TestMapper {
List<Content> getContent();
}

View File

@ -0,0 +1,30 @@
package com.nbclass.szxgl.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import lombok.Data;
@Data
@Table(name = "content")
public class Content implements Serializable {
private static final long serialVersionUID = -6422276602170816740L;
/**
* ID, 主键,自增
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 标题
*/
private String title;
}

View File

@ -3,10 +3,11 @@ package com.nbclass.szxgl.model;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.List;
@Table(name = "list_values")
public class ListType {
@Id
private String id;
@ -16,7 +17,9 @@ public class ListType {
@Column(name = "list_type")
private String listType;
/**
private List<ListType> listTypes;
/**
* 名称
*/
@Column(name = "list_value")
@ -46,11 +49,12 @@ public class ListType {
this.listValue = listValue;
}
public List<ListType> getListTypes() {
return listTypes;
}
public void setListTypes(List<ListType> listTypes) {
this.listTypes = listTypes;
}
}
}

View File

@ -48,6 +48,36 @@ public class ProjectTaskJournal {
@Column(name = "_create_user_id")
private String createUserId;
/**
*素材是否有侵权风险1无风险 2有风险
*/
@Column(name = "_risk")
private Integer risk;
/**
* 评分分数
*/
@Column(name = "_score")
private Double score;
/**
* 任务点评
*/
@Column(name = "_comment")
private String comment;
/**
* 点评人id
*/
@Column(name = "_comment_id")
private String commentId;
/**
* 点评状态1已点评 2未点评
*/
@Column(name = "_status")
private Integer status;
/**
* 创建时间
*/
@ -60,16 +90,16 @@ public class ProjectTaskJournal {
@Column(name = "_update_time")
private Date updateTime;
// 以下是查询字段
/**
* 创建人姓名
*/
@Transient
private String createUserName;
/**
* @return id
*/
@ -235,6 +265,44 @@ public class ProjectTaskJournal {
public void setCreateUserName(String createUserName) {
this.createUserName = createUserName;
}
}
public Integer getRisk() {
return risk;
}
public void setRisk(Integer risk) {
this.risk = risk;
}
public double getScore() {
return score;
}
public void setScore(Double score) {
this.score = score;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public String getCommentId() {
return commentId;
}
public void setCommentId(String commentId) {
this.commentId = commentId;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
}

View File

@ -0,0 +1,29 @@
package com.nbclass.szxgl.model;
import lombok.Data;
import java.util.Date;
@Data
public class ProjectTaskJournalFontType {
private String id;
/**
* 字典值id
*/
private String listValuesId;
/**
* 任务id
*/
private String projectTaskJournalId;
/**
* 创建时间
*/
private Date createdTime;
private String listValue;
}

View File

@ -0,0 +1,25 @@
package com.nbclass.szxgl.model;
import lombok.Data;
@Data
public class ProjectTaskTerm {
private String id ;
/**
* 项目id
*/
private String projectId;
/**
* 字典值id
*/
private String listValuesId;
/**
* 工期
*/
private Integer term;
}

View File

@ -0,0 +1,22 @@
package com.nbclass.szxgl.service;
import java.util.List;
import java.util.Map;
/**
* ES搜索
* @author Leon
* @datetime 2020年6月1日 下午3:00:41
*/
public interface ElasticSearchService {
/**
* 根据条件查询列表
* @param pageNum
* @param pageSize
* @return
*/
public Map<String, Object> getList(String tagIds,String caseName,Integer pageNum, Integer pageSize);
}

View File

@ -13,7 +13,7 @@ import com.nbclass.szxgl.model.ProjectTask;
import com.nbclass.szxgl.model.ProjectTaskJournal;
/**
*
*
* @author Leon
* @datetime 2019年4月24日 下午4:24:11
*/
@ -26,7 +26,7 @@ public interface ProjectService {
* @return
*/
public boolean hasUpdateProject(String pid);
/**
* 拥有对项目文档的权限
* 管理员项目创建者项目负责人项目任务执行人 才有修改权限
@ -34,7 +34,7 @@ public interface ProjectService {
* @return
*/
public boolean hasPowerForFile(String pid);
/**
* 是否有 添加 修改 删除 项目任务的权限
* 只有项目创建者或项目负责人才有此权限
@ -42,7 +42,7 @@ public interface ProjectService {
* @return
*/
public boolean hasPowerForTask(String pid);
/**
* 根据条件查询项目列表
* @param project
@ -56,7 +56,7 @@ public interface ProjectService {
* @return 用户id列表
*/
public List<String> selectUserIdsByDeptId(String deptId);
/**
* 根据主键id查询
* @param pid
@ -70,14 +70,14 @@ public interface ProjectService {
* @return
*/
public List<ProjectFiles> getFileList(String pid);
/**
* 项目任务列表
* @param pid
* @return
*/
public List<ProjectTask> getTaskList(String pid);
/**
* 项目任务进度日志列表
* @param taskId
@ -90,7 +90,7 @@ public interface ProjectService {
* @return
*/
public List<ListType> getListValues(String listType);
/**
* 添加项目
* @param p
@ -152,5 +152,11 @@ public interface ProjectService {
* @return
*/
public void updateProjectStatus(String id, String contractno, String status);
/**
* 更新任务评分分数和点评内容
* @return
*/
void updateTaskJournal(ProjectTaskJournal projectTaskJournal);
}

View File

@ -27,7 +27,7 @@ public interface ProjectTaskService {
* @param userIds
* @return
*/
public void addProjectTask(ProjectTask t, Integer isSendMsg, String[] userIds);
public void addProjectTask(ProjectTask t, Integer isSendMsg, String[] userIds,String listValues);
/**
* 修改项目任务
@ -50,7 +50,7 @@ public interface ProjectTaskService {
* @param j
* @return
*/
public void addProjectTaskJournal(ProjectTaskJournal j, short speed);
public void addProjectTaskJournal(ProjectTaskJournal j,String listType, short speed);
/**
* //判断当前用户是否是任务的执行人

View File

@ -3,16 +3,23 @@ package com.nbclass.szxgl.service;
import java.util.List;
import java.util.Map;
import com.nbclass.system.model.User;
import com.nbclass.szxgl.model.SyUsers;
public interface SyUsersService {
/**
* 根据用户id查询
* @param username
* @return
*/
public SyUsers selectByUsername(String username);
/**
* 根据部门id上级领导
* @param deptId
* @return
*/
String getByIsLeader(String deptId);
}

View File

@ -0,0 +1,11 @@
package com.nbclass.szxgl.service;
import com.nbclass.szxgl.model.Content;
import java.util.List;
public interface TestService {
List<Content> getContent();
}

View File

@ -0,0 +1,99 @@
package com.nbclass.szxgl.service.impl;
import com.alibaba.fastjson.JSON;
import com.nbclass.szxgl.model.Content;
import com.nbclass.szxgl.service.ElasticSearchService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.*;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
@Service
@Slf4j
public class ElasticSearchServiceImpl implements ElasticSearchService {
@Autowired
private RestHighLevelClient restHighLevelClient;
@Override
public Map<String, Object> getList(String tagIds,String caseName,Integer pageNum, Integer pageSize) {
// 封装Map参数返回
Map<String, Object> result = new HashMap<>();
try {
// 选择标签或来源过滤时从数据库查询记录
/*if(StringUtils.isNotBlank(tagIds) || StringUtils.isNotBlank(sourceIds)) {
return getListByMySQL(pageNum, pageSize, type, keyWord, tagIds, sourceIds);
}*/
if(StringUtils.isNoneBlank(tagIds) || StringUtils.isNoneBlank(caseName)){
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
// 分页采用简单的from + size分页适用数据量小的了解更多分页方式可自行查阅资料
searchSourceBuilder.from((pageNum - 1) * pageSize); // 从0开始
searchSourceBuilder.size(pageSize);
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must(QueryBuilders.termQuery("release", 2));
// if(StringUtils.isNoneBlank(tagIds) && StringUtils.isNoneBlank(caseName)){
// boolQueryBuilder.must(QueryBuilders.termQuery("release", 2));
// }
if (StringUtils.isNoneBlank(tagIds)){
List<String> list = Arrays.asList(tagIds.split(","));
for(String tagId:list) {
boolQueryBuilder.must(QueryBuilders.termQuery("tagList.tid", tagId));
}
}
if(StringUtils.isNoneBlank(caseName)){
BoolQueryBuilder keywordQuery = QueryBuilders.boolQuery();
keywordQuery.must(QueryBuilders.matchQuery("title", caseName)).boost(2F);
boolQueryBuilder.should(keywordQuery);
}else {
// 排序根据点赞数倒叙
searchSourceBuilder.sort("praiseno", SortOrder.DESC);
}
searchSourceBuilder.query(boolQueryBuilder);
// SearchRequest
SearchRequest searchRequest = new SearchRequest();
searchRequest.source(searchSourceBuilder);
// 查询ES
SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
SearchHits hits = searchResponse.getHits();
// 获取总数
Long total = hits.getTotalHits().value;
// 遍历封装列表对象
List<Content> dataList = new ArrayList<>();
SearchHit[] searchHits = hits.getHits();
for (SearchHit searchHit : searchHits) {
Content entity = JSON.parseObject(searchHit.getSourceAsString(), Content.class);
dataList.add(entity);
System.out.println(searchHit.getSourceAsString());
}
result.put("total", total); // 总记录数
result.put("rows", dataList); // 数据体
int totalPage = (int)(total % pageSize==0 ? total/pageSize : total/pageSize+1);
result.put("totalPage", totalPage); // 总页数
}
}catch (Exception e) {
log.error("从es查询数据列表异常", e);
}
return result;
}
}

View File

@ -991,6 +991,11 @@ public class ProjectServiceImpl implements ProjectService {
mapper.updateProjectStatus(setuptime, id, contractno, Integer.parseInt(status),updatetime);
}
@Override
public void updateTaskJournal(ProjectTaskJournal projectTaskJournal) {
journalMapper.updateTaskJournal(projectTaskJournal);
}
@Override
public List<Map<String, Object>> selectZxrUserObj(String userIds) {
List<Map<String, Object>> resultMap = new ArrayList<>();

View File

@ -1,5 +1,7 @@
package com.nbclass.szxgl.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.nbclass.exception.ParameterException;
import com.nbclass.exception.ServiceException;
import com.nbclass.system.model.User;
@ -48,6 +50,12 @@ public class ProjectTaskServiceImpl implements ProjectTaskService {
@Resource
ProjectService projectService;
@Resource
private ProjectTaskTermMapper projectTaskTermMapper;
@Resource
private QywxUserMapper qywxUserMapper;
@Override
public boolean deleteProjectTask(String projectId, String[] ids) {
@ -79,7 +87,7 @@ public class ProjectTaskServiceImpl implements ProjectTaskService {
@Transactional
@Override
public void addProjectTask(ProjectTask t, Integer isSendMsg, String[] userIds) {
public void addProjectTask(ProjectTask t, Integer isSendMsg, String[] userIds,String listValues) {
if(t.getStartTime().getTime() > t.getEndTime().getTime()) {
throw new ParameterException("项目任务时间范围不对!");
}
@ -98,6 +106,16 @@ public class ProjectTaskServiceImpl implements ProjectTaskService {
t.setNotify((short) 0);//默认0生产环境改为1
projectTaskMapper.insert(t);
JSONArray jsonArray = JSONObject.parseArray(listValues);
for (int i = 0; i < jsonArray.size(); i++) {
//添加工期信息
ProjectTaskTerm projectTaskTerm = jsonArray.getObject(i, ProjectTaskTerm.class);
projectTaskTerm.setProjectId(t.getId());
projectTaskTerm.setId(UUIDUtil.uuid());
projectTaskTermMapper.addProjectTaskTerm(projectTaskTerm);
}
// 等待保存的对象集合
List<ProjectTaskUser> c = new ArrayList<ProjectTaskUser>();
Set<String> sendIds = new HashSet<String>();// 需要发送消息提醒的用户
@ -262,7 +280,7 @@ public class ProjectTaskServiceImpl implements ProjectTaskService {
@Override
public void addProjectTaskJournal(ProjectTaskJournal j, short speed) {
public void addProjectTaskJournal(ProjectTaskJournal j,String listType,short speed) {
ProjectTask t = projectTaskMapper.findById(j.getProjectTaskId());
if(t==null){
throw new ParameterException("任务不存在,可能已被删除!");
@ -297,6 +315,24 @@ public class ProjectTaskServiceImpl implements ProjectTaskService {
j.setId(UUIDUtil.uuid());
j.setCreateTime(DateUtil.currentTimestamp());
int insert = projectTaskJournalMapper.insert(j);
StringBuilder fontTypeNames = new StringBuilder();
//更新日志字体类型信息
if(StringUtils.isNoneBlank(listType)){
JSONArray jsonArray = JSONObject.parseArray(listType);
for (int i = 0; i < jsonArray.size(); i++) {
ProjectTaskJournalFontType fontType = jsonArray.getObject(i, ProjectTaskJournalFontType.class);
fontType.setId(UUIDUtil.uuid());
fontType.setProjectTaskJournalId(j.getId());
projectTaskJournalMapper.addTaskFontType(fontType);
//该步即不会第一位有也防止最后一位拼接
if(fontTypeNames.length() > 0){
fontTypeNames.append("");
}
fontTypeNames.append(fontType.getListValue());
}
}
if(insert>0){
//更新任务进度
projectTaskMapper.updateTaskSpeed(t.getId(), speed);
@ -329,13 +365,21 @@ public class ProjectTaskServiceImpl implements ProjectTaskService {
if(fzIds!=null && fzIds.size()>0)touser += (StringUtils.isBlank(touser)?"":"|") + StringUtils.join(fzIds, "|");
if(userIds!=null && userIds.size()>0)touser += (StringUtils.isBlank(touser)?"":"|") + StringUtils.join(userIds, "|");
//点评人id获取用户姓名
String name = projectTaskJournalMapper.getUserName(j.getId());
String description =
"<div class=\"gray\">"+DateUtil.date2String(new Date(), "yyyy年MM月dd日 HH:mm")+"</div><br><br>"
+ "项目名称:"+projectName+"<br>"
+ "任务名称:"+taskName
+ "<div class=\"highlight\">"+j.getJournal()+"</div><br>"
// + "操作用户:"+user.getUsername()+"<br>"
+ "进度说明:"+j.getContent();
+ "已使用字体:"+fontTypeNames+"<br>"
+ "素材是否有侵权风险?:"+""+((j.getRisk() == 1) ? "无风险":"有风险")+""
+ "进度说明:"+j.getContent()+"<br>"
+ name+"&nbsp;&nbsp;&nbsp;&nbsp;"
+ ""+((j.getStatus() == 1) ? "已点评":"未点评")+""+"<br>"
+ "点评内容:"+""+((j.getComment() == null) ? "暂无评论":""+j.getComment()+"")+"";
if(StringUtils.isNotBlank(touser)){
SendMsgUtil.sendWxMsgByNewTask(touser, t.getProjectId(), description);
}

View File

@ -2,6 +2,7 @@ package com.nbclass.szxgl.service.impl;
import javax.annotation.Resource;
import com.nbclass.system.model.User;
import org.springframework.stereotype.Service;
import com.nbclass.szxgl.mapper.QywxUserMapper;
@ -11,7 +12,7 @@ import com.nbclass.szxgl.service.SyUsersService;
@Service
public class SyUsersServiceImpl implements SyUsersService {
@Resource
private SyUsersMapper mapper;
@Resource
@ -25,6 +26,9 @@ public class SyUsersServiceImpl implements SyUsersService {
return result;
}
@Override
public String getByIsLeader(String deptId) {
return mapper.getByIsLeader(deptId);
}
}

View File

@ -0,0 +1,21 @@
package com.nbclass.szxgl.service.impl;
import com.nbclass.szxgl.mapper2.TestMapper;
import com.nbclass.szxgl.model.Content;
import com.nbclass.szxgl.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class TestServiceImpl implements TestService {
@Autowired
private TestMapper testMapper;
@Override
public List<Content> getContent() {
return testMapper.getContent();
}
}

View File

@ -14,6 +14,8 @@
package com.nbclass.util;
import com.nbclass.system.model.User;
import java.io.UnsupportedEncodingException;
import java.security.SecureRandom;
@ -53,7 +55,7 @@ import java.security.SecureRandom;
* String stronger_salt = BCrypt.gensalt(12)<br />
* </code>
* <p>
* The amount of work increases exponentially (2**log_rounds), so
* The amount of work increases exponentially (2**log_rounds), so
* each increment is twice as much work. The default log_rounds is
* 10, and the valid range is 4 to 30.
*
@ -774,4 +776,5 @@ public class BCrypt {
ret |= hashed_bytes[i] ^ try_bytes[i];
return ret == 0;
}
}

View File

@ -1,19 +1,25 @@
package com.nbclass.util;
import org.apache.shiro.codec.Base64;
import org.apache.shiro.codec.Hex;
import org.apache.shiro.crypto.AesCipherService;
import org.apache.shiro.crypto.RandomNumberGenerator;
import org.apache.shiro.crypto.SecureRandomNumberGenerator;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;
import com.nbclass.system.model.User;
import java.security.Key;
/**
* 密码加密
* @author Leon
* @datetime 2019年4月1日 下午10:09:02
*/
public class PasswordHelper {
private static RandomNumberGenerator randomNumberGenerator = new SecureRandomNumberGenerator();
private static String algorithmName = "md5";
private static int hashIterations = 2;
@ -37,7 +43,7 @@ public class PasswordHelper {
public static String encryptPwdByBCrypt(String password){
return BCrypt.hashpw(password, BCrypt.gensalt());
}
/**
* BCrypt 密码验证
* @param password 明文
@ -47,17 +53,26 @@ public class PasswordHelper {
public static boolean checkPwdByBCrypt(String password, String ciphertext){
return BCrypt.checkpw(password, ciphertext);
}
public static void main(String[] args) {
User user = new User();
user.setUsername("admin");
user.setPassword("szxgl.com");
encryptPassword(user);
System.out.println("salt="+user.getSalt());
System.out.println("password="+user.getPassword());
String pwd1 = encryptPwdByBCrypt("123456");
boolean result = checkPwdByBCrypt("123456", pwd1);
System.out.println("pwd1="+pwd1+", result="+result);
String hashAlgorithmName = "MD5";//加密方式
Object crdentials = "123456";//密码原值
Object salt = null;//盐值
int hashIterations = 2;//加密1024次
Object result2 = new SimpleHash(hashAlgorithmName,crdentials,salt,hashIterations);
System.out.println(result2);
}
}

View File

@ -23,23 +23,20 @@ import java.sql.PreparedStatement;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Random;
import java.util.UUID;
import java.util.Vector;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.nbclass.szxgl.model.ProjectTaskTerm;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.codec.digest.UnixCrypt;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
/**
* 工具类
@ -49,9 +46,9 @@ import org.apache.commons.lang3.StringUtils;
public class Utility implements java.io.Serializable {
private static final long serialVersionUID = 1L;
protected static Utility instance = null;
public static synchronized void setInstance(boolean clear) {
if (clear)
instance = null;
@ -68,7 +65,7 @@ public class Utility implements java.io.Serializable {
protected Utility() {
instance = null;
}
/**
* Convert integer string array into integer array
@ -102,7 +99,7 @@ public class Utility implements java.io.Serializable {
}
return result;
}
public static int[] toIntArray(String str){
if(str == null || str.equals("")) return null;
int[] result;
@ -124,7 +121,7 @@ public class Utility implements java.io.Serializable {
}
return result;
}
public static String encodeHTML(String value) {
if (value == null)
return "";
@ -143,7 +140,7 @@ public class Utility implements java.io.Serializable {
/**
* This function will convert the string to a unicode string. (e.g. "\u7f51")
*
*
* @param value
* @return
*/
@ -183,7 +180,7 @@ public class Utility implements java.io.Serializable {
/**
* Create a instance from a class
*
*
* @param service
* @return @throws
* ClassNotFoundException
@ -203,14 +200,14 @@ public class Utility implements java.io.Serializable {
result = bd.setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue();
return result;
}
public static float getRoundUp(float d, int scale) {
float result = d;
BigDecimal bd = new BigDecimal(d);
result = bd.setScale(scale, BigDecimal.ROUND_HALF_UP).floatValue();
return result;
}
public static Calendar getCalendar(Date date) throws Exception {
Calendar result = Calendar.getInstance();
result.setTime(date);
@ -222,10 +219,10 @@ public class Utility implements java.io.Serializable {
result.setTimeInMillis(milliseconds);
return result;
}
public static String getTimeStampWithMillis() {
return getTimeStampWithMillis(Calendar.getInstance());
}
}
public static String getTimeStampWithMillis(Calendar calendar) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
@ -280,7 +277,7 @@ public class Utility implements java.io.Serializable {
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(date.getTime());
}
public static String getHttpContent(String urlStr, String encoding) throws Exception {
URL url = new URL(urlStr);
InputStream is = null;
@ -323,7 +320,7 @@ public class Utility implements java.io.Serializable {
}
return bos.toByteArray();
}
public static Object byteArrayToObject(byte[] array) throws Exception {
ByteArrayInputStream bis = new ByteArrayInputStream(array);
@ -371,24 +368,24 @@ public class Utility implements java.io.Serializable {
public static String getFormatedTimeStamp() {
return getFormatedTimeStamp(Calendar.getInstance());
}
public static String getFormatedTimeStamp(Calendar calendar) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
return sdf.format(calendar.getTime());
}
public static String getTimeStamp() {
Calendar calendar = Calendar.getInstance();
return getTimeStamp(calendar);
}
public static String getTimeStamp(Calendar calendar) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String result = sdf.format(calendar.getTime());
result = result + "000";
return result;
}
public static String getFormatedFileSize(long value) {
double kb = value / 1024.00;
@ -420,13 +417,13 @@ public class Utility implements java.io.Serializable {
calendar.add(Calendar.DATE, -1);
return calendar.getTime();
}
public static String getDateFormat(Date date, String format) {
if (date == null) return "";
SimpleDateFormat dateFormat = new SimpleDateFormat(format, Locale.US);
return dateFormat.format(date);
}
public static java.sql.Date UtilDateToSQLDate(Date utilDate) {
if (utilDate == null) return null;
return new java.sql.Date(utilDate.getTime());
@ -441,19 +438,19 @@ public class Utility implements java.io.Serializable {
if (SQLDate == null) return null;
return new Date(SQLDate.getTime());
}
public static java.util.Date SQLDateToUtilDate(java.sql.Timestamp SQLDate) {
if (SQLDate == null) return null;
return new Date(SQLDate.getTime());
}
public static Date parseDate(String strDate, String pattern) throws Exception {
if (strDate == null || strDate.trim().equals("")) return null;
SimpleDateFormat format = new SimpleDateFormat(pattern);
Date date = format.parse(strDate);
return date;
}
public static String getSearchFormat(String pattern) {
if (pattern == null) return "%";
pattern = pattern.trim(); // format maybe : A, A%, %A%, A%B%, %A"B
@ -464,7 +461,7 @@ public class Utility implements java.io.Serializable {
}
return pattern;
}
public static String getLeadingZero(int intValue, int maxLength) {
String result = String.valueOf(intValue);
if (result.length() < maxLength) {
@ -474,17 +471,17 @@ public class Utility implements java.io.Serializable {
}
return result;
}
public static String getQuantityAsString(float qty) {
DecimalFormat df = new DecimalFormat("#0.00");
return df.format(qty);
}
public static String getQuantityAsString(double qty) {
DecimalFormat df = new DecimalFormat("#0.00");
return df.format(qty);
}
public static String getQuantityAsString(float amt, String pattern) {
DecimalFormat df = new DecimalFormat(pattern);
return df.format(amt);
@ -504,17 +501,17 @@ public class Utility implements java.io.Serializable {
DecimalFormat df = new DecimalFormat(pattern);
return df.format(amt);
}
public static String getAmountAsString(double amt, String pattern) {
DecimalFormat df = new DecimalFormat(pattern);
return df.format(amt);
}
public static String getFloatFormat(float f, String pattern) {
DecimalFormat df = new DecimalFormat(pattern);
return df.format(f);
}
}
public static String getDoubleFormat(double d, String pattern) {
DecimalFormat df = new DecimalFormat(pattern);
return df.format(d);
@ -530,30 +527,30 @@ public class Utility implements java.io.Serializable {
public static double mul(double d1, double d2) {
BigDecimal b1 = new BigDecimal(String.valueOf(d1));
BigDecimal b2 = new BigDecimal(String.valueOf(d2));
return b1.multiply(b2).doubleValue();
}
public static double mul(BigDecimal b1, double d2) {
BigDecimal b2 = new BigDecimal(String.valueOf(d2));
return b1.multiply(b2).doubleValue();
}
public static double add(double d1, double d2) {
BigDecimal b1 = new BigDecimal(String.valueOf(d1));
BigDecimal b2 = new BigDecimal(String.valueOf(d2));
return b1.add(b2).doubleValue();
return b1.add(b2).doubleValue();
}
public static boolean isPositiveInteger(String inValue) {
return isNumericValue(inValue, false, false);
}
}
public static boolean isNumericValue(String inValue) {
return isNumericValue(inValue, true, true);
}
}
public static boolean isNumericValue(String inValue, boolean includeSymbol, boolean includeDecimal) {
boolean result = false;
@ -578,7 +575,7 @@ public class Utility implements java.io.Serializable {
}
return result;
}
public static String getIDAsString(ArrayList<?> idList, int idFrom, int idTo) {
String IDs = null;
if (idList != null && idList.size() > 0) {
@ -587,7 +584,7 @@ public class Utility implements java.io.Serializable {
int lp;
IDs = idList.get(idFrom).toString();
if (idList.size() > 1 && idTo > idFrom) {
for (lp = idFrom+1; lp < idTo; lp ++) IDs += "," + idList.get(lp).toString();
for (lp = idFrom+1; lp < idTo; lp ++) IDs += "," + idList.get(lp).toString();
}
}
return IDs;
@ -601,15 +598,15 @@ public class Utility implements java.io.Serializable {
}
return result;
}
public static void setPreparedParameterList(PreparedStatement stmt, int startParamIndex, ArrayList<Integer> idList, int fromID, int toID) throws Exception {
int idx = startParamIndex;
for (int i = fromID; i <= toID; i++) {
stmt.setInt(idx, idList.get(i).intValue());
idx ++;
}
}
}
public static String replaceMailAddress(String mailAddress, String oldPattern, String newPattern) {
if (mailAddress == null || mailAddress.trim().equals("") || oldPattern == null || newPattern == null)
return mailAddress;
@ -617,19 +614,19 @@ public class Utility implements java.io.Serializable {
return mailAddress.trim().replaceAll(oldPattern, newPattern);
}
}
public static String getValidMailAddress(String mailAddress, String defaultAddress) {
if (mailAddress != null && !mailAddress.trim().equals(""))
return mailAddress;
else
return defaultAddress;
}
public static String getValidString(String str) {
if (str == null) return "";
else return str;
}
public static String[] getMailTo(String to) {
String[] toAC = null;
if (to != null && to.indexOf("@") != -1) {
@ -643,15 +640,15 @@ public class Utility implements java.io.Serializable {
}
return toAC;
}
public static int getASCII(String str) {
int result = 48;
if (str != null && !str.trim().equals("")) {
result = 48 + Integer.parseInt(str);
result = 48 + Integer.parseInt(str);
}
return result;
return result;
}
public static void getKeyAsVector(String s_key, Vector<String> v_key) {
int idx;
if (s_key != null && !s_key.trim().equals("")) {
@ -660,7 +657,7 @@ public class Utility implements java.io.Serializable {
idx = s_key.indexOf(".");
if (idx != -1) {
v_key.addElement(s_key.substring(0, idx));
s_key = s_key.substring(idx+1);
s_key = s_key.substring(idx+1);
} else {
v_key.addElement(s_key);
s_key = "";
@ -668,7 +665,7 @@ public class Utility implements java.io.Serializable {
}
}
}
public static String getNameFromAscII(String s_key, int startIndex, int length) {
Vector<String> v_key = new Vector<String>();
Utility.getKeyAsVector(s_key, v_key);
@ -676,7 +673,7 @@ public class Utility implements java.io.Serializable {
v_key = null;
return result;
}
public static String getNameFromAscII(Vector<String> v_key, int startIndex, int length) {
String result = "";
if (length > v_key.size() - startIndex) length = v_key.size() - startIndex;
@ -685,7 +682,7 @@ public class Utility implements java.io.Serializable {
}
return result;
}
public static String NameToASCII(String str) {
String result = null;
char[] ch = str.toCharArray();
@ -695,21 +692,21 @@ public class Utility implements java.io.Serializable {
}
return result;
}
public static void writeLog(String log) {
try {
System.out.println(getFormatedTimeStamp() + " : " + log);
System.out.println(getFormatedTimeStamp() + " : " + log);
} catch (Exception e) {
}
}
}
public static String intToHex(int i) {
String result = Integer.toHexString(i).trim();
if (result.length() == 0) result = "00";
if (result.length() == 1) result = "0" + result;
return result;
}
public static int HexToInt(String s) {
return Integer.parseInt(Integer.valueOf(s, 16).toString());
}
@ -728,8 +725,8 @@ public class Utility implements java.io.Serializable {
}
return list;
}
public static String getDateFormat(Calendar calendar){
String returnValue="";
Date now = new Date();
@ -738,7 +735,7 @@ public class Utility implements java.io.Serializable {
long hour=(leftTime/(60*60*1000)-day*24);
long min=((leftTime/(60*1000))-day*24*60-hour*60);
long s=(leftTime/1000-day*24*60*60-hour*60*60-min*60);
if(returnValue.equals("") && day>=365){
int year = (int) (day/365);
returnValue=year+"年前";
@ -757,14 +754,14 @@ public class Utility implements java.io.Serializable {
returnValue=s+"秒前";
if(returnValue.equals(""))
returnValue="0秒前";
return returnValue;
}
public static String getUUID(){
return java.util.UUID.randomUUID().toString();
}
/**
* 格式化日期 eg. 2014年07月10日 12:29 星期四
* @param date
@ -773,9 +770,9 @@ public class Utility implements java.io.Serializable {
public static String getDateCN(Date date){
SimpleDateFormat dateFm = new SimpleDateFormat("yyyy年MM月dd日 HH:mm EEEE");
return dateFm.format(date);
}
/**
* 获取文件的后缀名
* @param filename
@ -786,12 +783,12 @@ public class Utility implements java.io.Serializable {
if(filename!=null && filename.indexOf(".")!=-1)suffix=filename.substring(filename.lastIndexOf("."));
return suffix;
}
public static String getFileSuffix(File file){
String fileName=file.getName();
return getFileSuffix(fileName);
}
/**
* 获取访问者IP
* 在一般情况下使用Request.getRemoteAddr()即可但是经过nginx等反向代理软件后这个方法会失效
@ -810,20 +807,20 @@ public class Utility implements java.io.Serializable {
}
}
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("PRoxy-Client-IP");
ip = request.getHeader("PRoxy-Client-IP");
}
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
ip = request.getHeader("WL-Proxy-Client-IP");
}
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("X-Real-IP");
}
if(ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
ip = request.getRemoteAddr();
}
return ip;
}
public static String listToString(List<?> stringList){
if (stringList==null) {
return null;
@ -840,8 +837,8 @@ public class Utility implements java.io.Serializable {
}
return result.toString();
}
public static boolean strIsEqual(String str1, String str2){
if(StringUtils.isBlank(str1) || StringUtils.isBlank(str2))return false;
if(str1.equals(str2) || str1.trim().equals(str2.trim()))return true;
@ -862,7 +859,7 @@ public class Utility implements java.io.Serializable {
return false;
}
}
/**
* 判断是否是浮点数
* @param str
@ -876,8 +873,8 @@ public class Utility implements java.io.Serializable {
} catch (Exception e) {
return false;
}
}
}
/**
* 密码加密方法
* @param pwd
@ -887,7 +884,7 @@ public class Utility implements java.io.Serializable {
if(StringUtils.isEmpty(pwd))return null;
else return UnixCrypt.crypt(pwd, DigestUtils.sha256Hex(pwd));
}
/**
* 优惠码的生成, 默认6为长度
* @return
@ -895,7 +892,7 @@ public class Utility implements java.io.Serializable {
public static String getCode() {
return getCode(6);
}
/**
* 优惠码的生成
* @return
@ -912,7 +909,7 @@ public class Utility implements java.io.Serializable {
final String code = new String(value);
return code;
}
/**
* 通过正则验证手机号码是否正确
* @param str
@ -925,7 +922,7 @@ public class Utility implements java.io.Serializable {
b = m.matches();
return b;
}
/**
* 使用urlencode对链接进行编码
* @param url
@ -959,7 +956,7 @@ public class Utility implements java.io.Serializable {
public static boolean isEmpty(String str){
return (str == null || "".equals(str.trim()));
}
public static boolean isNotEmpty(String str){
return (str != null && str.trim().length() > 0);
}
@ -980,7 +977,7 @@ public class Utility implements java.io.Serializable {
}
return flag;
}
/**
* 判断输入流是否是图片
* @param inputStream
@ -999,7 +996,7 @@ public class Utility implements java.io.Serializable {
}
return flag;
}
/**
* 通过文件路径获取文件的ContentType
* JDK1.7以上支持
@ -1015,7 +1012,7 @@ public class Utility implements java.io.Serializable {
}
return contentType;
}
public static String getReqIpAddr(HttpServletRequest request) {
String ip = null;
try {
@ -1035,10 +1032,10 @@ public class Utility implements java.io.Serializable {
} catch (Exception e) {
e.printStackTrace();
}
return ip;
}
/**
* 获取http访问路径包括ContextPath
* @param request
@ -1053,15 +1050,15 @@ public class Utility implements java.io.Serializable {
String domainPath = request.getScheme()+"://"+request.getServerName()+strport+request.getContextPath();
return domainPath;
}
/**
* 生成微信支付需要的nonce_str参数
* @return
*/
public static String getNonceStr(){
return UUID.randomUUID().toString().replace("-", "");
return UUID.randomUUID().toString().replace("-", "");
}
/**
* 生成[min,max]区间的随机小数 (保留2位小数)
* @param min
@ -1071,7 +1068,7 @@ public class Utility implements java.io.Serializable {
public static double getRandom(double min, double max){
return getRandom(min, max, 2);
}
/**
* 生成[min,max]区间的随机小数
* @param min
@ -1085,18 +1082,18 @@ public class Utility implements java.io.Serializable {
result = round(result, scale); // 精度位数(保留的小数位数)
return result;
}
private static double round(double value, int scale) {
return round(value, scale, BigDecimal.ROUND_HALF_UP);
}
/**
* 对double数据进行取精度.
* @param value double数据.
* @param scale 精度位数(保留的小数位数).
* @param roundingMode 精度取值方式.
* @return 精度计算后的数据.
*/
/**
* 对double数据进行取精度.
* @param value double数据.
* @param scale 精度位数(保留的小数位数).
* @param roundingMode 精度取值方式.
* @return 精度计算后的数据.
*/
private static double round(double value, int scale, int roundingMode) {
BigDecimal bd = new BigDecimal(value);
bd = bd.setScale(scale, roundingMode);
@ -1104,7 +1101,7 @@ public class Utility implements java.io.Serializable {
bd = null;
return d;
}
/**
* double保留2位小数
* @param value
@ -1117,7 +1114,7 @@ public class Utility implements java.io.Serializable {
bd = null;
return d;
}
/**
* 向URL中添加参数(有则修改无则添加)
* @param url
@ -1139,7 +1136,7 @@ public class Utility implements java.io.Serializable {
}
return url;
}
/**
* 替换URL参数的值
* @param url
@ -1154,7 +1151,7 @@ public class Utility implements java.io.Serializable {
}
return url;
}
/**
* 删除URL中的参数
* @param url
@ -1168,7 +1165,7 @@ public class Utility implements java.io.Serializable {
url = url.replaceAll("(\\?" + ParamName +"=[^&]*)", "");
url = url.replaceAll("(%3f" + ParamName +"%3d[^&]*)", "");
url = url.replaceAll("(%3F" + ParamName +"%3D[^&]*)", "");
url = url.replaceAll("(\\&" + ParamName +"=[^&]*)", "");
url = url.replaceAll("(%26" + ParamName +"%3d[^&]*)", "");
url = url.replaceAll("(%26" + ParamName +"%3D[^&]*)", "");
@ -1217,6 +1214,25 @@ public class Utility implements java.io.Serializable {
}
public static void main(String[] args) {
Map<String, Object> map = new HashMap<>();
Map<String, Object> map2 = new HashMap<>();
map.put("402880817dfaaae1017dfaac17ee0010","主kv");
map.put("402880817dfaaae1017dfaac17ee0011","海报");
map.put("402880817dfaaae1017dfaac17ee0012","长图");
String s2 = "[{\"listValuesId\": 244,\"term\": \"1\"},{\"listValuesId\": 245,\"term\": \"3\"}]";
System.out.println(s2);
System.out.println(map);
String s = JSONObject.toJSONString(map);
System.out.println(s);
//List<String> list = Arrays.asList(s.split(","));
JSONArray jsonArray = JSONObject.parseArray(s2);
System.out.println(jsonArray);
for (int i = 0; i < jsonArray.size(); i++) {
ProjectTaskTerm projectTaskTerm = jsonArray.getObject(i, ProjectTaskTerm.class);
projectTaskTerm.setProjectId(UUIDUtil.uuid());
projectTaskTerm.setId(UUIDUtil.uuid());
System.out.println(projectTaskTerm);
}
System.out.println(getDouble2(2.31468d));
}
}
}

View File

@ -1,37 +1,17 @@
spring:
spring:
# 数据库配置
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://120.25.121.117:3306/xgl_oa?autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=GMT%2B8&characterEncoding=UTF-8
username: root
password: 'szxgl@2001B'
druid:
initial-size: 3
min-idle: 1
max-active: 500
max-wait: 60000 # 获取连接等待超时的时间
time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位是毫秒
test-while-idle: true # 申请连接的时候检测, 建议配置为true不影响性能
test-on-borrow: false # 申请连接时执行validationQuery检测连接是否有效
test-on-return: false # 归还连接时执行validationQuery检测连接是否有效
validation-query: SELECT 1
log-abandoned: true # 关闭abanded连接时输出错误日志
remove-abandoned: false # 是否开启连接泄漏监测,对性能会有一些影响,建议怀疑存在泄漏之后再打开
remove-abandoned-timeout: 1800 # 1800秒也就是30分钟
filters: stat, wall
web-stat-filter:
exclusions: '*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*'
stat-view-servlet:
enabled: true
url-pattern: /druid/*
login-username: admin
login-password: szxgl.com
# driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://39.108.110.167:13376/xgl_oa?autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=GMT%2B8&characterEncoding=UTF-8
# username: root
# password: 'szxgl@2001B'
#
# url2: jdbc:mysql://39.108.110.167:13376/xgl_cases?autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=GMT%2B8&characterEncoding=UTF-8
# username2: root
# password2: 'szxgl@2001B'
# Redis配置(springboot2.x版本中默认客户端是用lettuce实现的)
redis:
database: 0 # Redis数据库索引,默认为0
host: 120.25.121.117
host: 39.108.110.167
port: 8266
password: 'Qiween@4531871'
#timeout: 5000ms # 连接超时时间(毫秒)
@ -44,4 +24,78 @@ spring:
max-idle: 8 # 连接池中的最大空闲连接
min-idle: 1 # 连接池中的最小空闲连接
data:
elasticsearch:
repositories:
enabled: true # 开启 Elasticsearch仓库(默认值:true)
client:
reactive:
endpoints: 39.108.110.167:9200
connection-timeout: 5000
socket-timeout: 5000
datasource:
#使用druid连接池
type: com.alibaba.druid.pool.DruidDataSource
# 自定义的主数据源配置信息
primary:
datasource:
#druid相关配置
druid:
#监控统计拦截的filters
filters: stat
driverClassName: com.mysql.jdbc.Driver
#配置基本属性
url: jdbc:mysql://39.108.110.167:13376/xgl_oa?autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=GMT%2B8&characterEncoding=UTF-8
username: root
password: 'szxgl@2001B'
#配置初始化大小/最小/最大
initialSize: 1
minIdle: 1
maxActive: 10
#获取连接等待超时时间
maxWait: 60000
#间隔多久进行一次检测,检测需要关闭的空闲连接
timeBetweenEvictionRunsMillis: 60000
#一个连接在池中最小生存的时间
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 'x'
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
#打开PSCache并指定每个连接上PSCache的大小。oracle设为truemysql设为false。分库分表较多推荐设置为false
poolPreparedStatements: false
maxPoolPreparedStatementPerConnectionSize: 20
# 自定义的从数据源配置信息
back:
datasource:
#druid相关配置
druid:
#监控统计拦截的filters
filters: stat
driverClassName: com.mysql.jdbc.Driver
#配置基本属性
url: jdbc:mysql://39.108.110.167:13376/xgl_cases?autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=GMT%2B8&characterEncoding=UTF-8
username: root
password: 'szxgl@2001B'
#配置初始化大小/最小/最大
initialSize: 1
minIdle: 1
maxActive: 10
#获取连接等待超时时间
maxWait: 60000
#间隔多久进行一次检测,检测需要关闭的空闲连接
timeBetweenEvictionRunsMillis: 60000
#一个连接在池中最小生存的时间
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 'x'
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
#打开PSCache并指定每个连接上PSCache的大小。oracle设为truemysql设为false。分库分表较多推荐设置为false
poolPreparedStatements: false
maxPoolPreparedStatementPerConnectionSize: 20

View File

@ -1,7 +1,7 @@
# tomcat配置
server:
port: 8080
servlet:
servlet:
context-path: /worktile
jsp:
init-parameters:
@ -50,7 +50,7 @@ mybatis:
configuration:
# 进行自动映射时,数据以下划线命名,如数据库返回的"order_address"命名字段是否映射为class的"orderAddress"字段。默认为false
map-underscore-to-camel-case: true
mapper:
mappers: com.nbclass.util.MyMapper
not-empty: false

View File

@ -1,16 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.nbclass.szxgl.mapper.ListTypeMapper">
<!--<resultMap id="BaseResultMap" type="com.nbclass.szxgl.model.ListType">-->
<!--<id column="id" jdbcType="CHAR" property="id" />-->
<!--<result column="_list_type" jdbcType="VARCHAR" property="" />-->
<!--<result column="_list_value" jdbcType="VARCHAR" property="list_value" />-->
<!--</resultMap> -->
<resultMap id="BaseResultMap" type="com.nbclass.szxgl.model.ListType">
<id column="id" jdbcType="CHAR" property="id" />
<result column="list_type" jdbcType="VARCHAR" property="listType" />
<result column="list_value" jdbcType="VARCHAR" property="listValue" />
<collection property="listTypes" ofType="com.nbclass.szxgl.model.ListType" column="id" select="getComboBoxPid">
<id column="id" jdbcType="CHAR" property="id" />
<result column="list_type" jdbcType="VARCHAR" property="listType" />
<result column="list_value" jdbcType="VARCHAR" property="listValue" />
</collection>
</resultMap>
<select id="getList" resultType="com.nbclass.szxgl.model.ListType">
SELECT * FROM list_values lv WHERE list_type = #{listType}
</select>
<select id="getListValue" resultType="string">
SELECT list_value FROM list_values lv WHERE list_type = #{listType} and id= #{id}
</select>
@ -18,4 +23,17 @@
<select id="getAreaIdByName" resultType="string">
SELECT id FROM list_values WHERE list_value = #{areaName}
</select>
</mapper>
<select id="getComboBox" resultMap="BaseResultMap">
select * from list_values WHERE parent_id = 0 and parent_id !='' and parent_id is not null
</select>
<select id="getComboBoxPid" resultMap="BaseResultMap">
select * from list_values WHERE parent_id = #{id} and parent_id !='' and parent_id is not null
</select>
<select id="getFontType" resultType="com.nbclass.szxgl.model.ListType">
select id,list_value from list_values where list_value like CONCAT('%',#{name},'%') and list_type = 360
</select>
</mapper>

View File

@ -15,17 +15,55 @@
<result column="_create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="_update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<select id="getList" resultType="com.nbclass.szxgl.model.ProjectTaskJournal">
select j.*, sy_users.true_name as createUserName
from project_task_journal j
left join sy_users ON j._create_user_id = sy_users.id
where j._project_task_id = #{taskId}
order by j._create_time desc
select j.*, sy_users.true_name as createUserName
from project_task_journal j
left join sy_users ON j._create_user_id = sy_users.id
where j._project_task_id = #{taskId}
order by j._create_time desc
</select>
<delete id="deleteByTaskId" parameterType="java.lang.String">
delete from project_task_journal where _project_task_id = #{projectTaskId}
</delete>
</mapper>
<update id="updateTaskJournal">
update project_task_journal set
<if test="score!=null">
_score = #{score},
</if>
<if test="comment!=null and comment!=''">
_comment = #{comment},
</if>
<if test="commentId!=null and commentId!=''">
_comment_id = #{commentId},
</if>
<if test="status!=null">
_status = #{status}
</if>
where id = #{id}
</update>
<select id="getUserName" resultType="java.lang.String">
select su.true_name from project_task_journal j LEFT JOIN sy_users su ON j._comment_id = su.id where j.id = #{id}
</select>
<insert id="addTaskFontType" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
insert into project_task_journal_font_type
(
id,
list_values_id,
project_task_journal_id,
created_time
)
values
(
#{id},
#{listValuesId},
#{projectTaskJournalId},
now()
)
</insert>
</mapper>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.nbclass.szxgl.mapper.ProjectTaskTermMapper">
<insert id="addProjectTaskTerm">
insert into project_task_term
(
id,
project_id,
list_values_id,
term
)
values
(
#{id},
#{projectId},
#{listValuesId},
#{term}
)
</insert>
</mapper>

View File

@ -22,21 +22,21 @@
<result column="Telephone" jdbcType="VARCHAR" property="telephone" />
<result column="ExtAttr" jdbcType="VARCHAR" property="extattr" />
</resultMap>
<select id="findByUserId" parameterType="java.lang.String" resultType="map">
SELECT Department, IsLeader, Avatar FROM qywx_user WHERE UserID = #{userId}
</select>
<select id="findAllByDepartment" parameterType="java.lang.String" resultType="map">
SELECT UserID, NAME, Avatar FROM qywx_user WHERE IsLeader = 1 AND Department IN (SELECT ParentId FROM qywx_party WHERE Id IN ( #{depId} ))
</select>
<select id="findByDepartment" parameterType="java.lang.String" resultType="map">
<!--SELECT UserID, NAME, Avatar FROM qywx_user WHERE IsLeader = 1 AND Department IN (#{depId})-->
<!--用户有多个部门的情况存储形式逗号分隔FIND_IN_SET精准匹配某一个-->
SELECT UserID, NAME, Avatar FROM qywx_user WHERE IsLeader = 1 AND FIND_IN_SET(#{depId}, Department)
</select>
<select id="findSuperiorLeadersByDepartment" parameterType="java.lang.String" resultType="map">
SELECT UserID, NAME, Avatar FROM qywx_user WHERE IsLeader = 1 AND Department IN (SELECT ParentId FROM qywx_party WHERE Id IN (#{depId}) )
</select>
@ -51,4 +51,3 @@
</mapper>

View File

@ -22,14 +22,18 @@
<result column="mobile_phone_number" jdbcType="CHAR" property="mobilePhoneNumber" />
<result column="isleader" jdbcType="BIT" property="isleader" />
</resultMap>
<select id="findByUserName" parameterType="java.lang.String" resultType="com.nbclass.szxgl.model.SyUsers">
SELECT * from sy_users where user_name =#{userName}
</select>
<select id="findIdByDeptId" parameterType="java.lang.String" resultType="string">
select id from SyUsers where deptId=#{deptId}
</select>
</mapper>
<select id="getByIsLeader" resultType="java.lang.String">
select user_name from sy_users where deptId=#{deptId} and isleader = 1
</select>
</mapper>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.nbclass.szxgl.mapper2.TestMapper">
<select id="getContent" resultType="com.nbclass.szxgl.model.Content">
select * from content
</select>
</mapper>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.nbclass.szxgl.mapper2.DataDictItemMapper">
<select id="getTagNames" resultType="java.util.Map">
select id,value from data_dict_item where dictid = 25 and value like concat('%',#{tagNames},'%')
</select>
</mapper>

View File

@ -119,4 +119,4 @@
})
</script>
</body>
</html>
</html>

0
tmlog0.log Normal file
View File