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

View File

@ -209,6 +209,13 @@
<artifactId>lombok</artifactId>
</dependency>
<!-- 整合 Elasticsearch -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<!-- 测试用, 配置devtools实现热部署 -->
<!--
会导致ClassCastException异常

View File

@ -48,6 +48,8 @@ public class ShiroService {
filterChainDefinitionMap.put("/favicon.ico", "anon");
filterChainDefinitionMap.put("/verificationCode", "anon");
filterChainDefinitionMap.put("/test/**", "anon");
filterChainDefinitionMap.put("/api/**" ,"anon"); // 前端接口
filterChainDefinitionMap.put("/", "anon"); // 网站首页
// 静态资源按后缀排除

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

@ -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

@ -39,70 +39,70 @@ public class WxWorkFilter implements Filter {
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);
}

View File

@ -15,4 +15,8 @@ public interface ListTypeMapper extends MyMapper<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,7 +3,9 @@ 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> {
@ -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

@ -11,4 +11,11 @@ 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,6 +3,7 @@ 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 {
@ -16,6 +17,8 @@ public class ListType {
@Column(name = "list_type")
private String listType;
private List<ListType> listTypes;
/**
* 名称
*/
@ -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;
/**
* 创建时间
*/
@ -236,5 +266,43 @@ public class ProjectTaskJournal {
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

@ -153,4 +153,10 @@ public interface ProjectService {
*/
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,6 +3,7 @@ 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 {
@ -14,5 +15,11 @@ public interface SyUsersService {
*/
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;
@ -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;
@ -774,4 +776,5 @@ public class BCrypt {
ret |= hashed_bytes[i] ^ try_bytes[i];
return ret == 0;
}
}

View File

@ -1,12 +1,18 @@
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
@ -53,11 +59,20 @@ public class PasswordHelper {
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;
/**
* 工具类
@ -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:
# 数据库配置
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,11 +1,16 @@
<?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}
@ -18,4 +23,17 @@
<select id="getAreaIdByName" resultType="string">
SELECT id FROM list_values WHERE list_value = #{areaName}
</select>
<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

@ -28,4 +28,42 @@
delete from project_task_journal where _project_task_id = #{projectTaskId}
</delete>
<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

@ -51,4 +51,3 @@
</mapper>

View File

@ -32,4 +32,8 @@
select id from SyUsers where deptId=#{deptId}
</select>
<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>

0
tmlog0.log Normal file
View File