commit
b00a14b814
@ -0,0 +1,84 @@
|
|||||||
|
package com.imitate.web.module.simulation.controller;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.imitate.common.util.BasicController;
|
||||||
|
import com.imitate.common.util.R;
|
||||||
|
import com.imitate.web.module.simulation.service.NetGlqService;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONArray;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Api(value = "网络隔离器配置", hidden = true)
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/netGlq")
|
||||||
|
public class NetGlqController extends BasicController{
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private NetGlqService netGlqService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网络隔离器配置-获取配置信息
|
||||||
|
* @param type 1.服务器列表信息 2.网络配置信息 3.安全策略信息 4.管理配置信息 5.VPN策略信息 6.防火墙策略信息 7.日志记录信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "网络隔离器配置")
|
||||||
|
@RequestMapping(path = "getGlqInfo")
|
||||||
|
public R getGlqInfo(Integer type){
|
||||||
|
log.info("[start]获取隔离器配置信息,type:{}",type);
|
||||||
|
JSONArray jsonArray = netGlqService.glqInfo(type);
|
||||||
|
log.info("[end]获取隔离器配置信息,return:{}",jsonArray);
|
||||||
|
return R.ok().setData(jsonArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网络隔离器配置- 远程文件配置 - 发送数据
|
||||||
|
* @param type 类型 1 服务列表 2 网络参数 3 安全策略 4 管理配置 5 vpn策略
|
||||||
|
* @param jsonStr json数组
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "远程文件配置")
|
||||||
|
@RequestMapping(path = "remoteFileConfiSendData")
|
||||||
|
public R remoteFileConfiSendData(Integer type,String jsonStr){
|
||||||
|
log.info("[start]远程文件配置,type:{},jsonStr:{}",type,jsonStr);
|
||||||
|
netGlqService.sendData(type,jsonStr);
|
||||||
|
log.info("[end]远程文件配置,return:");
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清空信息
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "清空信息")
|
||||||
|
@RequestMapping(path = "remoteFileConfigClean")
|
||||||
|
public R remoteFileConfigClean(Integer type){
|
||||||
|
log.info("[start]远程文件配置,type:{}",type);
|
||||||
|
netGlqService.cleanRemoteConfig(type);
|
||||||
|
log.info("[end]远程文件配置");
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,63 @@
|
|||||||
|
package com.imitate.web.module.simulation.controller;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.imitate.common.util.BasicController;
|
||||||
|
import com.imitate.common.util.R;
|
||||||
|
import com.imitate.web.module.simulation.service.ParameterSetService;
|
||||||
|
import com.imitate.web.params.DataTerminalParam;
|
||||||
|
import com.imitate.web.params.ParameterSetParam;
|
||||||
|
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Api(value = "二期参数设置", hidden = true)
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/parameterSet")
|
||||||
|
public class ParameterSetController extends BasicController{
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ParameterSetService parameterSetService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载数据
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "参数设置", httpMethod = "POST")
|
||||||
|
@RequestMapping(path = "setParameter", method = RequestMethod.POST)
|
||||||
|
public R setParameter(@RequestBody @Valid ParameterSetParam param, BindingResult bindingResult){
|
||||||
|
log.info("[start]参数设置,param:{}",param);
|
||||||
|
if(bindingResult.hasErrors()){
|
||||||
|
return actionResultWithBindingResult(ErrorCodeEnum.BIND_EXCEPTION,bindingResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parameterSetService.updateOrAdd(param.getParameterSet())>0){
|
||||||
|
return R.ok().setData(dataTerminalParam.getDataTerminal());
|
||||||
|
}else {
|
||||||
|
return R.error();
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("[end]参数设置,return");
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,130 @@
|
|||||||
|
package com.imitate.web.module.simulation.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.imitate.common.enums.ErrorCodeEnum;
|
||||||
|
import com.imitate.common.util.BasicController;
|
||||||
|
import com.imitate.common.util.R;
|
||||||
|
import com.imitate.web.module.simulation.service.SecretFormatService;
|
||||||
|
import com.imitate.web.params.SecretAskParam;
|
||||||
|
import com.imitate.web.params.SecretFormatParam;
|
||||||
|
import com.imitate.web.params.SecretImportParam;
|
||||||
|
import com.imitate.web.persistence.beans.SecretFormat;
|
||||||
|
import com.imitate.web.persistence.beans.SecretImport;
|
||||||
|
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Api(value = "秘钥体管理", hidden = true)
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/secretFormat")
|
||||||
|
public class SecretFormatController extends BasicController{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SecretFormatService secretFormatService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation(value = "密钥体格式导入")
|
||||||
|
@RequestMapping(path = "secretFormatImport")
|
||||||
|
public R secretFormatImport(@RequestParam("file") MultipartFile file){
|
||||||
|
log.info("[start]密钥体格式导入");
|
||||||
|
String fileName = file.getOriginalFilename();
|
||||||
|
secretFormatService.importSecretFormat(fileName);
|
||||||
|
log.info("[end]密钥体格式导入,return:");
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation(value = "密钥体发布")
|
||||||
|
@RequestMapping(path = "secretPublisher")
|
||||||
|
public R secretPublisher(Integer id){
|
||||||
|
log.info("[start]密钥体发布,id:{}",id);
|
||||||
|
secretFormatService.publisherSecret(id);
|
||||||
|
log.info("[end]密钥体发布");
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation(value = "密钥提格式列表")
|
||||||
|
@RequestMapping(path = "secretFormatList",method = RequestMethod.GET)
|
||||||
|
public R secretFormatList(@RequestBody @Valid SecretFormatParam param, BindingResult bindingResult){
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
return actionResultWithBindingResult(ErrorCodeEnum.BIND_EXCEPTION, bindingResult);
|
||||||
|
}
|
||||||
|
log.info("[start]密钥提格式列表,param:{}",param);
|
||||||
|
PageInfo<SecretFormat> pages = secretFormatService.pageList(param);
|
||||||
|
log.info("[end]密钥提格式列表,pages:{}",pages);
|
||||||
|
return R.ok().setData(pages);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation(value = "密钥体申请")
|
||||||
|
@RequestMapping(path = "addSecretAsk",method = RequestMethod.POST)
|
||||||
|
public R addSecretAsk(@RequestBody @Valid SecretAskParam param, BindingResult bindingResult){
|
||||||
|
if(bindingResult.hasErrors()){
|
||||||
|
return actionResultWithBindingResult(ErrorCodeEnum.BIND_EXCEPTION, bindingResult);
|
||||||
|
}
|
||||||
|
log.info("[start]钥体申请,param:{}",param);
|
||||||
|
secretFormatService.addSecretAsk(param);
|
||||||
|
log.info("[end]密钥体申请");
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation(value = "密钥体导入")
|
||||||
|
@RequestMapping(path = "secretBodyImport")
|
||||||
|
public R secretBodyImport(String productNumber,@RequestParam("file") MultipartFile file){
|
||||||
|
log.info("[start] 密钥体导入,productNumber:{}, file:{}",productNumber,file);
|
||||||
|
String fileName = file.getOriginalFilename();
|
||||||
|
secretFormatService.importSecretBody(productNumber,fileName);
|
||||||
|
log.info("[end] 密钥体导入");
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation(value = "密钥体列表")
|
||||||
|
@RequestMapping(path = "secretList",method = RequestMethod.GET)
|
||||||
|
public R secretList(@RequestBody @Valid SecretImportParam param, BindingResult bindingResult){
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
return actionResultWithBindingResult(ErrorCodeEnum.BIND_EXCEPTION, bindingResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("[start]密钥提列表,param:{}",param);
|
||||||
|
PageInfo<SecretImport> pages = secretFormatService.secretList(param);
|
||||||
|
log.info("[end]密钥提列表,pages:{}",pages);
|
||||||
|
return R.ok().setData(pages);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改密钥体状态 密钥体删除 还原 清理")
|
||||||
|
@RequestMapping(path = "updateSecret",method = RequestMethod.POST)
|
||||||
|
public R updateSecret(Integer type,Integer id){
|
||||||
|
log.info("[start]修改密钥体状态,type:{}, id:{}", type, id);
|
||||||
|
secretFormatService.updateStatus(type, id);
|
||||||
|
log.info("[end]修改密钥体状态");
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,118 @@
|
|||||||
|
package com.imitate.web.module.simulation.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import com.imitate.common.util.R;
|
||||||
|
import com.imitate.web.module.simulation.service.SecretInitService;
|
||||||
|
import com.imitate.web.persistence.beans.SecretInit;
|
||||||
|
import ch.qos.logback.classic.BasicConfigurator;
|
||||||
|
import cn.hutool.json.JSONArray;
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Api(value = "二期密码机初装", hidden = true)
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/secretInit")
|
||||||
|
public class SecretInitController extends BasicConfigurator{
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SecretInitService secretInitService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数设置-加载数据
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "加载数据", httpMethod = "POST")
|
||||||
|
@RequestMapping(path = "loadData", method = RequestMethod.POST)
|
||||||
|
public R loadData(@RequestParam("file") MultipartFile file){
|
||||||
|
log.info("[start]加载数据");
|
||||||
|
// 获取上传文件名
|
||||||
|
String fileName = file.getOriginalFilename();
|
||||||
|
log.info("上传文件名: {}", fileName);
|
||||||
|
SecretInit secretInit = secretInitService.dataLoadding(fileName);
|
||||||
|
log.info("[end]加载数据,return:{}", secretInit);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation(value = "发送数据", httpMethod = "POST")
|
||||||
|
@RequestMapping(path = "sendData", method = RequestMethod.POST)
|
||||||
|
public R sendData(){
|
||||||
|
log.info("[start]发送数据");
|
||||||
|
secretInitService.sendData();
|
||||||
|
log.info("[end]发送数据");
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清空信息
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "清空信息")
|
||||||
|
@RequestMapping(path = "cleanInfo", method = RequestMethod.GET)
|
||||||
|
public R cleanInfo(){
|
||||||
|
log.info("[start]清空信息");
|
||||||
|
secretInitService.clean();
|
||||||
|
log.info("[end]清空信息");
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送命令
|
||||||
|
* @param type 1 密钥销毁 2 密钥遥毙 3 密钥机遥毙
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "发送命令")
|
||||||
|
@RequestMapping(path = "sendCommand", method = RequestMethod.GET)
|
||||||
|
public R sendCommand(Integer type){
|
||||||
|
log.info("[start]发送命令,type:{}",type);
|
||||||
|
secretInitService.secretSendCmd(type);
|
||||||
|
log.info("[end]发送命令");
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态查询
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "状态查询")
|
||||||
|
@RequestMapping(path = "getStatus",method = RequestMethod.GET)
|
||||||
|
public R getStatus(){
|
||||||
|
log.info("[start]状态查询");
|
||||||
|
SecretInit secretInit = secretInitService.secretInfo();
|
||||||
|
log.info("[end]状态查询,return:{}",secretInit);
|
||||||
|
return R.ok().setData(secretInit);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,141 @@
|
|||||||
|
package com.imitate.web.module.simulation.service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.imitate.web.persistence.beans.RemoteFileConfig;
|
||||||
|
import com.imitate.web.persistence.mapper.RemoteFileConfigMapper;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONArray;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class NetGlqService {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RemoteFileConfigMapper remoteFileConfigMapper;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网络隔离器信息
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public JSONArray glqInfo(Integer type) {
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
//服务器列表信息
|
||||||
|
case 1:
|
||||||
|
break;
|
||||||
|
//网络配置信息
|
||||||
|
case 2:
|
||||||
|
break;
|
||||||
|
//安全策略信息
|
||||||
|
case 3:
|
||||||
|
break;
|
||||||
|
//管理配置信息
|
||||||
|
case 4:
|
||||||
|
break;
|
||||||
|
//VPN策略信息
|
||||||
|
case 5:
|
||||||
|
break;
|
||||||
|
//防火墙策略信息
|
||||||
|
case 6:
|
||||||
|
break;
|
||||||
|
//日志记录信息
|
||||||
|
case 7:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 远程文件配置- 发送数据
|
||||||
|
* @param type
|
||||||
|
* @param jsonStr
|
||||||
|
*/
|
||||||
|
public void sendData(Integer type, String jsonStr) {
|
||||||
|
List<RemoteFileConfig> list = remoteFileConfigMapper.selectAll();
|
||||||
|
RemoteFileConfig remoteFileConfig = new RemoteFileConfig();
|
||||||
|
if(list.size() > 0){
|
||||||
|
remoteFileConfig = list.get(0);
|
||||||
|
}else{
|
||||||
|
remoteFileConfig.setId(1L);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
//服务器列表信息
|
||||||
|
case 1:
|
||||||
|
remoteFileConfig.setServiceList(jsonStr);
|
||||||
|
break;
|
||||||
|
//网络配置信息
|
||||||
|
case 2:
|
||||||
|
remoteFileConfig.setNetParam(jsonStr);
|
||||||
|
break;
|
||||||
|
//安全策略信息
|
||||||
|
case 3:
|
||||||
|
remoteFileConfig.setSafeStrategy(jsonStr);
|
||||||
|
break;
|
||||||
|
//管理配置信息
|
||||||
|
case 4:
|
||||||
|
remoteFileConfig.setManagerStrategy(jsonStr);
|
||||||
|
break;
|
||||||
|
//VPN策略信息
|
||||||
|
case 5:
|
||||||
|
remoteFileConfig.setVpnStrategy(jsonStr);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
remoteFileConfig.setUpdateTime(LocalDateTime.now());
|
||||||
|
remoteFileConfigMapper.updateByPrimaryKeySelective(remoteFileConfig);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清空远程配置信息
|
||||||
|
* @param type
|
||||||
|
*/
|
||||||
|
public void cleanRemoteConfig(Integer type) {
|
||||||
|
List<RemoteFileConfig> list = remoteFileConfigMapper.selectAll();
|
||||||
|
RemoteFileConfig remoteFileConfig = new RemoteFileConfig();
|
||||||
|
if(list.size() > 0){
|
||||||
|
remoteFileConfig = list.get(0);
|
||||||
|
switch (type) {
|
||||||
|
//服务器列表信息
|
||||||
|
case 1:
|
||||||
|
remoteFileConfig.setServiceList(null);
|
||||||
|
break;
|
||||||
|
//网络配置信息
|
||||||
|
case 2:
|
||||||
|
remoteFileConfig.setNetParam(null);
|
||||||
|
break;
|
||||||
|
//安全策略信息
|
||||||
|
case 3:
|
||||||
|
remoteFileConfig.setSafeStrategy(null);
|
||||||
|
break;
|
||||||
|
//管理配置信息
|
||||||
|
case 4:
|
||||||
|
remoteFileConfig.setManagerStrategy(null);
|
||||||
|
break;
|
||||||
|
//VPN策略信息
|
||||||
|
case 5:
|
||||||
|
remoteFileConfig.setVpnStrategy(null);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
remoteFileConfig.setUpdateTime(LocalDateTime.now());
|
||||||
|
remoteFileConfigMapper.updateByPrimaryKeySelective(remoteFileConfig);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
package com.imitate.web.module.simulation.service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.aliyuncs.utils.StringUtils;
|
||||||
|
import com.imitate.web.persistence.beans.ParameterSet;
|
||||||
|
import com.imitate.web.persistence.mapper.ParameterSetMapper;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ParameterSetService {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ParameterSetMapper parameterSetMapper;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public ParameterSet updateOrAdd(ParameterSet parameterSet){
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
if (null == parameterSet.getId()){
|
||||||
|
if(StringUtils.isEmpty(parameterSet.getIpAddress())){
|
||||||
|
parameterSet.setIpAddress("114.114.114.114");
|
||||||
|
}
|
||||||
|
parameterSet.setCreateTime(now);
|
||||||
|
return parameterSetMapper.insertSelective(dataTerminal);
|
||||||
|
}else {
|
||||||
|
parameterSet.setUpdateTime(now);
|
||||||
|
return parameterSetMapper.updateByPrimaryKeySelective(parameterSet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,190 @@
|
|||||||
|
package com.imitate.web.module.simulation.service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.imitate.web.params.SecretAskParam;
|
||||||
|
import com.imitate.web.params.SecretFormatParam;
|
||||||
|
import com.imitate.web.params.SecretImportParam;
|
||||||
|
import com.imitate.web.persistence.beans.SecretFormat;
|
||||||
|
import com.imitate.web.persistence.beans.SecretImport;
|
||||||
|
import com.imitate.web.persistence.mapper.SecretAskMapper;
|
||||||
|
import com.imitate.web.persistence.mapper.SecretFormatMapper;
|
||||||
|
import com.imitate.web.persistence.mapper.SecretImportMapper;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SecretFormatService {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SecretFormatMapper secretFormatMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SecretAskMapper secretAskMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SecretImportMapper secretImportMapper;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密钥体导入
|
||||||
|
*/
|
||||||
|
public void importSecretFormat(String fileName) {
|
||||||
|
//1 . 每次导入先清空表
|
||||||
|
secretFormatMapper.deleteAll();
|
||||||
|
//2. 判断导入文件的正确性,模拟导入文件
|
||||||
|
if(fileName.equals("aaaaa.zip")){
|
||||||
|
List<SecretFormat> list = new ArrayList<>();
|
||||||
|
list.add(new SecretFormat("AAA111","载体名称01","三寸","AAA.txt","管理系统名称0-1","管理系统标识","产品名称","未发布","软盘","在线向密钥编制分系统"));
|
||||||
|
list.add(new SecretFormat("AAA222","载体名称02","六寸","BBB.txt","管理系统名称0-2","管理系统标识","产品名称","未发布","移动盘","离线向密钥编制分系统"));
|
||||||
|
list.add(new SecretFormat("AAA333","载体名称02","八寸","CCC.txt","管理系统名称0-3","管理系统标识","产品名称","未发布","光盘","在线向下级管理系统"));
|
||||||
|
secretFormatMapper.insertList(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新已发布状态
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
public void publisherSecret(Integer id){
|
||||||
|
SecretFormat secretFormat = secretFormatMapper.selectByPrimaryKey(id);
|
||||||
|
if(secretFormat != null){
|
||||||
|
secretFormat.setCurrentStatus("已发布");
|
||||||
|
secretFormatMapper.updateByPrimaryKeySelective(secretFormat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取密钥列表
|
||||||
|
*/
|
||||||
|
public PageInfo<SecretFormat> pageList(SecretFormatParam param) {
|
||||||
|
PageHelper.startPage(param.getPageNumber(), param.getPageSize());
|
||||||
|
List<SecretFormat> list = secretFormatMapper.selectAllByParam(param);
|
||||||
|
return new PageInfo<>(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密钥体申请
|
||||||
|
* @param param
|
||||||
|
*/
|
||||||
|
public void addSecretAsk(SecretAskParam param){
|
||||||
|
secretAskMapper.insertSelective(param.getSecretAsk());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密钥体导入
|
||||||
|
* @param productNumber
|
||||||
|
* @param fileName
|
||||||
|
*/
|
||||||
|
public void importSecretBody(String productNumber, String fileName) {
|
||||||
|
// 1 每次导入清空历史数据
|
||||||
|
secretImportMapper.deleteAll();
|
||||||
|
|
||||||
|
// 2 判断导入文件的正确性,模拟导入文件
|
||||||
|
if(fileName.equals("aaaa.zip")){
|
||||||
|
List<SecretImport> list = new ArrayList<>();
|
||||||
|
SecretImport secretImport = new SecretImport();
|
||||||
|
secretImport.setProductName("AAA111");
|
||||||
|
secretImport.setProductNum("8549电");
|
||||||
|
secretImport.setCarrierType("移动盘");
|
||||||
|
secretImport.setApplyNum(33);
|
||||||
|
secretImport.setApplyModel("三寸");
|
||||||
|
secretImport.setNumber(99);
|
||||||
|
secretImport.setSource("离线来自111系统");
|
||||||
|
secretImport.setCurrentStatus("未使用");
|
||||||
|
secretImport.setIsClean(0);
|
||||||
|
secretImport.setImportTime(LocalDateTime.now());
|
||||||
|
|
||||||
|
SecretImport secretImport1 = new SecretImport();
|
||||||
|
secretImport1.setProductName("AAA111");
|
||||||
|
secretImport1.setProductNum("8549电");
|
||||||
|
secretImport1.setCarrierType("软盘");
|
||||||
|
secretImport1.setApplyNum(33);
|
||||||
|
secretImport1.setApplyModel("三寸");
|
||||||
|
secretImport1.setNumber(99);
|
||||||
|
secretImport1.setSource("离线来自111系统");
|
||||||
|
secretImport1.setCurrentStatus("使用");
|
||||||
|
secretImport1.setIsClean(0);
|
||||||
|
secretImport1.setImportTime(LocalDateTime.now());
|
||||||
|
|
||||||
|
SecretImport secretImport2 = new SecretImport();
|
||||||
|
secretImport2.setProductName("AAA111");
|
||||||
|
secretImport2.setProductNum("8549电");
|
||||||
|
secretImport2.setCarrierType("移动盘");
|
||||||
|
secretImport2.setApplyNum(33);
|
||||||
|
secretImport2.setApplyModel("三寸");
|
||||||
|
secretImport2.setNumber(99);
|
||||||
|
secretImport2.setSource("离线来自111系统");
|
||||||
|
secretImport2.setCurrentStatus("未使用");
|
||||||
|
secretImport2.setIsClean(0);
|
||||||
|
secretImport2.setImportTime(LocalDateTime.now());
|
||||||
|
|
||||||
|
|
||||||
|
list.add(secretImport);
|
||||||
|
list.add(secretImport1);
|
||||||
|
list.add(secretImport2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密钥体列表
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public PageInfo<SecretImport> secretList(SecretImportParam param) {
|
||||||
|
PageHelper.startPage(param.getPageNumber(), param.getPageSize());
|
||||||
|
List<SecretImport> list = secretImportMapper.selectAllByParam(param);
|
||||||
|
return new PageInfo<>(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改状态
|
||||||
|
* @param type 1.删除 2. 还原 3.清理
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
public void updateStatus(Integer type,Integer id){
|
||||||
|
SecretImport secretImport;
|
||||||
|
switch (type) {
|
||||||
|
case 1:
|
||||||
|
secretImportMapper.deleteByExample(id);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
secretImport = secretImportMapper.selectByPrimaryKey(id);
|
||||||
|
if(secretImport != null){
|
||||||
|
secretImport.setIsClean(0);
|
||||||
|
secretImportMapper.updateByPrimaryKeySelective(secretImport);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
secretImport = secretImportMapper.selectByPrimaryKey(id);
|
||||||
|
if(secretImport != null){
|
||||||
|
secretImport.setIsClean(1);
|
||||||
|
secretImportMapper.updateByPrimaryKeySelective(secretImport);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,124 @@
|
|||||||
|
package com.imitate.web.module.simulation.service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.imitate.web.persistence.beans.Device;
|
||||||
|
import com.imitate.web.persistence.beans.DeviceInit;
|
||||||
|
import com.imitate.web.persistence.beans.SecretInit;
|
||||||
|
import com.imitate.web.persistence.mapper.SecretInitMapper;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONArray;
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import tk.mybatis.mapper.entity.Example;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SecretInitService {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SecretInitMapper secretInitMapper;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据加载
|
||||||
|
* @param fileName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public SecretInit dataLoadding(String fileName){
|
||||||
|
// 根据加载不同的文件 生成密码机初装数据
|
||||||
|
SecretInit secretInit = new SecretInit();
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
secretInit.setPasswordInit("aGVsbG93b3JsZAo=");
|
||||||
|
secretInit.setAlgorithmParam("Y2Fuc2h1Cg==");
|
||||||
|
secretInit.setParamCode("emlqaWFubWEK");
|
||||||
|
secretInit.setSecretDataStatus("未发送");
|
||||||
|
secretInit.setSecretRain("未销毁");
|
||||||
|
secretInit.setSecretKill("未遥毙");
|
||||||
|
secretInit.setMmjKill("未遥毙");
|
||||||
|
secretInit.setCreateTime(now);
|
||||||
|
secretInit.setUpdateTime(now);
|
||||||
|
|
||||||
|
secretInitMapper.selectCount(secretInit);
|
||||||
|
|
||||||
|
Example example = new Example(SecretInit.class);
|
||||||
|
example.createCriteria().andEqualTo("fileName",fileName);
|
||||||
|
List<SecretInit> list = secretInitMapper.selectByExample(example);
|
||||||
|
if(list.size() > 0){
|
||||||
|
secretInit.setId(list.get(0).getId());
|
||||||
|
secretInitMapper.updateByPrimaryKeySelective(deviceInit);
|
||||||
|
}else{
|
||||||
|
secretInitMapper.insertSelective(deviceInit);
|
||||||
|
}
|
||||||
|
return secretInit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送数据
|
||||||
|
*/
|
||||||
|
public void sendData(){
|
||||||
|
Example example = new Example(SecretInit.class);
|
||||||
|
example.createCriteria().andEqualTo("fileName",fileName);
|
||||||
|
List<SecretInit> list = secretInitMapper.selectByExample(example);
|
||||||
|
if(list.size() > 0){
|
||||||
|
SecretInit secretInit = list.get(0);
|
||||||
|
secretInit.setSecretDataStatus("已发送");
|
||||||
|
secretInit.setUpdateTime(LocalDateTime.now());
|
||||||
|
secretInitMapper.updateByPrimaryKeySelective(secretInit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清空信息
|
||||||
|
*/
|
||||||
|
public void clean(){
|
||||||
|
secretInitMapper.deleteAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1 密钥销毁 2 密钥遥毙 3 密钥机遥毙
|
||||||
|
*/
|
||||||
|
public SecretInit secretSendCmd(Integer type){
|
||||||
|
SecretInit secretInit = secretInitMapper.selectAll().get(0);
|
||||||
|
switch (type) {
|
||||||
|
case 1:
|
||||||
|
secretInit.setSecretRain("已销毁");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
secretInit.setSecretKill("已遥毙");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
secretInit.setMmjKill("已遥毙")
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
secretInitMapper.updateByPrimaryKeySelective(secretInit);
|
||||||
|
return secretInit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态查询
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public SecretInit secretInfo(){
|
||||||
|
return secretInitMapper.selectAll().get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package com.imitate.web.params;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import com.imitate.common.util.BasePageCondition;
|
||||||
|
import com.imitate.web.persistence.beans.ParameterSet;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Delegate;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ParameterSetParam extends BasePageCondition implements Serializable{
|
||||||
|
|
||||||
|
|
||||||
|
@Valid
|
||||||
|
@Delegate
|
||||||
|
private ParameterSet parameterSet;
|
||||||
|
|
||||||
|
{
|
||||||
|
parameterSet = new ParameterSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package com.imitate.web.params;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import com.imitate.common.util.BasePageCondition;
|
||||||
|
import com.imitate.web.persistence.beans.SecretAsk;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SecretAskParam extends BasePageCondition implements Serializable{
|
||||||
|
|
||||||
|
private SecretAsk secretAsk;
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
this.secretAsk = new SecretAsk();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
package com.imitate.web.params;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
|
||||||
|
import com.imitate.common.util.BasePageCondition;
|
||||||
|
import com.imitate.web.persistence.beans.SecretFormat;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SecretFormatParam extends BasePageCondition implements Serializable{
|
||||||
|
|
||||||
|
|
||||||
|
private SecretFormat secretFormat;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
this.secretFormat = new SecretFormat();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.imitate.web.params;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import com.imitate.common.util.BasePageCondition;
|
||||||
|
import com.imitate.web.persistence.beans.SecretImport;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SecretImportParam extends BasePageCondition implements Serializable{
|
||||||
|
|
||||||
|
private SecretImport secretImport;
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
this.secretImport = new SecretImport();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
package com.imitate.web.params;
|
||||||
|
|
||||||
|
import com.imitate.web.persistence.beans.SecretInit;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SecretInitParam extends BasePageCondition implements Serializable{
|
||||||
|
|
||||||
|
|
||||||
|
@Valid
|
||||||
|
@Delegate
|
||||||
|
private SecretInit secretInit;;
|
||||||
|
|
||||||
|
{
|
||||||
|
secretInit = new SecretInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
|
||||||
|
package com.imitate.web.persistence.beans;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import com.imitate.common.util.AbstractDO;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Table(name = "remote_file_config")
|
||||||
|
public class RemoteFileConfig extends AbstractDO{
|
||||||
|
|
||||||
|
@Column(name = "service_list")
|
||||||
|
private String serviceList;
|
||||||
|
|
||||||
|
@Column(name = "net_param")
|
||||||
|
private String netParam;
|
||||||
|
|
||||||
|
@Column(name = "safe_strategy")
|
||||||
|
private String safeStrategy;
|
||||||
|
|
||||||
|
@Column(name = "manager_strategy")
|
||||||
|
private String managerStrategy;
|
||||||
|
|
||||||
|
@Column(name = "vpn_strategy")
|
||||||
|
private String vpnStrategy;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package com.imitate.web.persistence.mapper;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.imitate.common.util.BaseMapper;
|
||||||
|
import com.imitate.web.persistence.beans.RemoteFileConfig;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
@Repository
|
||||||
|
public interface RemoteFileConfigMapper extends BaseMapper<RemoteFileConfig>{
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="com.imitate.web.persistence.mapper.RemoteFileConfigMapper" >
|
||||||
|
<resultMap id="BaseResultMap" type="com.imitate.web.persistence.beans.RemoteFileConfig" >
|
||||||
|
<id column="id" property="id" jdbcType="INTEGER" />
|
||||||
|
<result column="service_list" property="serviceList" jdbcType="TEXT" />
|
||||||
|
<result column="net_param" property="netParam" jdbcType="TEXT" />
|
||||||
|
<result column="safe_strategy" property="safeStrategy" jdbcType="TEXT" />
|
||||||
|
<result column="manager_strategy" property="mangerStrategy" jdbcType="TEXT" />
|
||||||
|
<result column="vpn_strategy" property="vpnStrategy" jdbcType="TEXT" />
|
||||||
|
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
|
||||||
|
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in new issue