提交 edbfac00 authored 作者: 133's avatar 133

[用户] [清退] [专管员统计] 代码提交

上级 a592ac80
...@@ -89,5 +89,8 @@ ...@@ -89,5 +89,8 @@
<artifactId>knife4j-spring-boot-starter</artifactId> <artifactId>knife4j-spring-boot-starter</artifactId>
<version>2.0.5</version> <version>2.0.5</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
...@@ -100,6 +100,7 @@ public class FileController { ...@@ -100,6 +100,7 @@ public class FileController {
public ResponseEntity fileUpload(HttpServletRequest request) throws IOException, DocumentException { public ResponseEntity fileUpload(HttpServletRequest request) throws IOException, DocumentException {
log.info("触发图片转pdf的接口"); log.info("触发图片转pdf的接口");
List<MultipartFile> multipartFiles = ((MultipartHttpServletRequest) request).getFiles("file"); List<MultipartFile> multipartFiles = ((MultipartHttpServletRequest) request).getFiles("file");
log.info("数量{}",multipartFiles.size());
File file1 = new File(url + "print/"); File file1 = new File(url + "print/");
if (!file1.exists()) { if (!file1.exists()) {
file1.mkdirs(); file1.mkdirs();
......
...@@ -131,9 +131,15 @@ public class UseReportFIleServiceImpl implements UseReportFIleService { ...@@ -131,9 +131,15 @@ public class UseReportFIleServiceImpl implements UseReportFIleService {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
try { try {
bs.close(); if (bs != null) {
is.close(); bs.close();
os.close(); }
if (is != null) {
is.close();
}
if (os != null) {
os.close();
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -174,9 +180,15 @@ public class UseReportFIleServiceImpl implements UseReportFIleService { ...@@ -174,9 +180,15 @@ public class UseReportFIleServiceImpl implements UseReportFIleService {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
try { try {
bs.close(); if (bs!=null) {
is.close(); bs.close();
os.close(); }
if (is != null) {
is.close();
}
if (os != null) {
os.close();
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -36,6 +36,18 @@ ...@@ -36,6 +36,18 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId> <artifactId>spring-boot-starter-security</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.4</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.1</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
...@@ -38,7 +38,7 @@ public class GlobalExceptionHandler { ...@@ -38,7 +38,7 @@ public class GlobalExceptionHandler {
@ResponseBody @ResponseBody
@ExceptionHandler(Exception.class) @ExceptionHandler(Exception.class)
public ResponseEntity errorMessage(Exception e) { public ResponseEntity errorMessage(Exception e) {
log.error("[其他异常] {}", e.toString()); log.error("[其他异常] {}", e);
e.printStackTrace(); e.printStackTrace();
return ResultUtil.failed(e.getMessage()); return ResultUtil.failed(e.getMessage());
} }
...@@ -69,7 +69,7 @@ public class GlobalExceptionHandler { ...@@ -69,7 +69,7 @@ public class GlobalExceptionHandler {
@ResponseBody @ResponseBody
@ExceptionHandler(ApiException.class) @ExceptionHandler(ApiException.class)
public ResponseEntity errorMessage(ApiException e) { public ResponseEntity errorMessage(ApiException e) {
log.warn("[自定义异常] {}", e.toString()); log.warn("[自定义异常] {}", e);
if (e.getResponseEntity() != null) { if (e.getResponseEntity() != null) {
return e.getResponseEntity(); return e.getResponseEntity();
} }
......
package com.tykj.dev.misc.utils.httpclientutil;
import org.apache.http.*;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.UnsupportedCharsetException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
/**
* @author LJJ
* on 18-12-27
*/
public class HttpClientUtil {
/**
* 缺省超时时间 单位:ms
*/
private static final int TIMEOUT = 60000;
/**
* 是否重定向标识
*/
private static final boolean IS_REDIRECTS = false;
private static String EMPTY_STR = "";
/**
* 字符集编码格式
*/
private static String UTF_8 = "UTF-8";
private HttpClientUtil() {
}
/**
* 发送 get 请求
*
* @param url 请求地址
* @return String
*/
public static String httpGetRequest(String url) {
HttpGet httpGet = new HttpGet(url);
return execute(httpGet);
}
/**
* 发送 get 请求
*
* @param url 请求地址
* @param headers 头信息
* @return String
*/
public static String httpGetRequestWithHeaders(String url, Map<String, Object> headers) {
HttpGet httpGet = new HttpGet(url);
for (Map.Entry<String, Object> param : headers.entrySet()) {
httpGet.addHeader(param.getKey(), String.valueOf(param.getValue()));
}
return execute(httpGet);
}
/**
* 发送 get 请求
*
* @param url 请求地址
* @param headers 头信息
* @param params 参数
* @return String
*/
public static String httpGetRequest(String url, Map<String, Object> headers,
Map<String, Object> params) {
HttpGet httpGet = new HttpGet(createParamUrl(url, params));
for (Map.Entry<String, Object> param : headers.entrySet()) {
httpGet.addHeader(param.getKey(), String.valueOf(param.getValue()));
}
return execute(httpGet);
}
/**
* 发送 get 请求
*
* @param url 请求地址
* @return String
*/
public static String httpGetRequestWithParams(String url, Map<String, Object> params) {
HttpGet httpGet = new HttpGet(createParamUrl(url, params));
return execute(httpGet);
}
/**
* 创建带参数的 URL
*
* @param url 无参URL
* @param params 参数
* @return String 带参数URL
*/
private static String createParamUrl(String url, Map<String, Object> params) {
Iterator<String> it = params.keySet().iterator();
StringBuilder sb = new StringBuilder();
boolean isIncludeQuestionMark = url.contains("?");
if (!isIncludeQuestionMark) {
sb.append("?");
}
while (it.hasNext()) {
String key = it.next();
String value = (String) params.get(key);
sb.append("&");
sb.append(key);
sb.append("=");
sb.append(value);
}
url += sb.toString();
return url;
}
/**
* 发送 post 请求
*
* @param url 请求地址
* @return String
*/
public static String httpPostRequest(String url) {
HttpPost httpPost = new HttpPost(url);
return execute(httpPost);
}
/**
* 发送 post 请求
*
* @param url 地址
* @param params 参数
* @return String
*/
public static String httpPostRequest(String url, Map<String, Object> params) {
HttpPost httpPost = new HttpPost(url);
ArrayList<NameValuePair> pairs = covertParams2NVPS(params);
try {
httpPost.setEntity(new UrlEncodedFormEntity(pairs, UTF_8));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return execute(httpPost);
}
/**
* 发送 post 请求
*
* @param url 地址
* @param headers 头信息
* @param params 参数
* @return String
*/
public static String httpPostRequest(String url, Map<String, Object> headers,
Map<String, Object> params) {
HttpPost httpPost = new HttpPost(url);
for (Map.Entry<String, Object> headerParam : headers.entrySet()) {
httpPost.addHeader(headerParam.getKey(), String.valueOf(headerParam.getValue()));
}
ArrayList<NameValuePair> pairs = covertParams2NVPS(params);
try {
httpPost.setEntity(new UrlEncodedFormEntity(pairs, UTF_8));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return execute(httpPost);
}
/**
* 发送 post 请求
*
* @param url 地址
* @param headers 头信息
* @param json json 格式参数
* @return String
*/
public static String httpPostRequestByJson(String url, Map<String, Object> headers,
String json) {
HttpPost httpPost = new HttpPost(url);
for (Map.Entry<String, Object> headerParam : headers.entrySet()) {
httpPost.addHeader(headerParam.getKey(), String.valueOf(headerParam.getValue()));
}
try {
httpPost.setEntity(new StringEntity(json, UTF_8));
} catch (UnsupportedCharsetException e) {
e.printStackTrace();
}
return execute(httpPost);
}
/**
* 把参数转换为名值对数组
*
* @param params 参数
* @return ArrayList<NameValuePair>
*/
private static ArrayList<NameValuePair> covertParams2NVPS(Map<String, Object> params) {
ArrayList<NameValuePair> pairs = new ArrayList<NameValuePair>();
for (Map.Entry<String, Object> param : params.entrySet()) {
pairs.add(new BasicNameValuePair(param.getKey(), String.valueOf(param.getValue())));
}
return pairs;
}
/**
* 执行 HTTP 请求 若重定向返回重定向地址
*
* @return String
*/
private static String execute(HttpRequestBase request) {
String result = EMPTY_STR;
request.setConfig(createConfig(TIMEOUT, IS_REDIRECTS));
CloseableHttpClient httpClient = getHttpClient();
try {
CloseableHttpResponse response = httpClient.execute(request);
if (isRedirected(response)) {
result = getRedirectedUrl(response);
} else {
result = getEntityData(response);
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
/**
* 创建HTTP请求配置
*
* @param timeout 超时时间
* @param redirectsEnabled 是否开启重定向
* @return RequestConfig
*/
private static RequestConfig createConfig(int timeout, boolean redirectsEnabled) {
return RequestConfig.custom()
// 读取数据超时时间(毫秒)
.setSocketTimeout(timeout)
// 建立连接超时时间(毫秒)
.setConnectTimeout(timeout)
// 从连接池获取连接的等待时间(毫秒)
.setConnectionRequestTimeout(timeout)
// 当响应状态码为302时,是否进行重定向
.setRedirectsEnabled(redirectsEnabled)
.build();
}
/**
* 通过连接池获取 httpclient
*/
private static CloseableHttpClient getHttpClient() {
return HttpClients.custom().setConnectionManager(
HttpConnectionManager.POOLING_CONNECTION_MANAGER).build();
}
/**
* 判断发送请求是否重定向跳转过
*
* @param response 请求响应
* @return boolean
*/
private static boolean isRedirected(CloseableHttpResponse response) {
int statusCode = response.getStatusLine().getStatusCode();
return statusCode == HttpStatus.SC_MOVED_PERMANENTLY
|| statusCode == HttpStatus.SC_MOVED_TEMPORARILY;
}
/**
* 获得重定向跳转地址
*
* @param response 请求响应
* @return String 重定向地址
*/
private static String getRedirectedUrl(CloseableHttpResponse response) {
String result = EMPTY_STR;
Header[] hs = response.getHeaders("Location");
if (hs.length > 0) {
result = hs[0].getValue();
}
return result;
}
/**
* 获得响应实体信息
*
* @param response 请求响应
* @return String 消息实体信息
*/
private static String getEntityData(CloseableHttpResponse response)
throws ParseException, IOException {
String result = EMPTY_STR;
HttpEntity entity = response.getEntity();
if (entity != null) {
result = EntityUtils.toString(entity);
response.close();
}
return result;
}
}
package com.tykj.dev.misc.utils.httpclientutil;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
/**
* @author LJJ
* on 18-12-27
*/
public class HttpConnectionManager {
/**
* 普通连接管理器
*/
public static final HttpClientConnectionManager BASIC_CONNECTION_MANAGER;
/**
* 连接池管理器
*/
public static final HttpClientConnectionManager POOLING_CONNECTION_MANAGER;
static {
Registry<ConnectionSocketFactory> r = RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", PlainConnectionSocketFactory.getSocketFactory())
.register("https", SslSelfSigned.SSL_CONNECTION_SOCKET_FACTORY).build();
// 普通连接管理器
BASIC_CONNECTION_MANAGER = new BasicHttpClientConnectionManager(r);
// 连接池管理器
PoolingHttpClientConnectionManager pooling = new PoolingHttpClientConnectionManager(r);
// 设置最大连接数
pooling.setMaxTotal(1000);
// 设置每个路由基础上的最大连接数
pooling.setDefaultMaxPerRoute(300);
POOLING_CONNECTION_MANAGER = pooling;
}
private HttpConnectionManager() {
}
/**
* @param max httpClient 最大连接数
*/
public static void setMaxTotal(int max) {
((PoolingHttpClientConnectionManager) POOLING_CONNECTION_MANAGER).setMaxTotal(max);
}
/**
* @param max 每个路由基础上的最大连接数
*/
public static void setDefaultMaxPerRoute(int max) {
((PoolingHttpClientConnectionManager) POOLING_CONNECTION_MANAGER).setDefaultMaxPerRoute(max);
}
}
package com.tykj.dev.misc.utils.httpclientutil;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.ssl.SSLContexts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.net.ssl.SSLContext;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
/**
* @author LJJ
* on 18-12-27
*/
public class SslSelfSigned {
public static final SSLConnectionSocketFactory SSL_CONNECTION_SOCKET_FACTORY;
protected static final Logger logger = LoggerFactory.getLogger(SslSelfSigned.class);
static {
SSLContext sslContext = null;
try {
sslContext = SSLContexts.custom().loadTrustMaterial(TrustSelfSignedStrategy.INSTANCE).build();
} catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) {
logger.error("{}", e);
}
SSL_CONNECTION_SOCKET_FACTORY = new SSLConnectionSocketFactory(sslContext,
NoopHostnameVerifier.INSTANCE);
}
private SslSelfSigned() {
}
}
...@@ -157,5 +157,16 @@ public class SendBackController { ...@@ -157,5 +157,16 @@ public class SendBackController {
return sendBackService.exceptionSelect(taskId); return sendBackService.exceptionSelect(taskId);
} }
@ApiOperation(value = "跟踪业务查询详情接口")
@GetMapping("/select/tracking/{taskId}")
public ResponseEntity trackingSelect(@PathVariable("taskId") Integer taskId) {
return sendBackService.trackingSelect(taskId);
}
@ApiOperation(value = "清退账单查询接口")
@GetMapping("/select/repelBack/{taskId}")
public ResponseEntity repelBack(@PathVariable("taskId") Integer taskId) {
return sendBackService.repelBack(taskId);
}
} }
...@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; ...@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.checkerframework.checker.units.qual.A;
import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where; import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedBy; import org.springframework.data.annotation.CreatedBy;
......
package com.tykj.dev.device.sendback.entity.vo;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.checkerframework.checker.units.qual.A;
import java.util.List;
/**
* @author zjm
* @version 1.0.0
* @ClassName BusinessSendBackVo.java
* @Description TODO
* @createTime 2020年11月11日 12:20:00
*/
@Data
@ApiModel("跟踪详")
public class BusinessSendBackVo {
@ApiModelProperty(value = "异常装备描述")
private UnDeviceDesVo unDeviceDes;
@ApiModelProperty(value = "异常装备")
private List<DeviceLibrary> unDevice;
}
package com.tykj.dev.device.sendback.entity.vo;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author zjm
* @version 1.0.0
* @ClassName TrackingVo.java
* @Description TODO
* @createTime 2020年11月09日 10:03:00
*/
@Data
@ApiModel("跟踪详细页面")
public class TrackingVo {
/**
* 审核状态 1.审核通过 2.不通过 3.待审核
*/
@ApiModelProperty(value = "审核状态")
private Integer status;
/**
* 相关装备集合
*/
@ApiModelProperty(value = "相关装备集合")
private List<DeviceLibrary> deviceLibraries;
@ApiModelProperty(value = "异常装备描述")
private UnDeviceDesVo unDeviceDes;
@ApiModelProperty(value = "异常装备")
private List<DeviceLibrary> unDevice;
}
...@@ -83,7 +83,6 @@ public interface SendBackService { ...@@ -83,7 +83,6 @@ public interface SendBackService {
*/ */
ResponseEntity sendBackOutExamine(Integer taskId, Integer startUserId, Integer type); ResponseEntity sendBackOutExamine(Integer taskId, Integer startUserId, Integer type);
/** /**
* 入库-专管员B * 入库-专管员B
* 1、通过,完结task * 1、通过,完结task
...@@ -139,4 +138,14 @@ public interface SendBackService { ...@@ -139,4 +138,14 @@ public interface SendBackService {
*/ */
ResponseEntity exceptionSelect(Integer task); ResponseEntity exceptionSelect(Integer task);
/**
* 跟踪业务 查询页面
*/
ResponseEntity trackingSelect(Integer taskId);
/**
* 清退单查询
*/
ResponseEntity repelBack(Integer taskId);
} }
...@@ -99,7 +99,7 @@ public class TrainJobController { ...@@ -99,7 +99,7 @@ public class TrainJobController {
//2. 报名中 //2. 报名中
// JobEntity jobEntity=new JobEntity(taskEntity.getId(),0,trainTheme.getTrainStatus(),securityUser.getCurrentUserInfo().getUserId(),"x"+securityUser.getCurrentUserInfo().getUserId()+"x",0); // JobEntity jobEntity=new JobEntity(taskEntity.getId(),0,trainTheme.getTrainStatus(),securityUser.getCurrentUserInfo().getUserId(),"x"+securityUser.getCurrentUserInfo().getUserId()+"x",0);
// jobService.addEntity(jobEntity); // jobService.addEntity(jobEntity);
trainTheme.setTrainStatus(StatusEnum.TRAIN1000.id);
needTrain.forEach( needTrain.forEach(
id -> { id -> {
//4 报名确认 //4 报名确认
...@@ -128,7 +128,7 @@ public class TrainJobController { ...@@ -128,7 +128,7 @@ public class TrainJobController {
// TaskLogBto taskLogBto = new TaskLogBto(task.getId(),"发起培训",null); // TaskLogBto taskLogBto = new TaskLogBto(task.getId(),"发起培训",null);
// taskLogService.addLog(taskLogBto); // taskLogService.addLog(taskLogBto);
myWebSocket.sendMessage1(); myWebSocket.sendMessage1();
return ResponseEntity.ok(trainTheme); return ResponseEntity.ok(trainThemeService.save(trainTheme));
} }
//报名 //报名
...@@ -459,7 +459,7 @@ public class TrainJobController { ...@@ -459,7 +459,7 @@ public class TrainJobController {
//7 市培训申请发证审核 //7 市培训申请发证审核
trainTheme.setIsCertificate(gradeEntryVo.getIsCertificate()); trainTheme.setIsCertificate(gradeEntryVo.getIsCertificate());
trainTheme.setTrainingResults(JacksonUtil.toJSon(gradeEntryVo.getGradeEntryList())); trainTheme.setTrainingResults(JacksonUtil.toJSon(gradeEntryVo.getGradeEntryList()));
trainTheme.setTrainStatus(33); trainTheme.setTrainStatus(StatusEnum.TRAIN1006.id);
trainTheme.setGood(gradeEntryVo.getGood()); trainTheme.setGood(gradeEntryVo.getGood());
trainTheme.setPass(gradeEntryVo.getPass()); trainTheme.setPass(gradeEntryVo.getPass());
TaskLogBto taskLogBto = new TaskLogBto(taskBto.getId(), "发证审核", null); TaskLogBto taskLogBto = new TaskLogBto(taskBto.getId(), "发证审核", null);
...@@ -476,7 +476,6 @@ public class TrainJobController { ...@@ -476,7 +476,6 @@ public class TrainJobController {
TaskBto taskBto = trainTaskService.selectFatherIsNullAndBillidAndBillType(trainTheme.getTrainId(), BusinessEnum.TRAIN.id); TaskBto taskBto = trainTaskService.selectFatherIsNullAndBillidAndBillType(trainTheme.getTrainId(), BusinessEnum.TRAIN.id);
taskService.moveToSpecial(taskBto, StatusEnum.TRAIN1007, gradeEntryVo.getAuditId()); taskService.moveToSpecial(taskBto, StatusEnum.TRAIN1007, gradeEntryVo.getAuditId());
//
// TaskEntity taskEntity= taskService.findByParentAndBillIdAndBussType(0,trainTheme.getTrainId(),BusinessEnum.TRAIN.id); // TaskEntity taskEntity= taskService.findByParentAndBillIdAndBussType(0,trainTheme.getTrainId(),BusinessEnum.TRAIN.id);
// taskEntity.setBillStatus(34); // taskEntity.setBillStatus(34);
// taskService.update(taskEntity); // taskService.update(taskEntity);
...@@ -722,4 +721,10 @@ public class TrainJobController { ...@@ -722,4 +721,10 @@ public class TrainJobController {
return ResponseEntity.ok(trainThemeService.updateTrain(trainUpdateVo)); return ResponseEntity.ok(trainThemeService.updateTrain(trainUpdateVo));
} }
@ApiOperation(value = "培训详情接口查询")
@GetMapping("/details/{trainId}")
public ResponseEntity details(@ApiIgnore @AuthenticationPrincipal SecurityUser securityUser, @PathVariable Integer trainId) {
return ResponseEntity.ok(trainThemeService.findSelectDetailsVo(trainId));
}
} }
...@@ -46,7 +46,7 @@ public class TrainTheme { ...@@ -46,7 +46,7 @@ public class TrainTheme {
/** /**
* 报名截止时间 * 报名截止时间
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ApiModelProperty(value = "报名截止时间") @ApiModelProperty(value = "报名截止时间")
private Date trainTime; private Date trainTime;
...@@ -83,7 +83,7 @@ public class TrainTheme { ...@@ -83,7 +83,7 @@ public class TrainTheme {
* 培训结束时间 * 培训结束时间
*/ */
@ApiModelProperty(value = "培训结束时间") @ApiModelProperty(value = "培训结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date endTime; private Date endTime;
/** /**
...@@ -202,5 +202,10 @@ public class TrainTheme { ...@@ -202,5 +202,10 @@ public class TrainTheme {
return mapper.map(this, TrainAuditVo.class); return mapper.map(this, TrainAuditVo.class);
} }
public TrainDetailsVo toTrainDetailsVo() {
ModelMapper mapper = BeanHelper.getUserMapper();
return mapper.map(this, TrainDetailsVo.class);
}
} }
...@@ -73,13 +73,13 @@ public class ByTrainingPeople { ...@@ -73,13 +73,13 @@ public class ByTrainingPeople {
* 培训开始时间 * 培训开始时间
*/ */
@ApiModelProperty(value = "培训开始时间") @ApiModelProperty(value = "培训开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date startTime; private Date startTime;
/** /**
* 培训结束时间 * 培训结束时间
*/ */
@ApiModelProperty(value = "培训结束时间") @ApiModelProperty(value = "培训结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date endTime; private Date endTime;
/** /**
......
...@@ -30,11 +30,11 @@ public class ConditionsTrainVo { ...@@ -30,11 +30,11 @@ public class ConditionsTrainVo {
@ApiModelProperty(value = "开始时间", example = "bmxx", name = "statusTime") @ApiModelProperty(value = "开始时间", example = "bmxx", name = "statusTime")
private String dimName; private String dimName;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ApiModelProperty(value = "开始时间", example = "bmxx", name = "statusTime") @ApiModelProperty(value = "开始时间", example = "bmxx", name = "statusTime")
private Date statusTime; private Date statusTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ApiModelProperty(value = "结束时间", example = "bmxx", name = "endTime") @ApiModelProperty(value = "结束时间", example = "bmxx", name = "endTime")
private Date endTime; private Date endTime;
......
...@@ -7,6 +7,7 @@ import lombok.AllArgsConstructor; ...@@ -7,6 +7,7 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import javax.persistence.Transient;
import java.util.Date; import java.util.Date;
/** /**
...@@ -31,7 +32,6 @@ public class GradeEntry { ...@@ -31,7 +32,6 @@ public class GradeEntry {
* 用户名称 * 用户名称
*/ */
@ApiModelProperty(value = "用户名称", name = "name") @ApiModelProperty(value = "用户名称", name = "name")
private String name; private String name;
/** /**
...@@ -50,30 +50,33 @@ public class GradeEntry { ...@@ -50,30 +50,33 @@ public class GradeEntry {
* 考勤 * 考勤
*/ */
@ApiModelProperty(value = "考勤", name = "attendance") @ApiModelProperty(value = "考勤", name = "attendance")
private String attendance; private String attendance;
/** /**
* 分数 * 分数
*/ */
@ApiModelProperty(value = "分数", name = "score") @ApiModelProperty(value = "分数", name = "score")
private String score; private String score;
/** /**
* 评价 * 评价
*/ */
@ApiModelProperty(value = "评价", name = "evaluation") @ApiModelProperty(value = "评价", name = "evaluation")
private String evaluation; private String evaluation;
/** /**
* 是否发证 * 是否发证
*/ */
@ApiModelProperty(value = "是否发证", name = "certificate") @ApiModelProperty(value = "是否发证", name = "certificate")
private Integer certificate; private Integer certificate;
/**
* 证书
*/
@Transient
private Mgrcert mgrcert;
public Mgrcert toDo() { public Mgrcert toDo() {
// LocalDateTime now = LocalDateTime.now().plusYears(2).atZone(ZoneOffset.ofHours(8)).toLocalDateTime(); // LocalDateTime now = LocalDateTime.now().plusYears(2).atZone(ZoneOffset.ofHours(8)).toLocalDateTime();
// DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(formatStr); // DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(formatStr);
......
...@@ -63,13 +63,13 @@ public class InTrainVo { ...@@ -63,13 +63,13 @@ public class InTrainVo {
* 培训开始时间 * 培训开始时间
*/ */
@ApiModelProperty(value = "培训开始时间") @ApiModelProperty(value = "培训开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date startTime; private Date startTime;
/** /**
* 培训结束时间 * 培训结束时间
*/ */
@ApiModelProperty(value = "培训结束时间") @ApiModelProperty(value = "培训结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date endTime; private Date endTime;
/** /**
......
...@@ -43,7 +43,7 @@ public class TrainAuditVo { ...@@ -43,7 +43,7 @@ public class TrainAuditVo {
* 报名截止时间 * 报名截止时间
*/ */
@ApiModelProperty(value = "报名截止时间") @ApiModelProperty(value = "报名截止时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date trainTime; private Date trainTime;
/** /**
...@@ -74,13 +74,13 @@ public class TrainAuditVo { ...@@ -74,13 +74,13 @@ public class TrainAuditVo {
* 培训开始时间 * 培训开始时间
*/ */
@ApiModelProperty(value = "培训开始时间") @ApiModelProperty(value = "培训开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date startTime; private Date startTime;
/** /**
* 培训结束时间 * 培训结束时间
*/ */
@ApiModelProperty(value = "培训结束时间") @ApiModelProperty(value = "培训结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date endTime; private Date endTime;
/** /**
......
package com.tykj.dev.device.train.entity.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.util.Date;
import java.util.List;
/**
* @author zjm
* @version 1.0.0
* @ClassName InTrainVo.java
* @Description 报名中
* @createTime 2020年08月17日 23:45:00
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "培训中返回的对象", description = "培训中返回的对象")
public class TrainDetailsVo {
/**
* 培训id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty(value = "培训id")
private Integer trainId;
/**
* 培训主题
*/
@ApiModelProperty(value = "培训主题")
private String name;
/**
* 报名截止时间
*/
@ApiModelProperty(value = "报名截止时间")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date trainTime;
/**
* 发起人 originator
*/
@ApiModelProperty(value = "发起人")
private String originatorName;
/**
* 发起人 originator
*/
@ApiModelProperty(value = "发起人id")
private Integer originatorId;
/**
* 主办单位
*/
@ApiModelProperty(value = "主办单位名称")
private String unitsName;
/**
* 主办单位
*/
@ApiModelProperty(value = "主办单位")
private Integer unitsId;
/**
* 培训开始时间
*/
@ApiModelProperty(value = "培训开始时间")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date startTime;
/**
* 培训结束时间
*/
@ApiModelProperty(value = "培训结束时间")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date endTime;
/**
* 培训地点
*/
@ApiModelProperty(value = "培训地点")
private String trainLocation;
/**
* 主讲人
*/
@ApiModelProperty(value = "主讲人")
private String speakerUserId;
/**
* 培训资料名称
*/
@ApiModelProperty(value = "培训资料")
private String trainDataName;
/**
* 培训url
*/
@ApiModelProperty(value = "培训资料")
private String trainDataUrl;
/**
* 培训简介
*/
@ApiModelProperty(value = "trainSynopsis")
private String trainSynopsis;
/**
* 及格
*/
@ApiModelProperty(value = "发证状态")
private Integer pass;
/**
* 优秀
*/
@ApiModelProperty(value = "发证状态")
private Integer good;
/**
* 成绩
*/
@ApiModelProperty(value = "gradeEntry")
private List<GradeEntry> gradeEntry;
}
...@@ -74,13 +74,13 @@ public class TrainRegistrationVo { ...@@ -74,13 +74,13 @@ public class TrainRegistrationVo {
* 培训开始时间 * 培训开始时间
*/ */
@ApiModelProperty(value = "培训开始时间") @ApiModelProperty(value = "培训开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date startTime; private Date startTime;
/** /**
* 培训结束时间 * 培训结束时间
*/ */
@ApiModelProperty(value = "培训结束时间") @ApiModelProperty(value = "培训结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date endTime; private Date endTime;
/** /**
......
...@@ -9,6 +9,7 @@ import lombok.Data; ...@@ -9,6 +9,7 @@ import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.modelmapper.ModelMapper; import org.modelmapper.ModelMapper;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -105,13 +106,13 @@ public class TrainThemeAddVo { ...@@ -105,13 +106,13 @@ public class TrainThemeAddVo {
* 必须参加 * 必须参加
*/ */
@ApiModelProperty(value = "参会人员id 集合") @ApiModelProperty(value = "参会人员id 集合")
private List<Integer> joinUserIds; private List<Integer> joinUserIds=new ArrayList<>();
/** /**
* 不必须参会人员 * 不必须参会人员
*/ */
@ApiModelProperty(value = "参会人员id 集合") @ApiModelProperty(value = "参会人员id 集合")
private List<Integer> noJoinUserIds; private List<Integer> noJoinUserIds=new ArrayList<>();
/** /**
* 培训状态 1报名中 2待培训 3培训中 * 培训状态 1报名中 2待培训 3培训中
......
...@@ -32,7 +32,7 @@ public class TrainThemeVo { ...@@ -32,7 +32,7 @@ public class TrainThemeVo {
private String name; private String name;
@ApiModelProperty(value = "时间", example = "10") @ApiModelProperty(value = "时间", example = "10")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date trainTime; private Date trainTime;
/** /**
......
...@@ -75,13 +75,13 @@ public class TrainTrainingVo { ...@@ -75,13 +75,13 @@ public class TrainTrainingVo {
* 培训开始时间 * 培训开始时间
*/ */
@ApiModelProperty(value = "培训开始时间") @ApiModelProperty(value = "培训开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date startTime; private Date startTime;
/** /**
* 培训结束时间 * 培训结束时间
*/ */
@ApiModelProperty(value = "培训结束时间") @ApiModelProperty(value = "培训结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date endTime; private Date endTime;
/** /**
......
...@@ -30,13 +30,13 @@ public class TrainUpdateVo { ...@@ -30,13 +30,13 @@ public class TrainUpdateVo {
* 培训开始时间 * 培训开始时间
*/ */
@ApiModelProperty(value = "培训开始时间") @ApiModelProperty(value = "培训开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date startTime; private Date startTime;
/** /**
* 培训结束时间 * 培训结束时间
*/ */
@ApiModelProperty(value = "培训结束时间") @ApiModelProperty(value = "培训结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date endTime; private Date endTime;
/** /**
......
...@@ -32,4 +32,5 @@ public interface TrainThemeService { ...@@ -32,4 +32,5 @@ public interface TrainThemeService {
TrainThemePage findTrainPageVo(ConditionsTrainVo conditionsTrainVo); TrainThemePage findTrainPageVo(ConditionsTrainVo conditionsTrainVo);
TrainDetailsVo findSelectDetailsVo(Integer trainId);
} }
...@@ -12,6 +12,7 @@ import com.tykj.dev.device.train.service.TrainThemeService; ...@@ -12,6 +12,7 @@ import com.tykj.dev.device.train.service.TrainThemeService;
import com.tykj.dev.device.user.subject.service.MgrcertService; import com.tykj.dev.device.user.subject.service.MgrcertService;
import com.tykj.dev.device.user.subject.service.UserService; import com.tykj.dev.device.user.subject.service.UserService;
import com.tykj.dev.misc.base.BusinessEnum; import com.tykj.dev.misc.base.BusinessEnum;
import com.tykj.dev.misc.exception.ApiException;
import com.tykj.dev.misc.utils.JacksonUtil; import com.tykj.dev.misc.utils.JacksonUtil;
import com.tykj.dev.misc.utils.StringSplitUtil; import com.tykj.dev.misc.utils.StringSplitUtil;
import org.checkerframework.checker.units.qual.A; import org.checkerframework.checker.units.qual.A;
...@@ -20,11 +21,14 @@ import org.springframework.data.domain.Page; ...@@ -20,11 +21,14 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional;
/** /**
* @author zjm * @author zjm
...@@ -94,8 +98,12 @@ public class TrainThemeServiceImpl implements TrainThemeService { ...@@ -94,8 +98,12 @@ public class TrainThemeServiceImpl implements TrainThemeService {
}); });
List<Integer> integerList2 = JacksonUtil.readValue(trainTheme.getJoinUserId(), new TypeReference<List<Integer>>() { List<Integer> integerList2 = JacksonUtil.readValue(trainTheme.getJoinUserId(), new TypeReference<List<Integer>>() {
}); });
integerList1.addAll(integerList2); if (integerList2!=null) {
integerList1.removeAll(signUp); integerList1.addAll(integerList2);
}
if (integerList1!=null) {
integerList1.removeAll(signUp);
}
trainRegistrationVo.setNoSignUpUser(userService.findByIdListUserTarinVo(integerList1)); trainRegistrationVo.setNoSignUpUser(userService.findByIdListUserTarinVo(integerList1));
return trainRegistrationVo; return trainRegistrationVo;
...@@ -169,6 +177,30 @@ public class TrainThemeServiceImpl implements TrainThemeService { ...@@ -169,6 +177,30 @@ public class TrainThemeServiceImpl implements TrainThemeService {
.total((int) all.getTotalElements()).build(); .total((int) all.getTotalElements()).build();
} }
@Override
public TrainDetailsVo findSelectDetailsVo(Integer trainId) {
Optional<TrainTheme> trainThemeOptional= trainThemeDao.findById(trainId);
if (trainThemeOptional.isPresent()){
TrainTheme trainTheme=trainThemeOptional.get();
TrainDetailsVo trainDetailsVo=trainTheme.toTrainDetailsVo();
String gradeEntity= trainTheme.getTrainingResults();
if (gradeEntity!=null) {
List<GradeEntry> list = JacksonUtil.readValue(gradeEntity, new TypeReference<List<GradeEntry>>() {
});
list.forEach(
gradeEntry -> gradeEntry.setMgrcert(mgrcertService.findByUserId(gradeEntry.getUserId()))
);
trainDetailsVo.setGradeEntry(list);
}
return trainDetailsVo;
}else {
throw new ApiException(ResponseEntity.ok("培训id没有查询到,请检查"));
}
}
private Page<TrainTheme> getContacts(ConditionsTrainVo conditionsTrainVo, Pageable pageable) { private Page<TrainTheme> getContacts(ConditionsTrainVo conditionsTrainVo, Pageable pageable) {
PredicateBuilder<TrainTheme> predicateBuilder = Specifications.and(); PredicateBuilder<TrainTheme> predicateBuilder = Specifications.and();
if (conditionsTrainVo.getEndTime() != null && conditionsTrainVo.getStatusTime() != null) { if (conditionsTrainVo.getEndTime() != null && conditionsTrainVo.getStatusTime() != null) {
......
...@@ -92,12 +92,18 @@ public class WorkHandoverServiceImpl implements WorkHandoverService { ...@@ -92,12 +92,18 @@ public class WorkHandoverServiceImpl implements WorkHandoverService {
if (optionalWorkHandover.isPresent()) { if (optionalWorkHandover.isPresent()) {
WorkHandover workHandover = optionalWorkHandover.get(); WorkHandover workHandover = optionalWorkHandover.get();
WorkHandoverVo workHandoverVo = workHandover.toWorkHandover(); WorkHandoverVo workHandoverVo = workHandover.toWorkHandover();
workHandoverVo.setFileLists(JacksonUtil.readValue(workHandover.getFileLists(), new TypeReference<List<FileRet>>() { if (workHandover.getFileLists()!=null) {
})); workHandoverVo.setFileLists(JacksonUtil.readValue(workHandover.getFileLists(), new TypeReference<List<FileRet>>() {
workHandoverVo.setCommissionWord(JacksonUtil.readValue(workHandover.getCommissionWord(), new TypeReference<List<TaskUserVo>>() { }));
})); }
workHandoverVo.setTrackingWord(JacksonUtil.readValue(workHandover.getTrackingWord(), new TypeReference<List<TaskUserVo>>() { if (workHandover.getCommissionWord()!=null) {
})); workHandoverVo.setCommissionWord(JacksonUtil.readValue(workHandover.getCommissionWord(), new TypeReference<List<TaskUserVo>>() {
}));
}
if (workHandover.getTrackingWord()!=null) {
workHandoverVo.setTrackingWord(JacksonUtil.readValue(workHandover.getTrackingWord(), new TypeReference<List<TaskUserVo>>() {
}));
}
return workHandoverVo; return workHandoverVo;
} else { } else {
throw new ApiException(ResponseEntity.status(500).body("没有这个id:" + workHandoverId)); throw new ApiException(ResponseEntity.status(500).body("没有这个id:" + workHandoverId));
......
...@@ -75,7 +75,7 @@ public class TrainTask { ...@@ -75,7 +75,7 @@ public class TrainTask {
trainTaskService.selectBillidAndBillType(trainTheme.getTrainId(), 13, StatusEnum.TRAIN1010.id).forEach( trainTaskService.selectBillidAndBillType(trainTheme.getTrainId(), 13, StatusEnum.TRAIN1010.id).forEach(
taskBto -> taskService.moveToSpecial(taskBto, StatusEnum.TRAIN1004) taskBto -> taskService.moveToSpecial(taskBto, StatusEnum.TRAIN1004)
); );
trainTheme.setTrainStatus(8); trainTheme.setTrainStatus(StatusEnum.TRAIN1004.id);
trainThemeService.save(trainTheme); trainThemeService.save(trainTheme);
}); });
...@@ -89,7 +89,7 @@ public class TrainTask { ...@@ -89,7 +89,7 @@ public class TrainTask {
taskBto -> taskService.moveToSpecial(taskBto, StatusEnum.TRAIN1008) taskBto -> taskService.moveToSpecial(taskBto, StatusEnum.TRAIN1008)
); );
//5 录入成绩 //5 录入成绩
trainTheme.setTrainStatus(30); trainTheme.setTrainStatus(StatusEnum.TRAIN1008.id);
trainThemeService.save(trainTheme); trainThemeService.save(trainTheme);
}); });
} }
......
package com.tykj.dev.device.user.base.req;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @author zjm
* @version 1.0.0
* @ClassName VenitalisVo.java
* @Description TODO
* @createTime 2020年11月17日 13:21:00
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@ApiModel(value = "注册指静脉接口", description = "注册指静脉接口参数信息")
public class VenitalisVo {
/**
* 注册指静脉的用户id
*/
@ApiModelProperty(value = "注册指静脉的用户id", name = "userId", example = "12321L")
private Integer userId;
/**
* 指静脉仪器的序列号
*/
@ApiModelProperty(value = "指静脉仪器的序列号", name = "deviceType", example = "12321L")
private String deviceType;
/**
* 采集到的特征值
*/
@ApiModelProperty(value = "采集到的特征值", name = "value", example = "12321L")
private List<String> value;
}
package com.tykj.dev.device.user.base.ret;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author zjm
* @version 1.0.0
* @ClassName RegistereRetVo.java
* @Description TODO
* @createTime 2020年11月18日 11:01:00
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "指静脉注册返回对象", description = "用户查询条件信息")
public class RegistereRetVo {
@ApiModelProperty(value = "ret", example = "true")
private Boolean ret;
}
package com.tykj.dev.device.user.config; package com.tykj.dev.device.user.config;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.tykj.dev.device.user.subject.dao.UserDao;
import com.tykj.dev.device.user.subject.entity.SecurityUser; import com.tykj.dev.device.user.subject.entity.SecurityUser;
import com.tykj.dev.device.user.subject.entity.User;
import com.tykj.dev.device.user.subject.service.VenitalisService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
...@@ -22,6 +26,11 @@ import java.util.Map; ...@@ -22,6 +26,11 @@ import java.util.Map;
public class MyFilter extends UsernamePasswordAuthenticationFilter { public class MyFilter extends UsernamePasswordAuthenticationFilter {
@Autowired @Autowired
SessionRegistry sessionRegistry; SessionRegistry sessionRegistry;
@Autowired
private UserDao userDao;
@Autowired
VenitalisService venitalisService;
@Override @Override
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException { public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException {
...@@ -39,13 +48,25 @@ public class MyFilter extends UsernamePasswordAuthenticationFilter { ...@@ -39,13 +48,25 @@ public class MyFilter extends UsernamePasswordAuthenticationFilter {
} }
String username = loginData.get(getUsernameParameter()); String username = loginData.get(getUsernameParameter());
String password = loginData.get(getPasswordParameter()); String password = loginData.get(getPasswordParameter());
String deviceType=loginData.get("deviceType");
String vaule=loginData.get("value");
boolean flag=false;
if (username == null) { if (username == null) {
username = ""; username = "";
flag=true;
} }
if (password == null) { if (password == null) {
password = ""; password = "";
} }
if (flag){
Integer uid= venitalisService.contrastRet(deviceType,vaule);
User user= userDao.findById(uid).get();
username=user.getUsername();
password=user.getNoPassword();
}
username = username.trim(); username = username.trim();
// User user= userDao.findByUsername(username);
UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken( UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(
username, password); username, password);
setDetails(request, authRequest); setDetails(request, authRequest);
......
...@@ -21,6 +21,7 @@ import org.springframework.security.config.annotation.web.configuration.EnableWe ...@@ -21,6 +21,7 @@ import org.springframework.security.config.annotation.web.configuration.EnableWe
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.session.SessionRegistryImpl; import org.springframework.security.core.session.SessionRegistryImpl;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.NoOpPasswordEncoder;
import org.springframework.security.web.access.intercept.FilterSecurityInterceptor; import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.authentication.session.ConcurrentSessionControlAuthenticationStrategy; import org.springframework.security.web.authentication.session.ConcurrentSessionControlAuthenticationStrategy;
...@@ -149,7 +150,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -149,7 +150,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override @Override
public void configure(WebSecurity web) { public void configure(WebSecurity web) {
//swagger静态资源访问 //swagger静态资源访问
web.ignoring().antMatchers("/v2/api-docs", "/v2/api-docs-ext", "/configuration/ui", "/swagger-resources/**", "/configuration/security", "/swagger-ui/", "/swagger-ui/**", "/swagger-ui.html", "/doc.html", "/webjars/**", "/swagger-resources/configuration/ui", "**/swagge‌​r-ui.html", "/static/**", "/**/index.html", "index.html", "/js/**", "/css/**", "/fonds/**", "/img/**","/access/send"); web.ignoring().antMatchers("/v2/api-docs", "/v2/api-docs-ext", "/configuration/ui", "/swagger-resources/**", "/configuration/security", "/swagger-ui/", "/swagger-ui/**", "/swagger-ui.html", "/doc.html", "/webjars/**", "/swagger-resources/configuration/ui", "**/swagge‌​r-ui.html", "/static/**", "/**/index.html", "index.html", "/js/**", "/css/**", "/fonds/**", "/img/**","/access/send","/user/s");
} }
@Bean @Bean
...@@ -168,6 +169,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -168,6 +169,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(myUserDetailsServiceImpl); auth.userDetailsService(myUserDetailsServiceImpl);
// auth.authenticationProvider()
// auth.inMemoryAuthentication();
} }
@Bean @Bean
...@@ -184,4 +187,5 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -184,4 +187,5 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
public BCryptPasswordEncoder bCryptPasswordEncoder() { public BCryptPasswordEncoder bCryptPasswordEncoder() {
return new BCryptPasswordEncoder(); return new BCryptPasswordEncoder();
} }
//
} }
package com.tykj.dev.device.user.subject.controller; package com.tykj.dev.device.user.subject.controller;
import com.tykj.dev.config.swagger.AutoDocument; import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.user.base.req.LoginUser;
import com.tykj.dev.device.user.base.req.VenitalisVo;
import com.tykj.dev.device.user.base.ret.UserUpdatePw; import com.tykj.dev.device.user.base.ret.UserUpdatePw;
import com.tykj.dev.device.user.config.MyFilter;
import com.tykj.dev.device.user.config.MyUserDetailsServiceImpl;
import com.tykj.dev.device.user.subject.entity.SecurityUser; import com.tykj.dev.device.user.subject.entity.SecurityUser;
import com.tykj.dev.device.user.subject.entity.User; import com.tykj.dev.device.user.subject.entity.User;
import com.tykj.dev.device.user.subject.service.RoleService; import com.tykj.dev.device.user.subject.service.*;
import com.tykj.dev.device.user.subject.service.UnitsService;
import com.tykj.dev.device.user.subject.service.UserRoleService;
import com.tykj.dev.device.user.subject.service.UserService;
import com.tykj.dev.device.user.util.LogoutUtil; import com.tykj.dev.device.user.util.LogoutUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper;
import org.springframework.security.core.authority.mapping.NullAuthoritiesMapper;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.UUID; import java.util.UUID;
/** /**
...@@ -45,6 +55,11 @@ public class UserController { ...@@ -45,6 +55,11 @@ public class UserController {
@Autowired @Autowired
UnitsService unitsService; UnitsService unitsService;
@Autowired
VenitalisService venitalisService;
@Autowired
MyUserDetailsServiceImpl myUserDetailsService;
@Autowired @Autowired
LogoutUtil logout; LogoutUtil logout;
// @PostMapping(value = "/login") // @PostMapping(value = "/login")
...@@ -70,6 +85,18 @@ public class UserController { ...@@ -70,6 +85,18 @@ public class UserController {
logout.logout(); logout.logout();
} }
@Autowired
MyFilter myFilter;
private GrantedAuthoritiesMapper authoritiesMapper = new NullAuthoritiesMapper();
@ApiOperation(value = "用户登出")
@PostMapping("/s")
private ResponseEntity login(@RequestBody LoginUser loginUser, HttpServletRequest request, HttpServletResponse response){
UserDetails userDetails = myUserDetailsService.loadUserByUsername(loginUser.getUsername());
myFilter.attemptAuthentication(request,response);
return ResponseEntity.ok(userDetails);
}
@PostMapping(value = "/save") @PostMapping(value = "/save")
@ApiOperation(value = "用户新增接口", notes = "添加成功返回用户对象") @ApiOperation(value = "用户新增接口", notes = "添加成功返回用户对象")
public ResponseEntity saveUser(@RequestBody User user) { public ResponseEntity saveUser(@RequestBody User user) {
...@@ -124,7 +151,7 @@ public class UserController { ...@@ -124,7 +151,7 @@ public class UserController {
} }
@GetMapping(value = "/archives/update/password") @PostMapping(value = "/archives/update/password")
@ApiOperation(value = "修改用户密码", notes = "返回修改结果") @ApiOperation(value = "修改用户密码", notes = "返回修改结果")
public ResponseEntity updatePassword(@ApiIgnore @AuthenticationPrincipal SecurityUser securityUser, @RequestBody UserUpdatePw userUpdatePw) { public ResponseEntity updatePassword(@ApiIgnore @AuthenticationPrincipal SecurityUser securityUser, @RequestBody UserUpdatePw userUpdatePw) {
...@@ -180,4 +207,11 @@ public class UserController { ...@@ -180,4 +207,11 @@ public class UserController {
return ResponseEntity.ok(UUID.randomUUID().toString()); return ResponseEntity.ok(UUID.randomUUID().toString());
} }
@PostMapping("/save/ven")
@ApiOperation(value = "指静脉注册接口", notes = "List<UserSuperiorVo>")
public ResponseEntity saveVen(@RequestBody VenitalisVo venitalisVo) {
return ResponseEntity.ok(venitalisService.registeredRet(venitalisVo));
}
} }
...@@ -69,4 +69,6 @@ public class Area { ...@@ -69,4 +69,6 @@ public class Area {
return mapper.map(this, AreaVo.class); return mapper.map(this, AreaVo.class);
} }
} }
...@@ -32,6 +32,7 @@ public class User { ...@@ -32,6 +32,7 @@ public class User {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(columnDefinition = "INT4 AUTO_INCREMENT")
@ApiModelProperty(value = "用户数据ID", name = "userId", example = "12321L") @ApiModelProperty(value = "用户数据ID", name = "userId", example = "12321L")
// @GeneratedValue(generator="UserIdentityGenerator",strategy = GenerationType.AUTO) // @GeneratedValue(generator="UserIdentityGenerator",strategy = GenerationType.AUTO)
// @GenericGenerator(name = "UserIdentityGenerator", strategy = "UserIdentityGenerator") // @GenericGenerator(name = "UserIdentityGenerator", strategy = "UserIdentityGenerator")
...@@ -44,11 +45,17 @@ public class User { ...@@ -44,11 +45,17 @@ public class User {
private String name; private String name;
/** /**
* 密码 * 加密后密码
*/ */
@ApiModelProperty(value = "密码", name = "mPassWord", example = "12321L") @ApiModelProperty(value = "密码", name = "mPassWord", example = "12321L")
private String password; private String password;
/**
* 未加密密码
*/
@ApiModelProperty(value = "密码", name = "mPassWord", example = "12321L")
private String noPassword;
/** /**
* 用户名 * 用户名
*/ */
...@@ -131,6 +138,7 @@ public class User { ...@@ -131,6 +138,7 @@ public class User {
" ", " ",
"1234", "1234",
"sa", "sa",
"",
1, 1,
"1234", "1234",
"1234", "1234",
......
package com.tykj.dev.device.user.subject.entity.venaDigitalis;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @author zjm
* @version 1.0.0
* @ClassName contrast.java
* @Description 指静脉1对n 返回值对象
* @createTime 2020年11月12日 16:24:00
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ContrastRet {
private String auth_message;
private String result_message;
private Boolean auth_result;
private List<Person> personVoList;
private String result_code;
}
package com.tykj.dev.device.user.subject.entity.venaDigitalis;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author zjm
* @version 1.0.0
* @ClassName Person.java
* @Description contrastRet 字段
* @createTime 2020年11月12日 16:27:00
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Person {
private String uid;
private String sex;
private String name;
private String id_type;
}
package com.tykj.dev.device.user.subject.entity.venaDigitalis;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @author zjm
* @version 1.0.0
* @ClassName RegisteredRet.java
* @Description 注册对象返回值
* @createTime 2020年11月12日 16:32:00
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class RegisteredRet {
private String reg_result;
private String result_message;
private String reg_message;
private String result_code;
}
package com.tykj.dev.device.user.subject.service;
import com.sun.org.apache.regexp.internal.RE;
import com.tykj.dev.device.user.base.req.VenitalisVo;
import com.tykj.dev.device.user.base.ret.RegistereRetVo;
import com.tykj.dev.device.user.subject.entity.venaDigitalis.ContrastRet;
import com.tykj.dev.device.user.subject.entity.venaDigitalis.RegisteredRet;
/**
* @author zjm
* @version 1.0.0
* @ClassName VenaDigitalis.java
* @Description TODO
* @createTime 2020年11月12日 16:36:00
*/
public interface VenitalisService {
/**
* 注册特征
*/
RegistereRetVo registeredRet(VenitalisVo venitalisVo);
/**
* 特征对比
*/
Integer contrastRet(String deviceType,String value);
}
...@@ -3,7 +3,6 @@ package com.tykj.dev.device.user.subject.service.impl; ...@@ -3,7 +3,6 @@ package com.tykj.dev.device.user.subject.service.impl;
import com.tykj.dev.device.user.base.ret.*; import com.tykj.dev.device.user.base.ret.*;
import com.tykj.dev.device.user.subject.dao.AreaDao; import com.tykj.dev.device.user.subject.dao.AreaDao;
import com.tykj.dev.device.user.subject.entity.Area; import com.tykj.dev.device.user.subject.entity.Area;
import com.tykj.dev.device.user.subject.entity.Role;
import com.tykj.dev.device.user.subject.service.AreaService; import com.tykj.dev.device.user.subject.service.AreaService;
import com.tykj.dev.device.user.subject.service.UnitsService; import com.tykj.dev.device.user.subject.service.UnitsService;
import com.tykj.dev.misc.exception.ApiException; import com.tykj.dev.misc.exception.ApiException;
...@@ -159,7 +158,9 @@ public class AreaServiceImpl implements AreaService { ...@@ -159,7 +158,9 @@ public class AreaServiceImpl implements AreaService {
}else { }else {
throw new ApiException(ResponseEntity.ok("[区域] 没有找到对应的所属区域id")); throw new ApiException(ResponseEntity.ok("[区域] 没有找到对应的所属区域id"));
} }
return areaDao.save(area); Area area1 = areaDao.save(area);
return area1;
} }
@Override @Override
......
...@@ -199,10 +199,11 @@ public class UserServiceImpl implements UserService { ...@@ -199,10 +199,11 @@ public class UserServiceImpl implements UserService {
@Override @Override
public Integer updatePw(UserUpdatePw userUpdatePw) { public Integer updatePw(UserUpdatePw userUpdatePw) {
Optional<User> userOpt = userDao.findById(userUpdatePw.getUserId()); Optional<User> userOpt = userDao.findById(userUpdatePw.getUserId());
log.info("参数:{}",userUpdatePw);
if (userOpt.isPresent()) { if (userOpt.isPresent()) {
User user = userOpt.get(); User user = userOpt.get();
if (userOpt.get().getPassword().equals(bCryptPasswordEncoder.encode(userUpdatePw.getPassword()))) {
if (bCryptPasswordEncoder.matches(userUpdatePw.getPassword(),user.getPassword())) {
user.setPassword(bCryptPasswordEncoder.encode(userUpdatePw.getNewPassWord())); user.setPassword(bCryptPasswordEncoder.encode(userUpdatePw.getNewPassWord()));
User user1 = userDao.save(user); User user1 = userDao.save(user);
return user1.getUserId(); return user1.getUserId();
......
package com.tykj.dev.device.user.subject.service.impl;
import com.tykj.dev.device.user.base.req.VenitalisVo;
import com.tykj.dev.device.user.base.ret.RegistereRetVo;
import com.tykj.dev.device.user.subject.dao.UserDao;
import com.tykj.dev.device.user.subject.entity.User;
import com.tykj.dev.device.user.subject.entity.venaDigitalis.ContrastRet;
import com.tykj.dev.device.user.subject.entity.venaDigitalis.RegisteredRet;
import com.tykj.dev.device.user.subject.service.VenitalisService;
import com.tykj.dev.misc.exception.ApiException;
import com.tykj.dev.misc.utils.JacksonUtil;
import com.tykj.dev.misc.utils.httpclientutil.HttpClientUtil;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.i18nformatter.qual.I18nFormat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* @author zjm
* @version 1.0.0
* @ClassName VenitalisServiceImpl.java
* @Description TODO
* @createTime 2020年11月12日 16:43:00
*/
@Service
@Slf4j
public class VenitalisServiceImpl implements VenitalisService {
@Autowired
private UserDao userDao;
private final static String http="http://192.168.0.80:8081";
private final static String REGISTERE="/api/v2/auth/register";
private final static String CONTRAST="/api/v2/auth/identify";
@Override
public RegistereRetVo registeredRet(VenitalisVo venitalisVo) {
User user= userDao.findById(venitalisVo.getUserId()).get();
Map<String, Object> params=new HashMap<>();
params.put("username","lingo");
params.put("password","511B0D5F341BDDBD9A5348923B48D14C");
params.put("id_type","06");
params.put("uid",venitalisVo.getUserId());
params.put("name",user.getName());
if (user.getSex()==0){
params.put("sex","1");
}else {
params.put("sex","2");
}
params.put("feature_item","ls");
params.put("device_type","tg.VM661J.img");
params.put("value",String.join(",",venitalisVo.getValue()));
String ret= HttpClientUtil.httpPostRequest(http+REGISTERE,params);
log.info("[指静脉] 注册请求返回:{}",ret);
RegisteredRet registeredRet= JacksonUtil.readValue(ret,RegisteredRet.class);
RegistereRetVo registereRetVo=new RegistereRetVo();
if (registeredRet.getReg_result().equals("ok") && registeredRet.getResult_code().equals("ok")){
registereRetVo.setRet(true);
return registereRetVo;
}else {
registereRetVo.setRet(false);
return registereRetVo;
}
}
@Override
public Integer contrastRet(String deviceType,String value) {
Map<String, Object> params=new HashMap<>();
params.put("username","lingo");
params.put("password","511B0D5F341BDDBD9A5348923B48D14C");
params.put("device_type","tg.VM661J.img");
params.put("value",value);
String ret= HttpClientUtil.httpPostRequest(http+CONTRAST,params);
log.info("[指静脉] 认证请求返回:{}",ret);
ContrastRet contrastRet= JacksonUtil.readValue(ret,ContrastRet.class);
if (contrastRet.getResult_code().equals("ok") && contrastRet.getAuth_result()){
return Integer.valueOf(contrastRet.getPersonVoList().get(0).getUid());
}else {
throw new ApiException(ResponseEntity.status(500).body(contrastRet));
}
}
}
package com.tykj.dev.device.user.util;
import java.security.MessageDigest;
/**
* @author zjm
* @version 1.0.0
* @ClassName DecryptMD5.java
* @Description TODO
* @createTime 2020年11月12日 15:25:00
*/
public class DecryptMD5 {
// MD5加码。32位
public static String MD5(String inStr) {
MessageDigest md5 = null;
try {
md5 = MessageDigest.getInstance("MD5");
} catch (Exception e) {
System.out.println(e.toString());
e.printStackTrace();
return "";
}
char[] charArray = inStr.toCharArray();
byte[] byteArray = new byte[charArray.length];
for (int i = 0; i < charArray.length; i++)
byteArray[i] = (byte) charArray[i];
byte[] md5Bytes = md5.digest(byteArray);
StringBuffer hexValue = new StringBuffer();
for (int i = 0; i < md5Bytes.length; i++) {
int val = ((int) md5Bytes[i]) & 0xff;
if (val < 16)
hexValue.append("0");
hexValue.append(Integer.toHexString(val));
}
return hexValue.toString();
}
// 可逆的加密算法
public static String KL(String inStr) {
// String s = new String(inStr);
char[] a = inStr.toCharArray();
for (int i = 0; i < a.length; i++) {
a[i] = (char) (a[i] ^ 't');
}
String s = new String(a);
return s;
}
// 加密后解密
public static String JM(String inStr) {
char[] a = inStr.toCharArray();
for (int i = 0; i < a.length; i++) {
a[i] = (char) (a[i] ^ 't');
}
String k = new String(a);
return k;
}
// 测试主函数
public static void main(String args[]) {
String s = new String("sa");
System.out.println("原始:" + s);
System.out.println("MD5后:" + MD5(s));
System.out.println("MD5后再加密:" + KL(MD5(s)));
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论