提交 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);
} }
...@@ -27,7 +27,11 @@ import com.tykj.dev.device.user.subject.entity.Units; ...@@ -27,7 +27,11 @@ import com.tykj.dev.device.user.subject.entity.Units;
import com.tykj.dev.device.user.subject.entity.User; import com.tykj.dev.device.user.subject.entity.User;
import com.tykj.dev.misc.base.BusinessEnum; import com.tykj.dev.misc.base.BusinessEnum;
import com.tykj.dev.misc.base.StatusEnum; import com.tykj.dev.misc.base.StatusEnum;
import com.tykj.dev.misc.exception.ApiException;
import com.tykj.dev.misc.utils.JacksonUtil;
import com.tykj.dev.misc.utils.Snowflake;
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.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
...@@ -70,6 +74,8 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -70,6 +74,8 @@ public class SendBackServiceImpl implements SendBackService {
private DeviceLibraryService deviceLibraryService; private DeviceLibraryService deviceLibraryService;
@Autowired @Autowired
private DeviceLogService deviceLogService; private DeviceLogService deviceLogService;
@Autowired
Snowflake snowflake;
/** /**
* 添加设备 * 添加设备
...@@ -123,19 +129,19 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -123,19 +129,19 @@ public class SendBackServiceImpl implements SendBackService {
} }
} }
if (!flag){ if (!flag){
sendBack.setStatus(1); sendBack.setStatus(0);
} }
List<Area> area = areaDao.findByFatherId(null); List<Area> area = areaDao.findByFatherId(null);
TaskBto taskBto = addTaskStatus(JSON.toJSONString(sendBack), idString.toString(),area.get(0).getId(),startUserId,sendBackVo.getTime(),flag); TaskBto taskBto = addTaskStatus(JSON.toJSONString(sendBack), idString.toString(),area.get(0).getId(),startUserId,sendBackVo.getTime(),flag);
/* /*
添加各单位的Task 添加各单位的Task
*/ */
addTaskById(deviceIdList,taskBto.getId(),startUserId,sendBackVo.getTime(),sendBackVo.getName()); addTaskById(deviceIdList,taskBto.getId(),startUserId,sendBackVo.getTime(),sendBackVo.getName());
return ResponseEntity.ok(taskBto.getId()); return ResponseEntity.ok(taskBto.getId());
} }
...@@ -321,7 +327,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -321,7 +327,7 @@ public class SendBackServiceImpl implements SendBackService {
待审核 待审核
*/ */
taskSaveVo.setBillStatus(StatusEnum.SEND_BACK_1207.id); taskSaveVo.setBillStatus(StatusEnum.SEND_BACK_1207.id);
taskSaveVo.setBusinessType(BusinessEnum.SEND_BACK.id); taskSaveVo.setBusinessType(BusinessEnum.SEND_BACK_EXCEPTION.id);
/* /*
设置所属单位 设置所属单位
*/ */
...@@ -334,13 +340,6 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -334,13 +340,6 @@ public class SendBackServiceImpl implements SendBackService {
taskSaveVo.setCurrentPoint(0); taskSaveVo.setCurrentPoint(0);
taskSaveVo.setInvolveUserIdList(integerList); taskSaveVo.setInvolveUserIdList(integerList);
taskService.start(taskSaveVo); taskService.start(taskSaveVo);
/*
保存task
*/
/*
生成一条代办的job,生成一条跟踪的job
*/
// addJob(task.getId(),task.getBillStatus(),userId,null,0,0);
} }
taskService.moveToEnd(parentTask); taskService.moveToEnd(parentTask);
...@@ -501,6 +500,8 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -501,6 +500,8 @@ public class SendBackServiceImpl implements SendBackService {
sendBackBillDetailEntity.setFileName(sendBackOut.getFileName()); sendBackBillDetailEntity.setFileName(sendBackOut.getFileName());
sendBackBillDetailEntity.setFileUrl(sendBackOut.getUrl()); sendBackBillDetailEntity.setFileUrl(sendBackOut.getUrl());
sendBackBillDetailEntity.setDeleteTag(0); sendBackBillDetailEntity.setDeleteTag(0);
List<Integer> ids= sendBackOut.getDeviceLibraryEntities().stream().map(DeviceLibrary::getId).collect(Collectors.toList());
sendBackBillDetailEntity.setDeviceIds(JacksonUtil.toJSon(ids));
sendBackBillDetailEntity.setApplyNumber(""); sendBackBillDetailEntity.setApplyNumber("");
sendBackBillDetailEntity.setReplayNumber(""); sendBackBillDetailEntity.setReplayNumber("");
sendBackBillDetailEntity.setReceiveUnit(fatherUnit.get(0).getName()); sendBackBillDetailEntity.setReceiveUnit(fatherUnit.get(0).getName());
...@@ -508,7 +509,8 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -508,7 +509,8 @@ public class SendBackServiceImpl implements SendBackService {
sendBackBillDetailEntity.setSendCheckDetail(sendBackOut.getReceiveCheckDetail()); sendBackBillDetailEntity.setSendCheckDetail(sendBackOut.getReceiveCheckDetail());
sendBackBillDetailEntity.setSendCheckResult(sendBackOut.getReceiveCheckResult()); sendBackBillDetailEntity.setSendCheckResult(sendBackOut.getReceiveCheckResult());
sendBackBillDetailEntity.setNum("第"+new Date().getYear()+"QT"+taskEntity.getBillId()+"号"); sendBackBillDetailEntity.setNum("第"+new Date().getYear()+"QT"+taskEntity.getBillId()+"号");
sendBackBillDetailEntity.setLeftSignatureId(String.valueOf(snowflake.creatNextId()));
sendBackBillDetailEntity.setRightSignatureId(String.valueOf(snowflake.creatNextId()));
SendBackBillDetail backBillDetailEntity = sendBackBillDetailEntityDao.save(sendBackBillDetailEntity); SendBackBillDetail backBillDetailEntity = sendBackBillDetailEntityDao.save(sendBackBillDetailEntity);
bill.setFormId(backBillDetailEntity.getId()); bill.setFormId(backBillDetailEntity.getId());
sendBackBillEntityDao.save(bill); sendBackBillEntityDao.save(bill);
...@@ -598,8 +600,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -598,8 +600,7 @@ public class SendBackServiceImpl implements SendBackService {
//父类task //父类task
TaskBto fatherTaskBto = taskService.get(taskEntity.getParentTaskId());; TaskBto fatherTaskBto = taskService.get(taskEntity.getParentTaskId());;
SendBackBill fatherBill = sendBackBillEntityDao.findById(fatherTaskBto.getBillId()).get() SendBackBill fatherBill = sendBackBillEntityDao.findById(fatherTaskBto.getBillId()).get();
;
String send=fatherBill.getSendBackStatistical(); String send=fatherBill.getSendBackStatistical();
SendBackVo sendBackVo= JSONObject.parseObject(send,SendBackVo.class); SendBackVo sendBackVo= JSONObject.parseObject(send,SendBackVo.class);
...@@ -611,7 +612,6 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -611,7 +612,6 @@ public class SendBackServiceImpl implements SendBackService {
Units units= unitsDao.findByName(sendBackBillDetail.getSendUnit()); Units units= unitsDao.findByName(sendBackBillDetail.getSendUnit());
Area area= areaDao.findById(units.getAreaId()).get(); Area area= areaDao.findById(units.getAreaId()).get();
updateStatistical(idList,area.getName(),sendBackVo); updateStatistical(idList,area.getName(),sendBackVo);
//查询当前task上级task //查询当前task上级task
//查询当前task上级task所有子task //查询当前task上级task所有子task
...@@ -623,10 +623,19 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -623,10 +623,19 @@ public class SendBackServiceImpl implements SendBackService {
if (flag){ if (flag){
if (fatherTaskBto.getParentTaskId()!=null) { if (fatherTaskBto.getParentTaskId()!=null) {
taskService.moveToSpecial(fatherTaskBto, StatusEnum.SEND_BACK_1203, 0); taskService.moveToSpecial(fatherTaskBto, StatusEnum.SEND_BACK_1203, 0);
SendBackBill billEntity = sendBackBillEntityDao.findById(fatherTaskBto.getBillId()).get(); List<Integer> list=new ArrayList<>();
List<Integer> integerList= findInvoleDevice(billEntity.getInvoleDevice()).stream().map(DeviceLibrary::getId).collect(Collectors.toList()); findInvoleDevice(fatherBill.getInvoleDevice()).forEach(deviceLibrary ->
addExceptionTask(fatherTaskBto.getId(),integerList,fatherTaskBto.getOwnUnit(),0,fatherBill.getDeadLine()); {
}else { if (!deviceLibrary.getLocationUnit().equals(deviceLibrary.getOwnUnit())){
list.add(deviceLibrary.getId());
}
}
);
if (list.size() != 0) {
addExceptionTask(fatherTaskBto.getId(), list, fatherTaskBto.getOwnUnit(), 0, fatherBill.getDeadLine());
}
}else {
sendBackVo.setStatus(0); sendBackVo.setStatus(0);
fatherBill.setSendBackStatistical(JSON.toJSONString(sendBackVo)); fatherBill.setSendBackStatistical(JSON.toJSONString(sendBackVo));
sendBackBillEntityDao.save(fatherBill); sendBackBillEntityDao.save(fatherBill);
...@@ -656,7 +665,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -656,7 +665,7 @@ public class SendBackServiceImpl implements SendBackService {
TaskBto taskEntity = taskService.get(taskId); TaskBto taskEntity = taskService.get(taskId);
Units unit = unitsDao.findById(taskEntity.getOwnUnit()).get(); Units unit = unitsDao.findById(Integer.valueOf(taskEntity.getCustomInfo())).get();
/* /*
区域对应的Task,方便点击进入下一级 区域对应的Task,方便点击进入下一级
*/ */
...@@ -665,20 +674,23 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -665,20 +674,23 @@ public class SendBackServiceImpl implements SendBackService {
获取账单信息 获取账单信息
*/ */
SendBackBill billEntity = sendBackBillEntityDao.findById(taskEntity.getBillId()).get(); SendBackBill billEntity = sendBackBillEntityDao.findById(taskEntity.getBillId()).get();
log.info("sssssssss,{}",taskEntity.getBillId());
List<Integer> idList = stringToList(billEntity.getInvoleDevice()); List<Integer> idList = stringToList(billEntity.getInvoleDevice());
/* /*
统计单 统计单
*/ */
String send = billEntity.getSendBackStatistical(); String send = billEntity.getSendBackStatistical();
if(send == null || send.equals("null") || send.equals("")){ if(send == null || send.equals("null") || send.equals("")){
if(unit.getLevel() == 2){ if(unit.getLevel() == 2){
SendBackVo sendBackVo = newStatistical(idList, 1, null, true); SendBackVo sendBackVo = newStatistical1(idList, unit);
billEntity.setSendBackStatistical(JSON.toJSONString(sendBackVo));
sendBackVo.setUnDeviceDes(JSONObject.parseObject(billEntity.getExceptionDes(), UnDeviceDesVo.class)); sendBackVo.setUnDeviceDes(JSONObject.parseObject(billEntity.getExceptionDes(), UnDeviceDesVo.class));
sendBackVo.setAreaToTaskId(areaToTaskId); sendBackVo.setAreaToTaskId(areaToTaskId);
List<String> list=new ArrayList<>();
list.add(areaDao.findById(unit.getAreaId()).get().getName());
sendBackVo.setHeader(list);
List<HashMap<String, StatisticalVo>> dataList = new ArrayList<>(sendBackVo.getMap().values()); List<HashMap<String, StatisticalVo>> dataList = new ArrayList<>(sendBackVo.getMap().values());
sendBackVo.setDataList(dataList); sendBackVo.setDataList(dataList);
billEntity.setSendBackStatistical(JSON.toJSONString(sendBackVo));
return ResponseEntity.ok(sendBackVo); return ResponseEntity.ok(sendBackVo);
}else { }else {
return ResponseEntity.ok(deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList)); return ResponseEntity.ok(deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList));
...@@ -688,15 +700,14 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -688,15 +700,14 @@ public class SendBackServiceImpl implements SendBackService {
if(unit.getLevel() == 1){ if(unit.getLevel() == 1){
type = 0; type = 0;
} }
SendBackVo sendBackVo = JSONObject.parseObject(send, new TypeReference<SendBackVo>() { SendBackVo sendBackVo1=JacksonUtil.readValue(send,SendBackVo.class);
}); SendBackVo backVo = newStatistical(idList, type, sendBackVo1, false);
SendBackVo backVo = newStatistical(idList, type, sendBackVo, false);
backVo.setUnDeviceDes(JSONObject.parseObject(billEntity.getExceptionDes(),UnDeviceDesVo.class)); backVo.setUnDeviceDes(JSONObject.parseObject(billEntity.getExceptionDes(),UnDeviceDesVo.class));
List<HashMap<String, StatisticalVo>> dataList = new ArrayList<>(backVo.getMap().values()); List<HashMap<String, StatisticalVo>> dataList = new ArrayList<>(backVo.getMap().values());
backVo.setDataList(dataList); backVo.setDataList(dataList);
backVo.setAreaToTaskId(areaToTaskId); backVo.setAreaToTaskId(areaToTaskId);
backVo.setTime(sendBackVo.getTime()); backVo.setTime(sendBackVo1.getTime());
backVo.setName(sendBackVo.getName()); backVo.setName(sendBackVo1.getName());
return ResponseEntity.ok(backVo); return ResponseEntity.ok(backVo);
} }
...@@ -720,14 +731,10 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -720,14 +731,10 @@ public class SendBackServiceImpl implements SendBackService {
List<SendBackBillDetail> list = sendBackBillDetailEntityDao.findAll(specification, pageable).getContent(); List<SendBackBillDetail> list = sendBackBillDetailEntityDao.findAll(specification, pageable).getContent();
for (SendBackBillDetail s:list) { for (SendBackBillDetail s:list) {
String deviceIds = s.getDeviceIds(); String deviceIds = s.getDeviceIds();
if (deviceIds!=null) { List<Integer> idList = JacksonUtil.readValue(deviceIds, new com.fasterxml.jackson.core.type.TypeReference<List<Integer>>() {});
String[] idString = deviceIds.split("x");
List<String> idStringList = Arrays.asList(idString);
List<String> idListString = idStringList.stream().filter(list2 -> !list2.equals("")).collect(Collectors.toList());
List<Integer> idList = idListString.stream().map(Integer::parseInt).collect(Collectors.toList());
s.setDeviceLibraryEntities(deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList)); s.setDeviceLibraryEntities(deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList));
} }
}
long count = sendBackBillDetailEntityDao.count(specification); long count = sendBackBillDetailEntityDao.count(specification);
return ResponseEntity.ok(new ListVo(count,list)); return ResponseEntity.ok(new ListVo(count,list));
} }
...@@ -831,6 +838,55 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -831,6 +838,55 @@ public class SendBackServiceImpl implements SendBackService {
return ResponseEntity.ok(new AbnormalVo("",null,sendBackBill.getDeadLine(),deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList),unDeviceDesVo)); return ResponseEntity.ok(new AbnormalVo("",null,sendBackBill.getDeadLine(),deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList),unDeviceDesVo));
} }
@Override
public ResponseEntity trackingSelect(Integer taskId) {
TaskBto taskBto= taskService.get(taskId);
TrackingVo trackingVo=new TrackingVo();
Optional<SendBackBill> sendBackBillOptional = sendBackBillEntityDao.findById(taskBto.getBillId());
if (sendBackBillOptional.isPresent()){
SendBackBill sendBackBill=sendBackBillOptional.get();
List<Integer> ids= stringToList(sendBackBill.getInvoleDevice());
List<DeviceLibrary> deviceLibraries= deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(ids);
if (taskBto.getBillStatus().equals(StatusEnum.SEND_BACK_1206.id)){
trackingVo.setStatus(3);
} else if (taskBto.getBillStatus().equals(StatusEnum.SEND_BACK_1204.id)) {
trackingVo.setStatus(3);
}else {
trackingVo.setStatus(1);
}
trackingVo.setDeviceLibraries(deviceLibraries);
Task exlTask = taskDao.findByParentTaskIdAndAndTitle(taskId, "异常装备待描述");
if (exlTask!=null){
SendBackBill sendBackBill1= sendBackBillEntityDao.findById(exlTask.getBillId()).get();
if (sendBackBill1.getExceptionDes()!=null) {
List<Integer> unDeviceIds=new ArrayList<>();
UnDeviceDesVo unDeviceDesVo = JacksonUtil.readValue(sendBackBill1.getExceptionDes(), UnDeviceDesVo.class);
trackingVo.setUnDeviceDes(unDeviceDesVo);
unDeviceDesVo.getDes().forEach(
abnormalDescribe -> unDeviceIds.add(abnormalDescribe.getId())
);
trackingVo.setUnDevice(deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(unDeviceIds));
}
}
return ResponseEntity.ok(trackingVo);
}else {
throw new ApiException(ResponseEntity.ok("[清退] 查询跟踪业务id未找到"));
}
}
@Override
public ResponseEntity repelBack(Integer taskId) {
TaskBto taskBto= taskService.get(taskId);
SendBackBill sendBackBill=sendBackBillEntityDao.findById(taskBto.getBillId()).get();
SendBackBillDetail sendBackBillDetail=sendBackBillDetailEntityDao.findById(sendBackBill.getFormId()).get();
String deviceIds = sendBackBillDetail.getDeviceIds();
if (deviceIds!=null) {
List<Integer> idList = JacksonUtil.readValue(deviceIds, new com.fasterxml.jackson.core.type.TypeReference<List<Integer>>() {});
sendBackBillDetail.setDeviceLibraryEntities(deviceLibraryDao.findAllById(idList));
}
return ResponseEntity.ok(sendBackBillDetail);
}
/** /**
* 新建task * 新建task
* @param sendBackVo 初始清退表单 * @param sendBackVo 初始清退表单
...@@ -851,7 +907,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -851,7 +907,7 @@ public class SendBackServiceImpl implements SendBackService {
List<Integer> integers=new ArrayList<>(); List<Integer> integers=new ArrayList<>();
integers= userDao.findAllByUnitsId(unitId).stream().map(User::getUserId).collect(Collectors.toList()); integers= userDao.findAllByUnitsId(unitId).stream().map(User::getUserId).collect(Collectors.toList());
integers.add(-1); integers.add(-1);
return taskService.start(new TaskBto(StatusEnum.SEND_BACK_1200.id,"装备清退",parentTaskId,".",billEntity.getId(), BusinessEnum.SEND_BACK.id,unitId,integers.size()-1,null,integers)); return taskService.start(new TaskBto(StatusEnum.SEND_BACK_1200.id,"装备清退",parentTaskId,".",billEntity.getId(), BusinessEnum.SEND_BACK.id,unitId,integers.size()-1,unitId.toString(),integers));
} }
/** /**
...@@ -891,7 +947,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -891,7 +947,7 @@ public class SendBackServiceImpl implements SendBackService {
// addJob(task.getId(),task.getBillStatus(),startUserId,null,0,0); // addJob(task.getId(),task.getBillStatus(),startUserId,null,0,0);
return taskService.start(new TaskBto(StatusEnum.SEND_BACK_1203.id,"装备清退",parentTaskId,".",billEntity.getId(), BusinessEnum.SEND_BACK.id,unitId,0,null,integers)); return taskService.start(new TaskBto(StatusEnum.SEND_BACK_1203.id,"装备清退",parentTaskId,".",billEntity.getId(), BusinessEnum.SEND_BACK.id,unitId,0,unitId.toString(),integers));
} }
/** /**
...@@ -931,7 +987,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -931,7 +987,7 @@ public class SendBackServiceImpl implements SendBackService {
// addJob(task.getId(),task.getBillStatus(),startUserId,null,0,0); // addJob(task.getId(),task.getBillStatus(),startUserId,null,0,0);
return taskService.start(new TaskBto(StatusEnum.SEND_BACK_1205.id,"异常装备描述",parentTaskId,".",billEntity.getId(), BusinessEnum.SEND_BACK.id,unitId,0,null,integers)); return taskService.start(new TaskBto(StatusEnum.SEND_BACK_1205.id,"异常装备待描述",parentTaskId,".",billEntity.getId(), BusinessEnum.SEND_BACK_EXCEPTION.id,unitId,0,unitId.toString(),integers));
} }
...@@ -959,7 +1015,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -959,7 +1015,7 @@ public class SendBackServiceImpl implements SendBackService {
List<Integer> integers=new ArrayList<>(); List<Integer> integers=new ArrayList<>();
integers.add(startUserId); integers.add(startUserId);
integers.add(-1); integers.add(-1);
TaskBto task = taskService.start(new TaskBto(StatusEnum.SEND_BACK_1200.id, "装备清退", null, ".", billEntity.getId(), BusinessEnum.SEND_BACK.id, unitId, 1, null, integers)); TaskBto task = taskService.start(new TaskBto(StatusEnum.SEND_BACK_1200.id, "装备清退", null, ".", billEntity.getId(), BusinessEnum.SEND_BACK.id, unitId, 1, unitId.toString(), integers));
if (!falg){ if (!falg){
task=taskService.moveToSpecial(task,StatusEnum.SEND_BACK_1201,startUserId); task=taskService.moveToSpecial(task,StatusEnum.SEND_BACK_1201,startUserId);
...@@ -1015,7 +1071,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1015,7 +1071,7 @@ public class SendBackServiceImpl implements SendBackService {
/** /**
* 修改统计内容 有提交需要修改提交状态 * 修改统计内容 有提交需要修改提交状态
*/ */
private SendBackVo updateStatistical(List<Integer> idList,String areaName,SendBackVo sendBack){ private void updateStatistical(List<Integer> idList,String areaName,SendBackVo sendBack){
HashMap<String,HashMap<String,StatisticalVo>> list= sendBack.getMap(); HashMap<String,HashMap<String,StatisticalVo>> list= sendBack.getMap();
HashMap<String,String> map=new HashMap<>(); HashMap<String,String> map=new HashMap<>();
...@@ -1025,21 +1081,132 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1025,21 +1081,132 @@ public class SendBackServiceImpl implements SendBackService {
map.put(deviceLibrary.getModel(),""); map.put(deviceLibrary.getModel(),"");
} }
); );
for (String name:map.keySet()){ for (String name:map.keySet()){
StatisticalVo statisticalVo = list.get(name).get(areaName); StatisticalVo statisticalVo = list.get(name).get(areaName);
statisticalVo.setStatus(3); statisticalVo.setStatus(3);
} }
return sendBack; // return sendBack;
} }
/** /**
* 统计表 * 统计表
*/ */
private SendBackVo newStatistical1(List<Integer> idList,Units units){
Area area=areaDao.findById(units.getAreaId()).get();
HashMap<String,HashMap<String,StatisticalVo>> list=new HashMap<>();
/*
映射表 0:单位-市 1:单位-区县
String 单位名称 Area 区域对象
*/
//根据所有装备id集合-获取装备集合
List<DeviceLibrary> deviceList = deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList);
/*
未在库装备
*/
List<DeviceLibrary> unDevice = new ArrayList<>();
List<String> modelList = new ArrayList<>();
List<String> areaList = new ArrayList<>();
for (DeviceLibrary DeviceLibrary:deviceList) {
//装备型号
String model = DeviceLibrary.getModel();
if(!modelList.contains(model)){
modelList.add(model);
}
String areaName = area.getName();
if(!areaList.contains(areaName)){
areaList.add(areaName);
}
}
//类型-(区域,统计)
HashMap<String,HashMap<String,StatisticalVo>> newList = new HashMap<>();
/*
生成一张新的空表
*/
for (String model:modelList) {
HashMap<String,StatisticalVo> areaMap = new HashMap<>();
areaMap.put(area.getName(),new StatisticalVo());
areaMap.put("总数",new StatisticalVo());
newList.put(model,areaMap);
}
/*
存放区域所对应的idList
*/
HashMap<String,List<Integer>> areaIdList = new HashMap<>();
/*
存放型号所对应的idList
*/
HashMap<String,List<Integer>> modelIdList = new HashMap<>();
/*
向表中填数据
*/
for (DeviceLibrary d : deviceList) {
String model = d.getModel();
String areaName = area.getName();
/*
按型号归类
*/
List<Integer> modelIds = modelIdList.getOrDefault(model, new ArrayList<>());
modelIds.add(d.getId());
modelIdList.put(model,modelIds);
/*
按区域归类
*/
List<Integer> areaIds = areaIdList.getOrDefault(areaName, new ArrayList<>());
areaIds.add(d.getId());
areaIdList.put(areaName,areaIds);
StatisticalVo statisticalVo = newList.get(model).get(areaName);
if (statisticalVo!=null) {
statisticalVo.setValCount(statisticalVo.getValCount() + 1);
statisticalVo.setAllCount(statisticalVo.getAllCount() + 1);
statisticalVo.getDeviceIdList().add(d.getId());
}
StatisticalVo all = newList.get(model).getOrDefault("总数",new StatisticalVo());
all.setAllCount(all.getAllCount() + 1);
newList.get(model).put("总数",all);
StatisticalVo name = newList.get(model).getOrDefault("名称",new StatisticalVo());
name.setName(d.getName());
newList.get(model).put("名称",name);
StatisticalVo deviceModel = newList.get(model).getOrDefault("型号",new StatisticalVo());
deviceModel.setName(model);
newList.get(model).put("型号",deviceModel);
}
SendBackVo sendBackVo = new SendBackVo();
sendBackVo.setHeader(areaList);
sendBackVo.setDeviceIdList(idList);
sendBackVo.setUnDevice(unDevice);
sendBackVo.setAreaToIds(areaIdList);
sendBackVo.setModelToIds(modelIdList);
sendBackVo.setMap(newList);
return sendBackVo;
}
private SendBackVo newStatistical(List<Integer> idList,Integer type,SendBackVo sendBack,boolean first){ private SendBackVo newStatistical(List<Integer> idList,Integer type,SendBackVo sendBack,boolean first){
HashMap<String,HashMap<String,StatisticalVo>> list; HashMap<String,HashMap<String,StatisticalVo>> list;
List<Area> areas= areaDao.findAllByFatherId(null); List<Area> areas= areaDao.findAllByFatherId(null);
if(sendBack == null){ if(sendBack == null){
list = new HashMap<>(); list = new HashMap<>();
...@@ -1189,7 +1356,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1189,7 +1356,7 @@ public class SendBackServiceImpl implements SendBackService {
Set<String> strings = newList.keySet(); Set<String> strings = newList.keySet();
Set<String> models =new HashSet<>(); Set<String> models =new HashSet<>();
// List<HashMap<String, StatisticalVo>> dataList = new ArrayList<>(); // List<HashMap<String, StatisticalVo>> dataList = new ArrayList<>();
for (String s:strings) { for (String s:strings) {
HashMap<String, StatisticalVo> stringStatisticalVoHashMap = newList.get(s); HashMap<String, StatisticalVo> stringStatisticalVoHashMap = newList.get(s);
List<StatisticalVo> statisticalVos = new ArrayList<>(stringStatisticalVoHashMap.values()); List<StatisticalVo> statisticalVos = new ArrayList<>(stringStatisticalVoHashMap.values());
...@@ -1202,7 +1369,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1202,7 +1369,7 @@ public class SendBackServiceImpl implements SendBackService {
allStatus = 1; allStatus = 1;
} }
} }
// dataList.add(stringStatisticalVoHashMap); // dataList.add(stringStatisticalVoHashMap);
} }
if (type==0) { if (type==0) {
HashMap<String, HashMap<String, StatisticalVo>> finalNewList = newList; HashMap<String, HashMap<String, StatisticalVo>> finalNewList = newList;
...@@ -1232,7 +1399,6 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1232,7 +1399,6 @@ public class SendBackServiceImpl implements SendBackService {
} }
/* /*
计算各单位的清退装备,市的清退装备包括市本级和下属单位 计算各单位的清退装备,市的清退装备包括市本级和下属单位
*/ */
...@@ -1250,13 +1416,15 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1250,13 +1416,15 @@ public class SendBackServiceImpl implements SendBackService {
*/ */
HashMap<Integer,StringBuffer> unitDeviceIds = new HashMap<>(); HashMap<Integer,StringBuffer> unitDeviceIds = new HashMap<>();
// HashMap<Integer,List<DeviceLibrary>> unitDevices=new HashMap<>();
//区县 //区县
HashMap<Integer,Integer> county=new HashMap<>(); HashMap<Integer,Integer> county=new HashMap<>();
//市 //市
HashMap<Integer,Integer> city=new HashMap<>(); HashMap<Integer,Integer> city=new HashMap<>();
//区县不在库装备存储 //不在库装备存储
HashMap<Integer,List<Integer>> cityNoLibrary=new HashMap<>(); HashMap<Integer,List<Integer>> cityNoLibrary=new HashMap<>();
//区县不在库装备存储 //区县不在库装备存储
...@@ -1266,6 +1434,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1266,6 +1434,7 @@ public class SendBackServiceImpl implements SendBackService {
*/ */
HashMap<Integer,List<Integer>> unitDevices = new HashMap<>(); HashMap<Integer,List<Integer>> unitDevices = new HashMap<>();
List<Integer> deviceIds;
for (DeviceLibrary device:deviceList) { for (DeviceLibrary device:deviceList) {
Units unit = unitsDao.findByName(device.getOwnUnit()); Units unit = unitsDao.findByName(device.getOwnUnit());
Integer level = unit.getLevel(); Integer level = unit.getLevel();
...@@ -1274,11 +1443,11 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1274,11 +1443,11 @@ public class SendBackServiceImpl implements SendBackService {
省级装备不参与分类 省级装备不参与分类
*/ */
if(level == 1){ if(level == 1){
List<Integer> deviceIds = unitDevices.getOrDefault(unit.getUnitId(), new ArrayList<>()); deviceIds = unitDevices.getOrDefault(unit.getUnitId(), new ArrayList<>());
deviceIds.add(device.getId()); deviceIds.add(device.getId());
unitDevices.put(0,deviceIds); unitDevices.put(0,deviceIds);
}else if (level == 2) { }else if (level == 2) {
List<Integer> deviceIds = unitDevices.getOrDefault(unit.getUnitId(), new ArrayList<>()); deviceIds = unitDevices.getOrDefault(unit.getUnitId(), new ArrayList<>());
deviceIds.add(device.getId()); deviceIds.add(device.getId());
unitDevices.put(unit.getUnitId(), deviceIds); unitDevices.put(unit.getUnitId(), deviceIds);
...@@ -1293,10 +1462,12 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1293,10 +1462,12 @@ public class SendBackServiceImpl implements SendBackService {
StringBuffer localIds = unitDeviceIds.getOrDefault(unit.getUnitId(), new StringBuffer()); StringBuffer localIds = unitDeviceIds.getOrDefault(unit.getUnitId(), new StringBuffer());
localIds.append("x").append(device.getId()); localIds.append("x").append(device.getId());
unitDeviceIds.put(unit.getUnitId(), localIds); unitDeviceIds.put(unit.getUnitId(), localIds);
city.put(unit.getUnitId(),0); if (!city.containsKey(city)){
city.put(unit.getUnitId(),0);
}
}else if(level == 3){ }else if(level == 3){
List<Integer> deviceIds = unitDevices.getOrDefault(unit.getUnitId(), new ArrayList<>()); deviceIds = unitDevices.getOrDefault(unit.getUnitId(), new ArrayList<>());
deviceIds.add(device.getId()); deviceIds.add(device.getId());
unitDevices.put(unit.getUnitId(), deviceIds); unitDevices.put(unit.getUnitId(), deviceIds);
...@@ -1342,9 +1513,18 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1342,9 +1513,18 @@ public class SendBackServiceImpl implements SendBackService {
SendBackVo sendBack = newStatistical(stringToList(ids.toString()), 1,null,true); SendBackVo sendBack = newStatistical(stringToList(ids.toString()), 1,null,true);
sendBack.setName(name); sendBack.setName(name);
sendBack.setTime(time); sendBack.setTime(time);
sendBack.setDeviceIdList(null);
TaskBto taskBto=addTask(parentId, JSON.toJSONString(sendBack), ids.toString(), key, userId, time); TaskBto taskBto=addTask(parentId, JSON.toJSONString(sendBack), ids.toString(), key, userId, time);
unitsAndTaskid.put(key,taskBto.getId()); unitsAndTaskid.put(key,taskBto.getId());
}else if(city.get(key)==2){
SendBackVo sendBack = newStatistical(stringToList(ids.toString()), 1,null,true);
sendBack.setName(name);
sendBack.setTime(time);
TaskBto taskBto=addTask(parentId, JSON.toJSONString(sendBack), ids.toString(), key, userId, time);
// TaskBto taskBto= addTask1203(parentId, null, ids.toString(), key, userId, time);
unitsAndTaskid.put(key,taskBto.getId());
// if (cityNoLibrary.containsKey(key)){
// addExceptionTask(taskBto.getId(),cityNoLibrary.get(key),key,userId,time);
// }
}else { }else {
TaskBto taskBto= addTask1203(parentId, null, ids.toString(), key, userId, time); TaskBto taskBto= addTask1203(parentId, null, ids.toString(), key, userId, time);
unitsAndTaskid.put(key,taskBto.getId()); unitsAndTaskid.put(key,taskBto.getId());
...@@ -1388,11 +1568,18 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1388,11 +1568,18 @@ public class SendBackServiceImpl implements SendBackService {
private HashMap<String,Integer> areaToTask(Units unit,TaskBto taskBto){ private HashMap<String,Integer> areaToTask(Units unit,TaskBto taskBto){
HashMap<String,Integer> areaToTaskId = new HashMap<>(); HashMap<String,Integer> areaToTaskId = new HashMap<>();
List<TaskBto> kidTask = new ArrayList<>(); List<TaskBto> kidTask = new ArrayList<>();
List<TaskBto> qkidTask =new ArrayList<>();
if(unit.getLevel() == 1){ if(unit.getLevel() == 1){
/* /*
省级的业务详情 省级的业务详情
*/ */
kidTask = taskDao.findTaskEntitiesByParentTaskId(taskBto.getId()).stream().map(Task::parse2Bto).collect(Collectors.toList()); kidTask = taskDao.findTaskEntitiesByParentTaskId(taskBto.getId()).stream().map(Task::parse2Bto).collect(Collectors.toList());
kidTask.forEach(
taskBto1 -> {
qkidTask.addAll(taskDao.findTaskEntitiesByParentTaskId(taskBto.getId()).stream().map(Task::parse2Bto).collect(Collectors.toList()));
}
);
}else if(unit.getLevel() == 2){ }else if(unit.getLevel() == 2){
/* /*
市级的业务详情 市级的业务详情
...@@ -1403,11 +1590,20 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1403,11 +1590,20 @@ public class SendBackServiceImpl implements SendBackService {
区域名和任务id的映射,方便进入下一级 区域名和任务id的映射,方便进入下一级
*/ */
for (TaskBto t:kidTask) { for (TaskBto t:kidTask) {
Integer ownUnit = t.getOwnUnit(); Integer ownUnit = Integer.valueOf(t.getCustomInfo());
Units units = unitsDao.findById(ownUnit).get(); Units units = unitsDao.findById(ownUnit).get();
Area area = areaDao.findById(units.getAreaId()).get(); Area area = areaDao.findById(units.getAreaId()).get();
areaToTaskId.put(area.getName(),t.getId()); areaToTaskId.put(area.getName(),t.getId());
} }
for (TaskBto t:qkidTask) {
Integer ownUnit = Integer.valueOf(t.getCustomInfo());
Units units = unitsDao.findById(ownUnit).get();
Area area = areaDao.findById(units.getAreaId()).get();
areaToTaskId.put(area.getName(),t.getId());
}
Area area = areaDao.findById(unit.getAreaId()).get();
areaToTaskId.put(area.getName(),taskBto.getId());
return areaToTaskId; return areaToTaskId;
} }
......
//package com.tykj.dev.device.sendback.service.impl;
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject;
//import com.alibaba.fastjson.TypeReference;
//import com.github.wenhao.jpa.Specifications;
//import com.tykj.dev.device.library.repository.DeviceLibraryDao;
//import com.tykj.dev.device.library.service.DeviceLibraryService;
//import com.tykj.dev.device.library.service.DeviceLogService;
//import com.tykj.dev.device.library.subject.Dto.DeviceLogDto;
//import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
//import com.tykj.dev.device.sendback.entity.domain.SendBackBill;
//import com.tykj.dev.device.sendback.entity.domain.SendBackBillDetail;
//import com.tykj.dev.device.sendback.entity.vo.*;
//import com.tykj.dev.device.sendback.repository.SendBackBillDao;
//import com.tykj.dev.device.sendback.repository.SendBackBillDetailDao;
//import com.tykj.dev.device.sendback.service.SendBackService;
//import com.tykj.dev.device.task.repository.TaskDao;
//import com.tykj.dev.device.task.service.TaskService;
//import com.tykj.dev.device.task.subject.bto.TaskBto;
//import com.tykj.dev.device.task.subject.domin.Task;
//import com.tykj.dev.device.user.subject.dao.AreaDao;
//import com.tykj.dev.device.user.subject.dao.UnitsDao;
//import com.tykj.dev.device.user.subject.dao.UserDao;
//import com.tykj.dev.device.user.subject.entity.Area;
//import com.tykj.dev.device.user.subject.entity.Units;
//import com.tykj.dev.device.user.subject.entity.User;
//import com.tykj.dev.misc.base.BusinessEnum;
//import com.tykj.dev.misc.base.StatusEnum;
//import com.tykj.dev.misc.exception.ApiException;
//import com.tykj.dev.misc.utils.JacksonUtil;
//import com.tykj.dev.misc.utils.Snowflake;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.domain.PageRequest;
//import org.springframework.data.domain.Pageable;
//import org.springframework.data.domain.Sort;
//import org.springframework.data.jpa.domain.Specification;
//import org.springframework.http.ResponseEntity;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.*;
//import java.util.stream.Collectors;
//
///**
// * <h4>Description : 装备清退</h4>
// * @Author zjm
// * @Date 2020-08-15 18:15
// * @Version 1.0
// */
//@Service
//@Slf4j
//public class SendBackServiceImpls implements SendBackService {
//
// @Autowired
// private DeviceLibraryDao deviceLibraryDao;
// @Autowired
// private SendBackBillDao sendBackBillEntityDao;
// @Autowired
// private TaskDao taskDao;
// @Autowired
// private UnitsDao unitsDao;
// @Autowired
// private AreaDao areaDao;
// @Autowired
// private TaskService taskService;
// @Autowired
// private UserDao userDao;
// @Autowired
// private SendBackBillDetailDao sendBackBillDetailEntityDao;
// @Autowired
// private DeviceLibraryService deviceLibraryService;
// @Autowired
// private DeviceLogService deviceLogService;
// @Autowired
// Snowflake snowflake;
//
// /**
// * 添加设备
// * @param deviceIdList 待清退装备的id集合
// * @return 清退单
// */
// @Override
// public ResponseEntity addDeviceToSendBack(List<Integer> deviceIdList, Integer type) {
// if(type == 2){
// return ResponseEntity.ok(deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(deviceIdList));
// }else {
// SendBackVo newSend = newStatistical(deviceIdList, type, null, true);
// List<HashMap<String, StatisticalVo>> dataList = new ArrayList<>(newSend.getMap().values());
// newSend.setDataList(dataList);
// return ResponseEntity.ok(newSend);
// }
// }
//
// /**
// * 确定待审核清退单
// * @param sendBackVo 待清退装备的表单
// * @param startUserId 操作用户id
// * @return 成功
// */
// @Transactional
// @Override
// public ResponseEntity addSendBackTask(SendBackVo sendBackVo,Integer startUserId) {
//
// /*
// 1、获取清退装备的idList
// */
// List<Integer> deviceIdList = sendBackVo.getDeviceIdList();
// /*
// 2、根据idList生成待清退装备的初始表单,浙江省的id
// */
// SendBackVo sendBack = newStatistical(deviceIdList, 0,null,true);
// sendBack.setName(sendBackVo.getName());
// sendBack.setTime(sendBackVo.getTime());
// sendBack.setDeviceIdList(null);
// StringBuilder idString = new StringBuilder();
// deviceIdList.forEach(id -> idString.append("x").append(id));
// /*
// 添加省级任务和账单
// */
// boolean flag=false;
// User user= userDao.findById(startUserId).get();
// Units units= unitsDao.findById(user.getUnitsId()).get();
// for (DeviceLibrary deviceLibrary:deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(deviceIdList)){
// if (!deviceLibrary.getLocationUnit().equals(units.getName())){
// flag=true;
// }
// }
// if (!flag){
// sendBack.setStatus(0);
// }
//
// List<Area> area = areaDao.findByFatherId(null);
//
// TaskBto taskBto = addTaskStatus(JSON.toJSONString(sendBack), idString.toString(),area.get(0).getId(),startUserId,sendBackVo.getTime(),flag);
//
//
// /*
// 添加各单位的Task
// */
// addTaskById(deviceIdList,taskBto.getId(),startUserId,sendBackVo.getTime(),sendBackVo.getName());
//
// HashMap<String,Integer> areaToTaskId = areaToTask(units,taskBto);
// SendBackBill sendBackBill= sendBackBillEntityDao.findById(taskBto.getBillId()).get();
// sendBack.setAreaToTaskId(areaToTaskId);
// sendBackBill.setSendBackStatistical(JSON.toJSONString(sendBack));
// sendBackBillEntityDao.save(sendBackBill);
//
// return ResponseEntity.ok(taskBto.getId());
// }
//
//
// /**
// * 点击查看Task,返回请退单或出库单
// * @return 清退单
// */
// @Transactional
// @Override
// public ResponseEntity getSendBackByTask(Integer taskId) {
// TaskBto taskBto = taskService.get(taskId);
// /*
// 判断任务状态,5为进行中,返回列表或统计表,16位出库待审核,返回出库单
// */
// Integer billStatus = taskBto.getBillStatus();
// /*
// 获取账单信息
// */
// SendBackBill billEntity = sendBackBillEntityDao.findById(taskBto.getBillId()).get();
//
// List<Integer> idList = stringToList(billEntity.getInvoleDevice());
// String send = billEntity.getSendBackStatistical();
// if(billStatus == 1200 || billStatus.equals(StatusEnum.SEND_BACK_1201.id)){
// Units unit = unitsDao.findById(taskBto.getOwnUnit()).get();
//
// HashMap<String,Integer> areaToTaskId = areaToTask(unit,taskBto);
// /*
// 统计单
// */
// if(send == null || send.equals("null")){
// if(unit.getLevel() == 2){
// SendBackVo sendBackVo = newStatistical(idList, 1, null, true);
// TaskBto parentTask = taskService.get(taskBto.getParentTaskId());
// SendBackBill parentBill = sendBackBillEntityDao.findById(parentTask.getBillId()).get();
// SendBackVo parentVo = JSONObject.parseObject(parentBill.getSendBackStatistical(),SendBackVo.class);
// sendBackVo.setName(parentVo.getName());
// sendBackVo.setTime(parentVo.getTime());
// billEntity.setSendBackStatistical(JSON.toJSONString(sendBackVo));
// sendBackVo.setAreaToTaskId(areaToTaskId);
// List<HashMap<String, StatisticalVo>> dataList = new ArrayList<>(sendBackVo.getMap().values());
// sendBackVo.setDataList(dataList);
// return ResponseEntity.ok(sendBackVo);
// }else {
// return ResponseEntity.ok(deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList));
// }
// }else {
// SendBackVo sendBackVo = JSONObject.parseObject(send,SendBackVo.class);
// sendBackVo.setAreaToTaskId(areaToTaskId);
// sendBackVo.setTime(sendBackVo.getTime());
// sendBackVo.setName(sendBackVo.getName());
// List<HashMap<String, StatisticalVo>> dataList = new ArrayList<>(sendBackVo.getMap().values());
// sendBackVo.setDataList(dataList);
// return ResponseEntity.ok(sendBackVo);
// }
// //27 出库待校验 18 入库待审核
// }else if(billStatus.equals(StatusEnum.SEND_BACK_1202.id) ){
//
// String sendBackOut = billEntity.getSendBackOut();
//
// return ResponseEntity.ok(JSON.parseObject(sendBackOut,new TypeReference<SendBackOutVo>() {}));
//
//
//
// }else if (billStatus.equals(StatusEnum.SEND_BACK_1204.id)){
// SendBackBillDetail sendBackBillDetail= sendBackBillDetailEntityDao.findSendBackBillDetailById(billEntity.getFormId());
// List<DeviceLibrary> deviceLibraryEntities = new ArrayList<>();
// String str2=sendBackBillDetail.getReceiveCheckDetail();
// if (str2!=null) {
// String[] strings1 = str2.split("x");
// for (String s : strings1) {
// if (s.length() >= 2 && "1".equals(s.substring(s.length() - 1))) {
// Integer id = Integer.parseInt(s.substring(0, s.length() - 1));
// Integer checkResult = Integer.parseInt(s.substring(s.length() - 1));
// DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(id);
// deviceLibraryEntity.setCheckResult(checkResult);
// deviceLibraryEntities.add(deviceLibraryEntity);
// }
// }
// }
//
// sendBackBillDetail.setDeviceLibraryEntities(deviceLibraryEntities);
//
// return ResponseEntity.ok(sendBackBillDetail);
//
// } else if(billStatus == 10 || billStatus.equals(StatusEnum.SEND_BACK_1206.id)){
// //10待审核 28入库待校验
// if (send==null || send.equals("null")){
// send=billEntity.getSendBackOut();
// }
// SendBackBillDetail one = sendBackBillDetailEntityDao.findSendBackBillDetailById(billEntity.getFormId());
// one.setDeviceLibraryEntities(deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList));
// SendBackVo sendBackVo = JSONObject.parseObject(send,SendBackVo.class);
// one.setTime(sendBackVo.getTime());
// SendBackOutVo sendBackOutVo = JSONObject.parseObject(billEntity.getSendBackOut(), SendBackOutVo.class);
// one.setBillFileName(sendBackOutVo.getReturnNoteName());
// one.setBillFileUrl(sendBackOutVo.getReturnNoteUrl());
//
// return ResponseEntity.ok(one);
// }
//
// return ResponseEntity.ok("*****");
// }
//
// @Transactional
// @Override
// public ResponseEntity exceptionTask(SendBackRequst sendBackRequst,Integer parentTaskId,Integer userId) {
//
// List<Integer> deviceIdList = sendBackRequst.getDeviceIdList();
//
// User user = userDao.findById(userId).get();
// UnDeviceDesVo unDeviceDes = sendBackRequst.getUnDeviceDesVo();
// unDeviceDes.setName(user.getName());
// unDeviceDes.setTime(new Date());
// unDeviceDes.setUnitName(unitsDao.findById(user.getUnitsId()).get().getName());
// List<AbnormalDescribe> abnormalDescribes=new ArrayList<>();
// if (unDeviceDes.getDes()!=null){
// abnormalDescribes=unDeviceDes.getDes();
// }
//
// Map<Integer,AbnormalDescribe> map=new HashMap<>();
//
// abnormalDescribes.forEach(
// abnormalDescribe -> {
// map.put(abnormalDescribe.getId(),abnormalDescribe);
// }
// );
// /*
// 将异常的装备根据所在进行分类,然后给所在地task
// */
// List<DeviceLibrary> deviceLibraryEntitiesByIdIn = deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(deviceIdList);
// HashMap<String,List<Integer>> locationUnitList = new HashMap<>();
//
// HashMap<String,List<AbnormalDescribe>> desList = new HashMap<>();
//
// for (DeviceLibrary deviceLibraryEntity : deviceLibraryEntitiesByIdIn) {
// String locationUnit = deviceLibraryEntity.getLocationUnit();
//
// List<Integer> ids = locationUnitList.get(locationUnit);
// if(ids == null){
// ids = new ArrayList<>();
// }
// ids.add(deviceLibraryEntity.getId());
// locationUnitList.put(locationUnit,ids);
//
// List<AbnormalDescribe> unDeviceDesVos = desList.get(locationUnit);
// if(unDeviceDesVos == null){
// unDeviceDesVos = new ArrayList<>();
// }
// unDeviceDesVos.add(map.get(deviceLibraryEntity.getId()));
// desList.put(locationUnit,unDeviceDesVos);
// }
//
// TaskBto parentTask = taskService.get(parentTaskId);
// SendBackBill parentBillEntity = sendBackBillEntityDao.findById(parentTask.getBillId()).get();
// parentBillEntity.setExceptionDes(JSON.toJSONString(unDeviceDes));
// sendBackBillEntityDao.save(parentBillEntity);
//
//
// Set<String> locationKey = locationUnitList.keySet();
// for (String location:locationKey) {
// TaskBto taskSaveVo = new TaskBto();
// /*
// 一个task,绑定一个账单,账单中存放装备ID
// */
// SendBackBill sendBackBillEntity = new SendBackBill();
// StringBuffer idString = new StringBuffer();
// locationUnitList.get(location).forEach(id -> idString.append("x").append(id));
// sendBackBillEntity.setInvoleDevice(idString.toString());
// unDeviceDes.setDes(desList.get(location));
// sendBackBillEntity.setExceptionDes(JSON.toJSONString(unDeviceDes));
// sendBackBillEntity.setDeadLine(new Date());
// sendBackBillEntity.setReviewUserId(0);
// sendBackBillEntity.setTitle("装备异常报告");
//
// SendBackBill billEntity = sendBackBillEntityDao.save(sendBackBillEntity);
// /*
// 账单与task关联
// */
// taskSaveVo.setTitle("装备异常报告");
// taskSaveVo.setBillId(billEntity.getId());
// /*
// 待审核
// */
// taskSaveVo.setBillStatus(StatusEnum.SEND_BACK_1207.id);
// taskSaveVo.setBusinessType(BusinessEnum.SEND_BACK.id);
// /*
// 设置所属单位
// */
// Units unit = unitsDao.findByName(location);
// taskSaveVo.setOwnUnit(unit.getUnitId());
// taskSaveVo.setParentTaskId(parentTask.getParentTaskId());
// taskSaveVo.setNodeIdDetail("");
// List<Integer> integerList=new ArrayList<>();
// integerList.add(0);
// taskSaveVo.setCurrentPoint(0);
// taskSaveVo.setInvolveUserIdList(integerList);
// taskService.start(taskSaveVo);
// }
// taskService.moveToEnd(parentTask);
//
// return ResponseEntity.ok("提交成功");
// }
//
// /**
// * 点击"确认后",开始处理异常
// * 1、将装备的所属单位改为处理人的所属单位
// * @param
// * @return 成功
// */
// @Transactional
// @Override
// public ResponseEntity endException(Integer taskId,Integer userId,Integer type) {
//
// User user = userDao.findById(userId).get();
// Units units = unitsDao.findById(user.getUnitsId()).get();
// TaskBto taskBto=taskService.get(taskId);
// /*
// 获取该Task的账单
// */
// Integer billId = taskBto.getBillId();
// SendBackBill sendBackBill = sendBackBillEntityDao.findById(billId).get();
// /*
// 获取关联的设备id
// */
// String involeDevice=sendBackBill.getInvoleDevice();
// List<Integer> idList = stringToList(involeDevice);
//
// /*
// 根据idList查询装备列表
// */
// List<DeviceLibrary> deviceList = deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList);
// deviceList.forEach(devices -> {
// DeviceLogDto deviceLogDto = new DeviceLogDto(devices.getId(),"清退异常将装备的所属单位从"+devices.getOwnUnit()+"改为"+units.getName(),null);
// deviceLogService.addLog(deviceLogDto);
// devices.setOwnUnit(units.getName());
// deviceLibraryService.update(devices);
// });
//
// /*
// 在parentTask的账单中移除id
// */
// TaskBto parentTask = taskService.get(taskBto.getParentTaskId());
// Integer parentTaskBillId = parentTask.getBillId();
// SendBackBill parentTaskBill = sendBackBillEntityDao.findById(parentTaskBillId).get();
// parentTaskBill.setInvoleDevice(parentTaskBill.getInvoleDevice().replaceAll(involeDevice,""));
//
// if (parentTaskBill.getInvoleDevice().equals("")){
// taskService.moveToEnd(parentTask);
// s(parentTask,parentTaskBill,idList);
//
// }
//
// sendBackBillEntityDao.save(parentTaskBill);
// taskService.moveToEnd(taskBto);
//
// if (units.getLevel()==2){
// TaskBto cityTask = taskService.get(parentTask.getParentTaskId());
// Integer cityTaskBillId = cityTask.getBillId();
// SendBackBill cityTaskBill = sendBackBillEntityDao.findById(cityTaskBillId).get();
// parentTaskBill.setInvoleDevice(cityTaskBill.getInvoleDevice()+involeDevice);
// sendBackBillEntityDao.save(parentTaskBill);
// }
//
// return ResponseEntity.ok("异常处理成功");
// }
//
//
// /**
// * 清退装备出库校验
// * @return 成功
// */
// @Transactional
// @Override
// public ResponseEntity sendBackOutCheck(Integer taskId,Integer userId) {
//
// TaskBto taskEntity = taskService.get(taskId);
//
// /*
// 获取账单信息,根据账单的id,出库装备
// */
// SendBackBill billEntity = sendBackBillEntityDao.findById(taskEntity.getBillId()).get();
// List<String> idStringList = Arrays.asList(billEntity.getInvoleDevice().split("x"));
// List<String> idListString = idStringList.stream().filter(list2->!list2.equals("")).collect(Collectors.toList());
// System.out.println(idListString);
// List<Integer> idList = idListString.stream().map(Integer::parseInt).collect(Collectors.toList());
//
// /*
// 返回出库单
// */
// SendBackOutVo sendBackOutVo = new SendBackOutVo();
//
// sendBackOutVo.setTime(billEntity.getDeadLine());
//
// /*
// 计算应出库和实出库,应出库为实出库加异常的数量(目前不管异常设备)
// */
// sendBackOutVo.setActualOut(idList.size());
// sendBackOutVo.setShouldOut(idList.size());
// List<DeviceLibrary> deviceLibraries= new ArrayList<>();
// boolean flag=false;
// for (DeviceLibrary deviceLibrary:deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList)) {
// if (!deviceLibrary.getOwnUnit().equals(deviceLibrary.getLocationUnit())){
// deviceLibrary.setManageStatus(0);
// sendBackOutVo.setIsNotOutbound(1);
// flag=true;
// }else {
// deviceLibrary.setManageStatus(1);
// }
// deviceLibraries.add(deviceLibrary);
// }
// sendBackOutVo.setDeviceLibraryEntities(deviceLibraries);
// if (flag) {
// Task exlTask = taskDao.findByParentTaskIdAndAndTitle(taskId, "装备异常报告");
// sendBackOutVo.setExcTask(exlTask.getId());
// }
// return ResponseEntity.ok(sendBackOutVo);
// }
//
// /**
// * 装备出库发起——专管员A
// * @return 成功
// */
// @Transactional
// @Override
// public ResponseEntity sendBackOut(Integer taskId,SendBackOutVo sendBackOut,Integer userId) {
// /*
// 保存出库清单
// */
// TaskBto taskEntity = taskService.get(taskId);
// Units unit = unitsDao.findById(taskEntity.getOwnUnit()).get();
//
// Area area = areaDao.findById(unit.getAreaId()).get();
//
// List<Units> fatherUnit = unitsDao.findByAreaId(area.getFatherId());
//
// SendBackBill bill = sendBackBillEntityDao.findById(taskEntity.getBillId()).get();
// bill.setSendBackOut(JSON.toJSONString(sendBackOut));
//
// taskService.moveToSpecial(taskEntity,StatusEnum.SEND_BACK_1202,sendBackOut.getReviewerNameId());
//
//
// /*
// 生成清退的表格
// */
// SendBackBillDetail sendBackBillDetailEntity = new SendBackBillDetail();
// sendBackBillDetailEntity.setSendUnit(unit.getName());
// sendBackBillDetailEntity.setSendUserAName(sendBackOut.getName());
// sendBackBillDetailEntity.setSendUserAId(sendBackOut.getId());
// sendBackBillDetailEntity.setSendUserBName(sendBackOut.getReviewerName());
// sendBackBillDetailEntity.setSendUserBId(sendBackOut.getReviewerNameId());
// sendBackBillDetailEntity.setSendTime(new Date());
// sendBackBillDetailEntity.setSendedCount(sendBackOut.getShouldOut());
// sendBackBillDetailEntity.setSendBackCount(sendBackOut.getActualOut());
// sendBackBillDetailEntity.setSendBackStatus(1);
// sendBackBillDetailEntity.setFileName(sendBackOut.getFileName());
// sendBackBillDetailEntity.setFileUrl(sendBackOut.getUrl());
// sendBackBillDetailEntity.setDeleteTag(0);
// sendBackBillDetailEntity.setApplyNumber("");
// sendBackBillDetailEntity.setReplayNumber("");
// sendBackBillDetailEntity.setReceiveUnit(fatherUnit.get(0).getName());
// sendBackBillDetailEntity.setReceiveUserAId(0);
// sendBackBillDetailEntity.setSendCheckDetail(sendBackOut.getReceiveCheckDetail());
// sendBackBillDetailEntity.setSendCheckResult(sendBackOut.getReceiveCheckResult());
// sendBackBillDetailEntity.setNum("第"+new Date().getYear()+"QT"+taskEntity.getBillId()+"号");
// sendBackBillDetailEntity.setLeftSignatureId(String.valueOf(snowflake.creatNextId()));
// sendBackBillDetailEntity.setRightSignatureId(String.valueOf(snowflake.creatNextId()));
// SendBackBillDetail backBillDetailEntity = sendBackBillDetailEntityDao.save(sendBackBillDetailEntity);
// bill.setFormId(backBillDetailEntity.getId());
// sendBackBillEntityDao.save(bill);
//
// return ResponseEntity.ok("装备出库发起成功等待审核");
// }
//
// /**
// * 装备出库审核
// * 1、修改task状态
// * 2、生成清退单详情
// * 3、生成入库的Task
// * @return 成功
// */
// @Transactional
// @Override
// public ResponseEntity sendBackOutExamine(Integer taskId,Integer userId,Integer type) {
// TaskBto taskEntity = taskService.get(taskId);
//
// Units unit = unitsDao.findById(taskEntity.getOwnUnit()).get();
//
// Area area = areaDao.findById(unit.getAreaId()).get();
//
// List<Units> fatherUnit = unitsDao.findByAreaId(area.getFatherId());
// Units father=fatherUnit.get(0);
// taskEntity.setOwnUnit(father.getUnitId());
// SendBackBill sendBackBill= sendBackBillEntityDao.findById(taskEntity.getBillId()).get();
// List<Integer> idList=stringToList(sendBackBill.getInvoleDevice());
// deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList).forEach(
// deviceLibrary -> {
// DeviceLogDto deviceLogDto = new DeviceLogDto(deviceLibrary.getId(),"清退装备出库等待"+father.getName()+"签收",null);
// deviceLogService.addLog(deviceLogDto);
// }
// );
// taskService.moveToSpecial(taskEntity,StatusEnum.SEND_BACK_1206,0);
//
// return ResponseEntity.ok("装配入库申请发送成功");
// }
//
//
// /**
// * 入库-专管员B
// * 1、通过,完结task
// * 2、修改装备的所属地
// * 3、通知fatherTask,清退完成
// * @return 成功
// */
// @Transactional
// @Override
// public ResponseEntity sendBackIn(Integer taskId,Integer userId,Integer type) {
//
// TaskBto taskEntity = taskService.get(taskId);
// Units unit = unitsDao.findById(taskEntity.getOwnUnit()).get();
//
// /*
// 已完结
// */
// taskService.moveToEnd(taskEntity);
// /*
// 修改装备是所属单位
// */
// Integer billId = taskEntity.getBillId();
// SendBackBill bill = sendBackBillEntityDao.findById(billId).get();
// bill.setIsComplete(1);
// sendBackBillEntityDao.save(bill);
// List<Integer> idList = stringToList(bill.getInvoleDevice());
// List<DeviceLibrary> deviceList = deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList);
// for (DeviceLibrary d:deviceList) {
// DeviceLogDto deviceLogDto = new DeviceLogDto(d.getId(),"清退装备签收入库完成",null);
// deviceLogService.addLog(deviceLogDto);
// d.setLocationUnit(unit.getName());
// d.setOwnUnit(unit.getName());
// d.setManageStatus(1);
//
// }
// deviceLibraryDao.saveAll(deviceList);
//
// s(taskEntity,bill,idList);
// return ResponseEntity.ok("装备已入库");
// }
//
// /**
// * 判断是否全部提交
// * 全部提交把跟踪业务改为代办
// */
// private void s(TaskBto taskEntity,SendBackBill bill,List<Integer> idList){
//
// //父类task
// TaskBto fatherTaskBto = taskService.get(taskEntity.getParentTaskId());;
// SendBackBill fatherBill = sendBackBillEntityDao.findById(fatherTaskBto.getBillId()).get()
// ;
// String send=fatherBill.getSendBackStatistical();
// SendBackVo sendBackVo= JSONObject.parseObject(send,SendBackVo.class);
//
// /*
// 将入库结果反馈给下级,由于两个task使用的是同一个账单,所以数据已反馈
// */
//
// SendBackBillDetail sendBackBillDetail= sendBackBillDetailEntityDao.findSendBackBillDetailById(bill.getFormId());
// Units units= unitsDao.findByName(sendBackBillDetail.getSendUnit());
// Area area= areaDao.findById(units.getAreaId()).get();
// updateStatistical(idList,area.getName(),sendBackVo);
//
// //查询当前task上级task
//
// //查询当前task上级task所有子task
// List<Task> taskList=taskDao.findAllByParentTaskId(fatherTaskBto.getId());
// //判断对应的bill是否完成
// List<Integer> integers=taskList.stream().map(Task::getBillId).collect(Collectors.toList());
//
// boolean flag = sendBackBillEntityDao.findAllById(integers).stream().allMatch(e->e.getIsComplete()==1);
// if (flag){
// if (fatherTaskBto.getParentTaskId()!=null) {
// taskService.moveToSpecial(fatherTaskBto, StatusEnum.SEND_BACK_1203, 0);
//// SendBackBill billEntity = sendBackBillEntityDao.findById(fatherTaskBto.getBillId()).get();
//// List<Integer> integerList= findInvoleDevice(billEntity.getInvoleDevice()).stream().map(DeviceLibrary::getId).collect(Collectors.toList());
//// addExceptionTask(fatherTaskBto.getId(),integerList,fatherTaskBto.getOwnUnit(),0,fatherBill.getDeadLine());
// }else {
// sendBackVo.setStatus(0);
// fatherBill.setSendBackStatistical(JSON.toJSONString(sendBackVo));
// sendBackBillEntityDao.save(fatherBill);
// taskService.moveToSpecial(fatherTaskBto,StatusEnum.SEND_BACK_1201,fatherTaskBto.getCreateUserId());
// }
// }
//
//
// }
// private List<DeviceLibrary> findInvoleDevice(String involeDevice){
// List<String> idStringList = Arrays.asList(involeDevice.split("x"));
// List<String> idListString = idStringList.stream().filter(list2->!list2.equals("")).collect(Collectors.toList());
// System.out.println(idListString);
// List<Integer> devIds = idListString.stream().map(Integer::parseInt).collect(Collectors.toList());
//
// return deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(devIds);
// }
//
//
// /**
// * 业务详情
// * @param taskId taskid
// * @return 成功
// */
// @Override
// public ResponseEntity bussiness(Integer taskId) {
//
// TaskBto taskEntity = taskService.get(taskId);
//
// Units unit = unitsDao.findById(taskEntity.getOwnUnit()).get();
// /*
// 区域对应的Task,方便点击进入下一级
// */
// HashMap<String,Integer> areaToTaskId = areaToTask(unit,taskEntity);
// /*
// 获取账单信息
// */
// SendBackBill billEntity = sendBackBillEntityDao.findById(taskEntity.getBillId()).get();
// List<Integer> idList = stringToList(billEntity.getInvoleDevice());
// /*
// 统计单
// */
// String send = billEntity.getSendBackStatistical();
//
// if(send == null || send.equals("null") || send.equals("")){
// if(unit.getLevel() == 2){
// SendBackVo sendBackVo = newStatistical(idList, 1, null, true);
// sendBackVo.setUnDeviceDes(JSONObject.parseObject(billEntity.getExceptionDes(), UnDeviceDesVo.class));
// sendBackVo.setAreaToTaskId(areaToTaskId);
// List<HashMap<String, StatisticalVo>> dataList = new ArrayList<>(sendBackVo.getMap().values());
// sendBackVo.setDataList(dataList);
// billEntity.setSendBackStatistical(JSON.toJSONString(sendBackVo));
// return ResponseEntity.ok(sendBackVo);
// }else {
// return ResponseEntity.ok(deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList));
// }
// }else {
// int type = 1;
// if(unit.getLevel() == 1){
// type = 0;
// }
// SendBackVo sendBackVo1=JacksonUtil.readValue(send,SendBackVo.class);
// SendBackVo backVo = newStatistical(idList, type, sendBackVo1, false);
// backVo.setUnDeviceDes(JSONObject.parseObject(billEntity.getExceptionDes(),UnDeviceDesVo.class));
// List<HashMap<String, StatisticalVo>> dataList = new ArrayList<>(backVo.getMap().values());
// backVo.setDataList(dataList);
// if (sendBackVo1.getAreaToTaskId()!=null){
// backVo.setAreaToTaskId(sendBackVo1.getAreaToTaskId());
// }
// backVo.setTime(sendBackVo1.getTime());
// backVo.setName(sendBackVo1.getName());
// return ResponseEntity.ok(backVo);
// }
//
// }
//
// /**
// * 业务详情列表查询
// * @param sendBackOutFormVo 查询条件
// * @return 数量和列表
// */
// @Override
// public ResponseEntity getList(SendBackOutFormVo sendBackOutFormVo) {
//
// Specification<SendBackBillDetail> specification = Specifications.<SendBackBillDetail>and()
// .eq(sendBackOutFormVo.getSendUnit() != null, "sendUnit", sendBackOutFormVo.getSendUnit())
// .eq(sendBackOutFormVo.getReceiveUnit() != null, "receiveUnit", sendBackOutFormVo.getReceiveUnit())
// .gt(sendBackOutFormVo.getStartTime() != null, "sendTime", sendBackOutFormVo.getStartTime())
// .lt(sendBackOutFormVo.getEndTime() != null, "sendTime", sendBackOutFormVo.getEndTime())
// .build();
// Pageable pageable = PageRequest.of(sendBackOutFormVo.getPage() - 1, sendBackOutFormVo.getSize(), Sort.Direction.DESC, "id");
// List<SendBackBillDetail> list = sendBackBillDetailEntityDao.findAll(specification, pageable).getContent();
// for (SendBackBillDetail s:list) {
// String deviceIds = s.getDeviceIds();
// if (deviceIds!=null) {
// String[] idString = deviceIds.split("x");
// List<String> idStringList = Arrays.asList(idString);
// List<String> idListString = idStringList.stream().filter(list2 -> !list2.equals("")).collect(Collectors.toList());
// List<Integer> idList = idListString.stream().map(Integer::parseInt).collect(Collectors.toList());
// s.setDeviceLibraryEntities(deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList));
// }
// }
// long count = sendBackBillDetailEntityDao.count(specification);
// return ResponseEntity.ok(new ListVo(count,list));
// }
//
// /**
// * 造数据用
// * @param sendBackBillDetailEntity 保存的清退单
// * @return null
// */
// @Override
// public ResponseEntity save(SendBackBillDetail sendBackBillDetailEntity) {
//
// sendBackBillDetailEntityDao.save(sendBackBillDetailEntity);
//
// return ResponseEntity.ok("完成");
// }
//
// /**
// * 查看某个型号的装备
// * @param deviceList 装备list
// * @return 装备
// */
// @Override
// public ResponseEntity getDeviceByModel(List<Integer> deviceList) {
// return ResponseEntity.ok(deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(deviceList));
// }
//
// /**
// * 保存入库单
// * @param sendBackBillDetailEntity 清退单
// * @return 成功
// */
// @Override
// public ResponseEntity saveSendBackBillDetailEntity(SendBackBillDetail sendBackBillDetailEntity) {
// sendBackBillDetailEntityDao.save(sendBackBillDetailEntity);
// return ResponseEntity.ok("清退单保存单");
// }
//
// @Transactional
// @Override
// public ResponseEntity sendBackInCheck(Integer taskId, SendBackOutVo sendBackOut, Integer userId) {
// /*
// 保存出库清单
// */
// TaskBto taskEntity = taskService.get(taskId);
//// taskEntity.setBillStatus(19);
// SendBackBill bill = sendBackBillEntityDao.findById(taskEntity.getBillId()).get();
// bill.setSendBackOut(JSON.toJSONString(sendBackOut));
//
// User user = userDao.findById(userId).get();
// SendBackBillDetail form = sendBackBillDetailEntityDao.findById(bill.getFormId()).get();
// form.setReceiveUserAId(userId);
// form.setReceiveUserAName(user.getName());
// form.setBillFileUrl(sendBackOut.getUrl());
// form.setBillFileName(sendBackOut.getFileName());
// form.setReceiveCheckDetail(sendBackOut.getReceiveCheckDetail());
// form.setReceiveCheckResult(sendBackOut.getReceiveCheckResult());
// form.setReceiveCount(sendBackOut.getActualOut());
// form.setSendedCount(sendBackOut.getShouldOut());
// form.setReceiveUserBId(sendBackOut.getReviewerNameId());
// form.setReceiveUserBName(sendBackOut.getReviewerName());
// sendBackBillDetailEntityDao.save(form);
// /*
// task 推入 19
// */
// taskService.moveToSpecial(taskEntity,StatusEnum.SEND_BACK_1204,sendBackOut.getReviewerNameId());
//// JobEntity job = jobDao.findByTaskIdAndIsDone(taskEntity.getId(), 0);
//// job.setIsDone(1);
//// addJob(taskEntity.getId(),taskEntity.getBillStatus(),userId,job,sendBackOut.getReviewerNameId(),0);
// /*
// 生成日志
// */
//// addLog(taskId,stringToList(bill.getInvoleDevice()),user.getName()+"发起装备入库申请,待"+sendBackOut.getReviewerName()+"审核","Ǒ"+sendBackOut.getUrl()+"Ǒ"+sendBackOut.getFileName());
//
//
// return ResponseEntity.ok("装备入库发起成功等待审核");
// }
//
//
// /**
// * 办结任务
// * @param taskId 任务id
// * @return 成功
// */
// @Override
// public ResponseEntity endTask(Integer taskId) {
// TaskBto taskEntity = taskService.get(taskId);
// taskService.moveToEnd(taskEntity);
// return ResponseEntity.ok("清退已办结");
// }
//
// @Override
// public ResponseEntity exceptionSelect(Integer task) {
// UnDeviceDesVo unDeviceDesVo =null;
// TaskBto taskBto = taskService.get(task);
// SendBackBill sendBackBill= sendBackBillEntityDao.findById(taskBto.getBillId()).get();
// if (sendBackBill.getExceptionDes()!=null) {
// unDeviceDesVo = JSONObject.parseObject(sendBackBill.getExceptionDes(), UnDeviceDesVo.class);
// }
// List<Integer> idList=stringToList(sendBackBill.getInvoleDevice());
// return ResponseEntity.ok(new AbnormalVo("",null,sendBackBill.getDeadLine(),deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList),unDeviceDesVo));
// }
//
// @Override
// public ResponseEntity trackingSelect(Integer taskId) {
// TaskBto taskBto= taskService.get(taskId);
// TrackingVo trackingVo=new TrackingVo();
// Optional<SendBackBill> sendBackBillOptional = sendBackBillEntityDao.findById(taskBto.getBillId());
// if (sendBackBillOptional.isPresent()){
// SendBackBill sendBackBill=sendBackBillOptional.get();
// List<Integer> ids= stringToList(sendBackBill.getInvoleDevice());
// List<DeviceLibrary> deviceLibraries= deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(ids);
// if (taskBto.getBillStatus().equals(StatusEnum.SEND_BACK_1206.id)){
// trackingVo.setStatus(3);
// } else if (taskBto.getBillStatus().equals(StatusEnum.SEND_BACK_1204.id)) {
// trackingVo.setStatus(3);
// }else {
// trackingVo.setStatus(1);
// }
// trackingVo.setDeviceLibraries(deviceLibraries);
// return ResponseEntity.ok(trackingVo);
// }else {
// throw new ApiException(ResponseEntity.ok("[清退] 查询跟踪业务id未找到"));
// }
// }
//
// /**
// * 新建task
// * @param sendBackVo 初始清退表单
// * @param idString id集合
// */
// private TaskBto addTask(int parentTaskId, String sendBackVo, String idString, Integer unitId, Integer startUserId, Date deadLine){
//
//
// //一个task,绑定一个账单,账单中存放装备ID和初始化清退单
// SendBackBill sendBackBillEntity = new SendBackBill();
// sendBackBillEntity.setSendBackStatistical(sendBackVo);
// sendBackBillEntity.setInvoleDevice(idString);
// sendBackBillEntity.setDeadLine(deadLine);
// sendBackBillEntity.setReviewUserId(startUserId);
// sendBackBillEntity.setTitle("清退账单");
// SendBackBill billEntity = sendBackBillEntityDao.save(sendBackBillEntity);
// //生成省级及以下的Task
// List<Integer> integers=new ArrayList<>();
// integers= userDao.findAllByUnitsId(unitId).stream().map(User::getUserId).collect(Collectors.toList());
// integers.add(-1);
// return taskService.start(new TaskBto(StatusEnum.SEND_BACK_1200.id,"装备清退",parentTaskId,".",billEntity.getId(), BusinessEnum.SEND_BACK.id,unitId,integers.size()-1,null,integers));
// }
//
// /**
// * 代办
// * @param parentTaskId
// * @param sendBackVo
// * @param idString
// * @param unitId
// * @param startUserId
// * @param deadLine
// * @return
// */
// private TaskBto addTask1203(int parentTaskId, String sendBackVo, String idString, Integer unitId, Integer startUserId, Date deadLine){
//
// /*
// 一个task,绑定一个账单,账单中存放装备ID和初始化清退单
// */
// SendBackBill sendBackBillEntity = new SendBackBill();
// sendBackBillEntity.setSendBackStatistical(sendBackVo);
// sendBackBillEntity.setInvoleDevice(idString);
// sendBackBillEntity.setDeadLine(deadLine);
// sendBackBillEntity.setReviewUserId(startUserId);
// sendBackBillEntity.setTitle("清退账单");
//
// SendBackBill billEntity = sendBackBillEntityDao.save(sendBackBillEntity);
//
// /*
// 生成省级及以下的Task
// */
// List<Integer> integers=new ArrayList<>();
// integers.add(0);
//
// /*
// 保存省级的task
// */
//
//
//// addJob(task.getId(),task.getBillStatus(),startUserId,null,0,0);
//
// return taskService.start(new TaskBto(StatusEnum.SEND_BACK_1203.id,"装备清退",parentTaskId,".",billEntity.getId(), BusinessEnum.SEND_BACK.id,unitId,0,null,integers));
// }
//
// /**
// * 县生成异常事件
// *
// */
// private TaskBto addExceptionTask(int parentTaskId, List<Integer> idString, Integer unitId, Integer startUserId, Date deadLine){
//
// /*
// 一个task,绑定一个账单,账单中存放装备ID和初始化清退单
// */
// StringBuffer localIds =new StringBuffer();
// idString.forEach(
// id-> localIds.append("x").append(id)
//
// );
//
// SendBackBill sendBackBillEntity = new SendBackBill();
//
// sendBackBillEntity.setSendBackStatistical(null);
// sendBackBillEntity.setInvoleDevice(localIds.toString());
// sendBackBillEntity.setDeadLine(deadLine);
// sendBackBillEntity.setTitle("异常装备处理");
//
// SendBackBill billEntity = sendBackBillEntityDao.save(sendBackBillEntity);
//
// /*
// 生成省级及以下的Task
// */
// List<Integer> integers=new ArrayList<>();
// integers.add(0);
//
// /*
// 保存省级的task
// */
//
//
//// addJob(task.getId(),task.getBillStatus(),startUserId,null,0,0);
//
// return taskService.start(new TaskBto(StatusEnum.SEND_BACK_1205.id,"装备异常报告",parentTaskId,".",billEntity.getId(), BusinessEnum.SEND_BACK.id,unitId,0,null,integers));
// }
//
//
// /**
// * 新建task
// * @param sendBackVo 初始清退表单
// * @param idString id集合
// */
// private TaskBto addTaskStatus(String sendBackVo, String idString, Integer unitId, Integer startUserId, Date deadLine,boolean falg){
//
// /*
// 一个task,绑定一个账单,账单中存放装备ID和初始化清退单
// */
// SendBackBill sendBackBillEntity = new SendBackBill();
// sendBackBillEntity.setSendBackStatistical(sendBackVo);
// sendBackBillEntity.setInvoleDevice(idString);
// sendBackBillEntity.setDeadLine(deadLine);
// sendBackBillEntity.setReviewUserId(startUserId);
// sendBackBillEntity.setTitle("清退账单");
// SendBackBill billEntity = sendBackBillEntityDao.save(sendBackBillEntity);
// /*
// 生成省级及以下的Task
// */
//
// List<Integer> integers=new ArrayList<>();
// integers.add(startUserId);
// integers.add(-1);
// TaskBto task = taskService.start(new TaskBto(StatusEnum.SEND_BACK_1200.id, "装备清退", null, ".", billEntity.getId(), BusinessEnum.SEND_BACK.id, unitId, 1, null, integers));
//
// if (!falg){
// task=taskService.moveToSpecial(task,StatusEnum.SEND_BACK_1201,startUserId);
// }
// return task;
//
// }
//
//
// /**
// * 按照需求返回单位和区域的映射关系
// * @param type 0:单位-市和省 1:单位-区
// * @return
// */
// private HashMap<String,Area> unitToArea(Integer type){
//
// /*
// 查询所有的区域
// */
// HashMap<Integer,Area> areaHashMap = new HashMap<>();
// areaDao.findAll().forEach(area -> areaHashMap.put(area.getId(),area));
//
// /*
// 查询所有单位
// */
// List<Units> units = unitsDao.findByIdDel(0);
//
// /*
// 单位和区域的映射关系
// */
// HashMap<String,Area> unitToArea = new HashMap<>();
//
// for (Units unit:units) {
// /*
// 根据等级判断单位的区域
// */
// Integer level = unit.getLevel();
// Area localArea = areaHashMap.get(unit.getAreaId());
// if(type == 0 && level>2){
// /*
// 单位与市的映射关系,区级设备需要找到上级区域;
// */
// Area fatherArea = areaHashMap.get(localArea.getFatherId());
// unitToArea.put(unit.getName(),fatherArea);
// }else {
// unitToArea.put(unit.getName(),localArea);
// }
// }
// return unitToArea;
// }
//
//
// /**
// * 修改统计内容 有提交需要修改提交状态
// */
// private SendBackVo updateStatistical(List<Integer> idList,String areaName,SendBackVo sendBack){
//
// HashMap<String,HashMap<String,StatisticalVo>> list= sendBack.getMap();
// HashMap<String,String> map=new HashMap<>();
// idList.forEach(
// id -> {
// DeviceLibrary deviceLibrary= deviceLibraryService.getOne(id);
// map.put(deviceLibrary.getModel(),"");
// }
// );
//
// for (String name:map.keySet()){
// StatisticalVo statisticalVo = list.get(name).get(areaName);
// statisticalVo.setStatus(3);
// }
// return sendBack;
// }
//
// /**
// * 统计表
// */
// private SendBackVo newStatistical(List<Integer> idList,Integer type,SendBackVo sendBack,boolean first){
//
// HashMap<String,HashMap<String,StatisticalVo>> list;
// List<Area> areas= areaDao.findAllByFatherId(null);
//
// if(sendBack == null){
// list = new HashMap<>();
// }else {
// list = sendBack.getMap();
// }
// /*
// 映射表 0:单位-市 1:单位-区县
// String 单位名称 Area 区域对象
// */
// HashMap<String, Area> unitToArea = unitToArea(type);
//
// //根据所有装备id集合-获取装备集合
// List<DeviceLibrary> deviceList = deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList);
// /*
// 未在库装备
// */
// List<DeviceLibrary> unDevice = new ArrayList<>();
//
//
// List<String> modelList = new ArrayList<>();
// List<String> areaList = new ArrayList<>();
// for (DeviceLibrary DeviceLibrary:deviceList) {
// //装备型号
// String model = DeviceLibrary.getModel();
// if(!modelList.contains(model)){
// modelList.add(model);
// }
// String areaName = unitToArea.get(DeviceLibrary.getOwnUnit()).getName();
// if(!areaList.contains(areaName)){
// areaList.add(areaName);
// }
// if(!DeviceLibrary.getOwnUnit().equals(DeviceLibrary.getLocationUnit())){
// unDevice.add(DeviceLibrary);
// }
//
// }
//
// //类型-(区域,统计)
// HashMap<String,HashMap<String,StatisticalVo>> newList = new HashMap<>();
//
// //延迟状态
// int delayStatus = 1;
//
// if(sendBack == null){
// /*
// 生成一张新的空表
// */
// for (String model:modelList) {
// HashMap<String,StatisticalVo> areaMap = new HashMap<>();
// for (String area:areaList) {
// areaMap.put(area,new StatisticalVo());
// }
// areaMap.put("总数",new StatisticalVo());
// newList.put(model,areaMap);
// }
// }else {
// /*
// 初始化旧的表格
// */
// HashMap<String, HashMap<String, StatisticalVo>> map = sendBack.getMap();
// Collection<HashMap<String, StatisticalVo>> values = map.values();
// values.forEach(value -> value.values().forEach(v -> v.setValCount(0)));
// newList = map;
// /*
// 判断是否延期
// */
// if(new Date().getTime() > sendBack.getTime().getTime()){
// delayStatus = 2;
// }
// }
//
// /*
// 存放区域所对应的idList
// */
// HashMap<String,List<Integer>> areaIdList = new HashMap<>();
//
// /*
// 存放型号所对应的idList
// */
// HashMap<String,List<Integer>> modelIdList = new HashMap<>();
//
//
// /*
// 向表中填数据
// */
// for (DeviceLibrary d : deviceList) {
// String model = d.getModel();
//
// String areaName = unitToArea.get(d.getOwnUnit()).getName();
// /*
// 按型号归类
// */
// List<Integer> modelIds = modelIdList.getOrDefault(model, new ArrayList<>());
// modelIds.add(d.getId());
// modelIdList.put(model,modelIds);
//
// /*
// 按区域归类
// */
// List<Integer> areaIds = areaIdList.getOrDefault(areaName, new ArrayList<>());
// areaIds.add(d.getId());
// areaIdList.put(areaName,areaIds);
//
//
// StatisticalVo statisticalVo = newList.get(model).get(areaName);
//
// if (statisticalVo!=null) {
// statisticalVo.setValCount(statisticalVo.getValCount() + 1);
//
// if (first) {
// statisticalVo.setAllCount(statisticalVo.getAllCount() + 1);
// } else {
// statisticalVo.setAllCount(list.get(model).get(areaName).getAllCount());
// }
//
// statisticalVo.getDeviceIdList().add(d.getId());
// }
// /*
// 存放总数和名字
// */
// if(first){
// StatisticalVo all = newList.get(model).getOrDefault("总数",new StatisticalVo());
// all.setAllCount(all.getAllCount() + 1);
// newList.get(model).put("总数",all);
//
// StatisticalVo name = newList.get(model).getOrDefault("名称",new StatisticalVo());
// name.setName(d.getName());
// newList.get(model).put("名称",name);
//
// StatisticalVo deviceModel = newList.get(model).getOrDefault("型号",new StatisticalVo());
// deviceModel.setName(model);
// newList.get(model).put("型号",deviceModel);
// }
// }
//
//
// /*
// 返回的对象
// */
//
//
// /*
// 计算状态 判断是否可以办结
// */
// int allStatus = 0;
//
// Set<String> strings = newList.keySet();
// Set<String> models =new HashSet<>();
// // List<HashMap<String, StatisticalVo>> dataList = new ArrayList<>();
// for (String s:strings) {
// HashMap<String, StatisticalVo> stringStatisticalVoHashMap = newList.get(s);
// List<StatisticalVo> statisticalVos = new ArrayList<>(stringStatisticalVoHashMap.values());
// if (stringStatisticalVoHashMap.containsKey(areas.get(0).getName())){
// models.add(s);
// }
// for (StatisticalVo statisticalVo:statisticalVos) {
// Integer status = statisticalVo.status(delayStatus);
// if(status == 1){
// allStatus = 1;
// }
// }
// // dataList.add(stringStatisticalVoHashMap);
// }
// if (type==0) {
// HashMap<String, HashMap<String, StatisticalVo>> finalNewList = newList;
// models.forEach(i -> {
// HashMap<String, StatisticalVo> stringStatisticalVoHashMap = finalNewList.get(i);
// StatisticalVo statisticalVo = stringStatisticalVoHashMap.get(areas.get(0).getName());
// statisticalVo.setStatus(3);
// statisticalVo.setValCount(statisticalVo.getAllCount());
// stringStatisticalVoHashMap.put(areas.get(0).getName(), statisticalVo);
// });
// }
// if (sendBack==null) {
// SendBackVo sendBackVo = new SendBackVo();
// sendBackVo.setHeader(areaList);
// sendBackVo.setDeviceIdList(idList);
// sendBackVo.setUnDevice(unDevice);
// sendBackVo.setAreaToIds(areaIdList);
// sendBackVo.setModelToIds(modelIdList);
// sendBackVo.setStatus(allStatus);
// sendBackVo.setMap(newList);
// return sendBackVo;
// }else {
// sendBack.setStatus(allStatus);
// sendBack.setMap(newList);
// return sendBack;
// }
//
// }
//
//
// /*
// 计算各单位的清退装备,市的清退装备包括市本级和下属单位
// */
// private HashMap<Integer,StringBuffer> addTaskById(List<Integer> idList,Integer parentId,Integer userId,Date time,String name){
//
// List<DeviceLibrary> deviceList = deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList);
//
// /*
// 单位名-市级的区域
// */
// HashMap<String, Area> unitToArea = unitToArea(0);
//
// /*
// 存放各单位需清退的装备id,用于生成task
// */
// HashMap<Integer,StringBuffer> unitDeviceIds = new HashMap<>();
//
//// HashMap<Integer,List<DeviceLibrary>> unitDevices=new HashMap<>();
//
// //区县
// HashMap<Integer,Integer> county=new HashMap<>();
//
// //市
// HashMap<Integer,Integer> city=new HashMap<>();
//
// //市不在库装备存储
// HashMap<Integer,List<Integer>> cityNoLibrary=new HashMap<>();
//
// //区县不在库装备存储
// HashMap<Integer,List<Integer>> countyNoLibrary=new HashMap<>();
// /*
// 存放各单位的装备集合
// */
// HashMap<Integer,List<Integer>> unitDevices = new HashMap<>();
//
// for (DeviceLibrary device:deviceList) {
// Units unit = unitsDao.findByName(device.getOwnUnit());
// Integer level = unit.getLevel();
//
// /*
// 省级装备不参与分类
// */
// if(level == 1){
// List<Integer> deviceIds = unitDevices.getOrDefault(unit.getUnitId(), new ArrayList<>());
// deviceIds.add(device.getId());
// unitDevices.put(0,deviceIds);
// }else if (level == 2) {
// List<Integer> deviceIds = unitDevices.getOrDefault(unit.getUnitId(), new ArrayList<>());
// deviceIds.add(device.getId());
// unitDevices.put(unit.getUnitId(), deviceIds);
//
// if (!device.getOwnUnit().equals(device.getLocationUnit())) {
// List<Integer> noLibrary = cityNoLibrary.getOrDefault(unit.getUnitId(), new ArrayList<>());
// noLibrary.add(device.getId());
// cityNoLibrary.put(unit.getUnitId(), noLibrary);
// }
// /*
// 将装备加入所属的单位
// */
// StringBuffer localIds = unitDeviceIds.getOrDefault(unit.getUnitId(), new StringBuffer());
// localIds.append("x").append(device.getId());
// unitDeviceIds.put(unit.getUnitId(), localIds);
// city.put(unit.getUnitId(),0);
// }else if(level == 3){
//
// List<Integer> deviceIds = unitDevices.getOrDefault(unit.getUnitId(), new ArrayList<>());
// deviceIds.add(device.getId());
// unitDevices.put(unit.getUnitId(), deviceIds);
//
// if (!device.getOwnUnit().equals(device.getLocationUnit())) {
// List<Integer> noLibrary = countyNoLibrary.getOrDefault(unit.getUnitId(), new ArrayList<>());
// noLibrary.add(device.getId());
// countyNoLibrary.put(unit.getUnitId(), noLibrary);
// }
//
// /*
// 将装备加入所属的单位
// */
// StringBuffer localIds = unitDeviceIds.getOrDefault(unit.getUnitId(), new StringBuffer());
// localIds.append("x").append(device.getId());
// unitDeviceIds.put(unit.getUnitId(), localIds);
// county.put(unit.getUnitId(),0);
// /*
// 所属市
// */
// Area parentArea = unitToArea.get(unit.getName());
// Units parentUnit = unitsDao.findByAreaIdAndLevel(parentArea.getId(), 2);
// /*
// 将装备加入上属的市
// */
// StringBuffer parentIds = unitDeviceIds.getOrDefault(parentUnit.getUnitId(),new StringBuffer());
// parentIds.append("x").append(device.getId());
// unitDeviceIds.put(parentUnit.getUnitId(),parentIds);
// if (city.containsKey(parentUnit.getUnitId())){
// city.put(parentUnit.getUnitId(),1);
// }else {
// city.put(parentUnit.getUnitId(),2);
// }
// }
//
// }
//
//// Set<Integer> keySet = unitDeviceIds.keySet();
//
// HashMap<Integer,Integer> unitsAndTaskid=new HashMap<>();
// for (Integer key:city.keySet()){
// StringBuffer ids = unitDeviceIds.get(key);
// if (city.get(key)==1) {
// SendBackVo sendBack = newStatistical(stringToList(ids.toString()), 1,null,true);
// sendBack.setName(name);
// sendBack.setTime(time);
// sendBack.setDeviceIdList(null);
// TaskBto taskBto=addTask(parentId, JSON.toJSONString(sendBack), ids.toString(), key, userId, time);
// unitsAndTaskid.put(key,taskBto.getId());
// }else if(city.get(key)==2){
// TaskBto taskBto= addTask(parentId, null, ids.toString(), key, userId, time);
//// TaskBto taskBto= addTask1203(parentId, null, ids.toString(), key, userId, time);
// unitsAndTaskid.put(key,taskBto.getId());
//// if (cityNoLibrary.containsKey(key)){
//// addExceptionTask(taskBto.getId(),cityNoLibrary.get(key),key,userId,time);
//// }
// }else {
// TaskBto taskBto= addTask1203(parentId, null, ids.toString(), key, userId, time);
// unitsAndTaskid.put(key,taskBto.getId());
// if (cityNoLibrary.containsKey(key)){
// addExceptionTask(taskBto.getId(),cityNoLibrary.get(key),key,userId,time);
// }
// }
// }
//
// for (Integer key:county.keySet()){
// StringBuffer ids = unitDeviceIds.get(key);
// Units units = unitsDao.findById(key).get();
// Area parentArea = unitToArea.get(units.getName());
// Units parentUnit = unitsDao.findByAreaIdAndLevel(parentArea.getId(), 2);
// TaskBto taskBto= addTask1203(unitsAndTaskid.get(parentUnit.getUnitId()), null, ids.toString(), key, userId, time);
//
// if (countyNoLibrary.containsKey(key)){
// addExceptionTask(taskBto.getId(),countyNoLibrary.get(key),key,userId,time);
// }
//
// }
//
// return unitDeviceIds;
// }
//
//
// /*
// x1x2x1 -> [1,2,3] 装备id组合字段 转换成id集合
// */
// private List<Integer> stringToList(String idString){
// String[] ids = idString.split("x");
// List<String> idStringList = Arrays.asList(ids);
// List<String> idListString = idStringList.stream().filter(list2->!list2.equals("")).collect(Collectors.toList());
// List<Integer> idList = idListString.stream().map(Integer::parseInt).collect(Collectors.toList());
// return idList;
// }
//
// /*
// 区域名对应的任务id,方便进入下一级
// */
// private HashMap<String,Integer> areaToTask(Units unit,TaskBto taskBto){
// HashMap<String,Integer> areaToTaskId = new HashMap<>();
// List<TaskBto> kidTask = new ArrayList<>();
// List<TaskBto> qkidTask =new ArrayList<>();
// if(unit.getLevel() == 1){
// /*
// 省级的业务详情
// */
// kidTask = taskDao.findTaskEntitiesByParentTaskId(taskBto.getId()).stream().map(Task::parse2Bto).collect(Collectors.toList());
//
// kidTask.forEach(
// taskBto1 -> {
// qkidTask.addAll(taskDao.findTaskEntitiesByParentTaskId(taskBto.getId()).stream().map(Task::parse2Bto).collect(Collectors.toList()));
// }
// );
// }else if(unit.getLevel() == 2){
// /*
// 市级的业务详情
// */
// kidTask = taskDao.findTaskEntitiesByParentTaskId(taskBto.getParentTaskId()).stream().map(Task::parse2Bto).collect(Collectors.toList());
// }
// /*
// 区域名和任务id的映射,方便进入下一级
// */
// for (TaskBto t:kidTask) {
// Integer ownUnit = t.getOwnUnit();
// Units units = unitsDao.findById(ownUnit).get();
// Area area = areaDao.findById(units.getAreaId()).get();
// areaToTaskId.put(area.getName(),t.getId());
// }
//
// for (TaskBto t:qkidTask) {
// Integer ownUnit = t.getOwnUnit();
// Units units = unitsDao.findById(ownUnit).get();
// Area area = areaDao.findById(units.getAreaId()).get();
// areaToTaskId.put(area.getName(),t.getId());
// }
//
// return areaToTaskId;
// }
//
//}
...@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论