This commit is contained in:
liulu 2024-10-28 14:08:32 +08:00
parent 17356d0314
commit 80ed3eae1f
39 changed files with 2713 additions and 9 deletions

View File

@ -92,7 +92,7 @@
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>4.5.2</version>
<version>5.5.0</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>

View File

@ -21,7 +21,7 @@ public abstract class KeyTemplateDTO {
public static class Query extends PageQuery {
/**
* 密钥类型
* @see com.sunyard.ssp.web.enums.KeyCategory#getCode()
* @see com.sunyard.chsm.enums.KeyCategory#getCode()
*/
private String keyType;
}
@ -63,24 +63,23 @@ public abstract class KeyTemplateDTO {
private String name;
/**
* 密钥类型
* @see com.sunyard.ssp.web.enums.KeyCategory#getCode()
* @see com.sunyard.chsm.enums.KeyCategory#getCode()
*/
@NotBlank(message = "密钥类型不能为空")
private String keyType;
/**
* 密钥算法
* @see com.sunyard.ssp.web.enums.KeyAlg#getCode()
* @see com.sunyard.chsm.enums.KeyAlg#getCode()
*/
@NotBlank(message = "密钥算法不能为空")
private String keyAlg;
/**
* 密钥长度
*/
@NotNull(message = "密钥长度不能为空")
private Integer keyLength;
/**
* 密钥用途
* @see com.sunyard.ssp.web.enums.KeyUsage#getCode()
* @see com.sunyard.chsm.enums.KeyUsage#getCode()
*/
@NotEmpty(message = "密钥用途不能为空")
private List<String> keyUsages;

View File

@ -1,12 +1,18 @@
package com.sunyard.config;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.apache.ibatis.mapping.DatabaseIdProvider;
import org.apache.ibatis.mapping.VendorDatabaseIdProvider;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
import java.util.Properties;
/**
* @author liulu
* @since 2024/10/28
@ -27,4 +33,24 @@ public class MyBatisConfig {
return interceptor;
}
@Bean
public DatabaseIdProvider databaseIdProvider() {
VendorDatabaseIdProvider databaseIdProvider = new VendorDatabaseIdProvider(){
@Override
public String getDatabaseId(DataSource dataSource) {
String databaseId = super.getDatabaseId(dataSource);
if (StrUtil.isBlank(databaseId)){
throw new NullPointerException("多数据库标识为空,请检查数据库连接情况");
}
return databaseId;
}
};
Properties properties = new Properties();
properties.put("Oracle","oracle");
properties.put("MySQL","mysql");
properties.put("DM","dm");
databaseIdProvider.setProperties(properties);
return databaseIdProvider;
}
}

View File

@ -0,0 +1,60 @@
package com.sunyard.ssp.modules.common;
import com.sunyard.ssp.common.Result;
import com.sunyard.ssp.common.vo.Captcha;
import com.sunyard.ssp.utils.CreateVerifyCode;
import com.sunyard.ssp.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
/**
* @author Exrickx
*/
@Api(description = "验证码接口")
@RequestMapping("/common/captcha")
@RestController
@Transactional
@Slf4j
public class CaptchaController {
@Autowired
private StringRedisTemplate redisTemplate;
@RequestMapping(value = "/init",method = RequestMethod.GET)
@ApiOperation(value = "初始化验证码")
public Result<Object> initCaptcha() {
String captchaId = UUID.randomUUID().toString().replace("-","");
String code = new CreateVerifyCode().randomStr(4);
Captcha captcha = new Captcha();
captcha.setCaptchaId(captchaId);
captcha.setCode(code);
//缓存验证码
redisTemplate.opsForValue().set(captchaId,code,3L, TimeUnit.MINUTES);
return new ResultUtil<Object>().setData(captcha);
}
@RequestMapping(value = "/draw/{captchaId}", method = RequestMethod.GET)
@ApiOperation(value = "根据验证码ID获取图片")
public void drawCaptcha(@PathVariable("captchaId") String captchaId, HttpServletResponse response) throws IOException {
// 得到验证码 生成指定验证码
String code=redisTemplate.opsForValue().get(captchaId);
CreateVerifyCode vCode = new CreateVerifyCode(116,36,4,10,code);
vCode.write(response.getOutputStream());
}
}

View File

@ -0,0 +1,319 @@
package com.sunyard.ssp.modules.jna;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
import com.sunyard.ssp.modules.sysconf.cipherunit.enums.LibEnum;
/**
* @author sunyard
*/
public interface CipherJna extends Library {
/**
* 加载动态库
*/
CipherJna INSTANCE = Native.load(LibEnum.LIB_NAME.getValue(), CipherJna.class);
/**
* 打开设备
* @param phDeviceHandle 设备句柄
* @return int 响应码
*/
int SDF_OpenDevice(PointerByReference phDeviceHandle);
/**
* 关闭设备
* @param hDeviceHandle 设备句柄
* @return int 响应码
*/
int SDF_CloseDevice(Pointer hDeviceHandle);
/**
* 打开会话
* @param hDeviceHandle 设备句柄
* @param phSessionHandle 会话句柄
* @return int 响应码
*/
int SDF_OpenSession(Pointer hDeviceHandle, PointerByReference phSessionHandle);
int SDF_ImportKey(Pointer hSessionHandle, byte[] pucKey, int uiKeyLen, PointerByReference phKeyhandle);
/**
* 关闭会话
* @param hSessionHandle 会话句柄
* @return int 响应码
*/
int SDF_CloseSession(Pointer hSessionHandle);
/**
* 生成随机数
* @param hSessionHandle 会话句柄
* @param uiLength 生成随机数长度
* @param pucRandom 存放随机数容器
* @return int 响应码
*/
int SDF_GenerateRandom(Pointer hSessionHandle, int uiLength, byte[] pucRandom);
/**
* 对称加密
* @param phSessionHandle 会话句柄
* @param hKeyHandle 密钥句柄
* @param uiAlgID 算法标识
* @param pucIV IV数据
* @param pucData 待加密数据
* @param pucDataLength 待加密数据长度
* @param pucEncData 存放密文容器
* @param pucEncDataLength 密文长度
* @return int 响应码
*/
int SDF_Encrypt(
Pointer phSessionHandle,
Pointer hKeyHandle,
int uiAlgID,
byte[] pucIV,
byte[] pucData,
int pucDataLength,
byte[] pucEncData,
IntByReference pucEncDataLength
);
/**
* 对称解密
* @param phSessionHandle 会话句柄
* @param hKeyHandle 密钥句柄
* @param uiAlgID 算法标识
* @param pucIV IV数据
* @param purEncData 指向密文数据的指针
* @param encDataLength 密文数据长度
* @param pucData 输出明文数据
* @param pucDataLength 输出明文数据长度
* @return int 响应码
*/
int SDF_Decrypt(
Pointer phSessionHandle,
Pointer hKeyHandle,
int uiAlgID,
byte[] pucIV,
byte[] purEncData,
int encDataLength,
byte[] pucData,
IntByReference pucDataLength
);
/**
* 生成ECC密钥对
* @param phSessionHandle 会话句柄
* @param uiAlgID 算法标识
* @param uiKeyBits 密钥长度
* @param pucPublicKey 输出的ECC公钥结构
* @param pucPrivateKey 输出的ECC私钥结构
* @return int 响应码
*/
int SDF_GenerateKeyPair_ECC(
Pointer phSessionHandle,
int uiAlgID,
int uiKeyBits,
byte[] pucPublicKey,
byte[] pucPrivateKey
);
/**
* 生成会话密钥并用外部ECC公钥加密输出,输出密钥句柄
* @param hSessionHandle 会话句柄
* @param uiKeyBits 密钥长度
* @param uiAlgID 算法标识
* @param pucPublicKey ECC公钥结构
* @param pucKey 密钥密文
* @param phKeyHandle 密钥句柄
* @return int 响应码
*/
int SDF_GenerateKeyWithEPK_ECC(
Pointer hSessionHandle,
int uiKeyBits,
int uiAlgID,
byte[] pucPublicKey,
byte[] pucKey,
PointerByReference phKeyHandle
);
/**
* 杂凑运算初始化
* @param phSessionHandle 会话句柄
* @param uiAlgID 算法标识
* @param pucPublicKey ECC公钥结构
* @param pucID 签名者的ID值
* @param pucIDlength 签名者ID的长度
* @return int 响应码
*/
int SDF_HashInit(Pointer phSessionHandle, int uiAlgID, byte[] pucPublicKey, String pucID, int pucIDlength);
/**
* 多包杂凑运算
* @param phSessionHandle 会话句柄
* @param pucData 输入的数据明文
* @param uiDataLength 输入的数据明文长度
* @return int 响应码
*/
int SDF_HashUpdate(
Pointer phSessionHandle, // 使用IntByReference因为SessionHandle可能是引用类型的
byte[] pucData, // 输入的明文数据作为字节数组
int uiDataLength // 明文数据长度
);
/**
* MAC 计算
* @param phSessionHandle 会话句柄
* @param hKeyHadnle 密钥句柄
* @param uiAlgID 算法标识
* @param pucIV IV数据
* @param purData 待计算MAC的数据
* @param pucDatalength 待计算MAC的数据长度
* @param pucMAC MAC值
* @param pucMACLength MAC值长度
* @return
*/
int SDF_CalculateMAC(Pointer phSessionHandle,
Pointer hKeyHadnle,
int uiAlgID,
byte[] pucIV,
byte[] purData,
int pucDatalength,
byte[] pucMAC,
IntByReference pucMACLength);
/**
* 杂凑运算结束
* @param phSessionHandle 会话句柄
* @param pucHash 杂凑结果
* @param pucHashLength 杂凑结果长度
* @return int 响应码
*/
int SDF_HashFinal(Pointer phSessionHandle, byte[] pucHash, IntByReference pucHashLength);
/**
* 外部ECC签名
* @param phSessionHandle 会话句柄
* @param uiAlgID 算法标识
* @param pucPublicKey ECC公钥结构
* @param pucData 输入的数据明文
* @param pucDataLength 输入的数据明文长度
* @param pucECCSignature 输出的签名值数据
* @return int 响应码
*/
int SDF_ExternalSign_ECC(
Pointer phSessionHandle,
int uiAlgID,
byte[] pucPublicKey,
byte[] pucData,
int pucDataLength,
byte[] pucECCSignature
);
/**
* 外部ECC验签
* @param phSessionHandle 会话句柄
* @param uiAlgID 算法标识
* @param pucPublicKey ECC公钥结构
* @param pucData 输入的数据明文
* @param pucDataLength 输入的数据明文长度
* @param pucECCSignature 输入的签名值数据
* @return int 响应码
*/
int SDF_ExternalVerify_ECC(Pointer phSessionHandle, int uiAlgID, byte[] pucPublicKey, byte[] pucData, int pucDataLength, byte[] pucECCSignature);
/**
* 密钥加密
* @param phSessionHandle 会话句柄
* @param uiAlgID 算法标识
* @param pucPublicKey ECC公钥结构
* @param pucData 输入的数据明文
* @param pucDatalength 输入的数据明文长度
* @param pucEncData 输出的密文数据
* @return int 响应码
*/
int SDF_ExternalEncrypt_ECC(Pointer phSessionHandle, int uiAlgID, byte[] pucPublicKey, byte[] pucData, int pucDatalength, byte[] pucEncData);
/**
* 密钥解密
* @param phSessionHandle 会话句柄
* @param uiAlgID 算法标识
* @param pucPrivateKey ECC私钥结构
* @param pucEncData 输入的密文数据
* @param pucDataOut 输出的数据明文
* @param pucDatalength 输出的数据明文长度
* @return int 响应码
*/
int SDF_ExternalDecrypt_ECC(Pointer phSessionHandle, int uiAlgID, byte[] pucPrivateKey, byte[] pucEncData, byte[] pucDataOut, IntByReference pucDatalength);
/**
* 生成密钥协商数据
* @param phSessionHandle 会话句柄
* @param uiISKIndex 密码设备存储私钥的索引值
* @param uiKeyBits 要求协商的密钥长度
* @param pucSponsorID 参与密钥协商的发起方ID值
* @param uiSponsorIDLength 发起方ID长度
* @param pucSponsorPublicKey 返回的发起方ECC公钥结构
* @param pucSponsorTmpPublicKey 返回的发起方临时ECC公钥结构
* @param phAgreementHandle 返回的协商对象用于计算协商密钥
* @return int 响应码
*/
int SDF_GenerateAgreementDataWithECC(Pointer phSessionHandle, int uiISKIndex, int uiKeyBits,
String pucSponsorID, int uiSponsorIDLength,
byte[] pucSponsorPublicKey, byte[] pucSponsorTmpPublicKey,
PointerByReference phAgreementHandle);
/**
* 生成密钥协商数据并计算密钥
* @param phSessionHandle 会话句柄
* @param uiISKIndex 密码设备存储私钥的索引值
* @param uiKeyBits 要求协商的密钥长度
* @param pucResponseID 参与密钥协商的响应方ID值
* @param uiResponseIDLength 响应方ID长度
* @param pucSponsorID 参与密钥协商的发起方ID值
* @param uiSponsorIDLength 发起方ID长度
* @param pucSponsorPublicKey 发起方ECC公钥结构
* @param pucSponsorTmpPublicKey 发起方临时ECC公钥结构
* @param pucResponsePublicKey 响应方ECC公钥结构
* @param pucResponseTmpPublicKey 响应方临时ECC公钥结构
* @param phKeyhandle 返回的密钥句柄
* @return
*/
int SDF_GenerateAgreementDataAndKeyWithECC(
Pointer phSessionHandle,
int uiISKIndex,
int uiKeyBits,
String pucResponseID,
int uiResponseIDLength,
String pucSponsorID,
int uiSponsorIDLength,
byte[] pucSponsorPublicKey,
byte[] pucSponsorTmpPublicKey,
byte[] pucResponsePublicKey,
byte[] pucResponseTmpPublicKey,
PointerByReference phKeyhandle
);
/**
* 获取私钥访问权
* @param phSessionHandle 会话句柄
* @param uiKeyIndex 密码设备存储私钥的索引值
* @param pucPassword 使用私钥权限的标识码
* @param uiPwdLength 私钥访问控制码长度不少于8字节
* @return int 响应码
*/
int SDF_GetPrivateKeyAccessRight(Pointer phSessionHandle, int uiKeyIndex, String pucPassword, int uiPwdLength);
/**
* 释放私钥访问权
* @param phSessionHandle 会话句柄
* @param uiKeyIndex 密码设备存储私钥的索引值
* @return int 响应码
*/
int SDF_ReleasePrivateKeyAccessRight(Pointer phSessionHandle, int uiKeyIndex);
}

View File

@ -0,0 +1,35 @@
package com.sunyard.ssp.modules.monitor.transaction.controller;
import com.sunyard.ssp.common.Result;
import com.sunyard.ssp.modules.monitor.transaction.entity.StatisticalParam;
import com.sunyard.ssp.modules.monitor.transaction.service.TransactionService;
import com.sunyard.ssp.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@Slf4j
@Api(description = "系统监控-交易监控", tags = "系统监控-交易监控")
@RequestMapping("/monitor/transaction")
@Transactional
public class TransactionController {
@Autowired
private TransactionService transactionService;
@RequestMapping(value = "/getTransactionData", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "获得交易监控的数据")
public Result<Object> getStaticInfo(@ModelAttribute StatisticalParam statisticalParam) {
Object result = transactionService.getTransactionData(statisticalParam);
return new ResultUtil<Object>().setData(result);
}
}

View File

@ -0,0 +1,28 @@
package com.sunyard.ssp.modules.monitor.transaction.entity;
public interface StatisticalConstant {
String STATISTICAL_METHOD_PIE_CHART = "pieChart";
String STATISTICAL_METHOD_LINE_CHART_TIME_INTERVAL= "lineChartTimeInterval";
String STATISTICAL_METHOD_LINE_CHART_KEY_GROUP = "lineChartKeyGroup";
String TIME_MONTH_FORMAT = "yyyy-mm";
String TIME_MONTH_WEAK_FORMAT = "yyyy-mm-w";
String TIME_WEAK_FORMAT = "yyyy-iw";
String TIME_DAY_FORMAT = "yyyy-mm-dd";
String TIME_HOUR_FORMAT = "yyyy-mm-dd HH24";
String TIME_METHOD_MONTH = "month";
String TIME_METHOD_DAY = "day";
String TIME_METHOD_WEAK = "week";
}

View File

@ -0,0 +1,40 @@
package com.sunyard.ssp.modules.monitor.transaction.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDate;
@Data
@ApiModel(value="", description="统计参数")
public class StatisticalParam {
@ApiModelProperty(value = "统计方式lineChartTimeInterval-不带对称秘钥 lineChartKeyGroup-带对称秘钥)(必传)")
private String statisticalMethod;
@ApiModelProperty(value = "服务名")
private String server;
@ApiModelProperty(value = "渠道Id")
private String channelId;
@ApiModelProperty(value = "方案Id")
private String solutionNumber;
@ApiModelProperty(value = "秘钥类型")
private String group;
@ApiModelProperty(value = "统计时间")
private String inputStatisticalTime;
private LocalDate sqlStatisticalTime;
@ApiModelProperty(value = "统计时间方式(月-month 周-weak 日-day必传")
private String timeInterval;
private String timeIntervalFormat;
private String sqlStatisticalTimeFormat;
}

View File

@ -0,0 +1,13 @@
package com.sunyard.ssp.modules.monitor.transaction.entity;
import lombok.Data;
@Data
public class StatisticalResult {
private Integer successCount;
private Integer failCount;
private String statisticalTime;
}

View File

@ -0,0 +1,71 @@
package com.sunyard.ssp.modules.monitor.transaction.mapper;
import com.sunyard.ssp.modules.monitor.transaction.entity.StatisticalParam;
import com.sunyard.ssp.modules.monitor.transaction.entity.StatisticalResult;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface StatisticalMapper {
// @Select("<script>" +
// " select SUM(SUCCESS_COUNT) as successCount,SUM(FAIL_COUNT) as failCount from SC_BUSINESS_STATISTICS\n" +
// " <where>\n" +
// " <if test=\"statisticalParam.server != null and statisticalParam.server != ''\">\n" +
// " and SERVER = #{statisticalParam.server}\n" +
// " </if>\n" +
// " <if test=\"statisticalParam.channelId != null\">\n" +
// " and CHANNEL_ID = #{statisticalParam.channelId}\n" +
// " </if>\n" +
// " <if test=\"statisticalParam.solutionId != null\">\n" +
// " and SOLUTION__ID = #{statisticalParam.solutionId}\n" +
// " </if>\n" +
// " <if test=\"statisticalParam.startTime != null and statisticalParam.endTime != null\">\n" +
// " and \"CURRENT_TIME\" between to_date(#{statisticalParam.startTime},'YYYY-MM-DD HH24:MI:SS') and to_date(#{statisticalParam.endTime},'YYYY-MM-DD HH24:MI:SS')\n" +
// " </if>\n" +
// " </where>" +
// "</script>")
StatisticalResult countPieChart(@Param("statisticalParam") StatisticalParam statisticalParam);
// @Select("<script>" +
// " select to_char(\"CURRENT_TIME\",'${statisticalParam.timeIntervalFormat}') as statisticalTime,\n" +
// " SUM(SUCCESS_COUNT) as successCount,\n" +
// " SUM(FAIL_COUNT) as failCount \n" +
// " from SC_BUSINESS_STATISTICS\n" +
// " <where>\n" +
// " <if test=\"statisticalParam.server != null and statisticalParam.server != ''\">\n" +
// " and SERVER = #{statisticalParam.server}\n" +
// " </if>\n" +
// " <if test=\"statisticalParam.channelId != null\">\n" +
// " and CHANNEL_ID = #{statisticalParam.channelId}\n" +
// " </if>\n" +
// " <if test=\"statisticalParam.solutionNumber != null\">\n" +
// " and SOLUTION_NUMBER = #{statisticalParam.solutionNumber}\n" +
// " </if>\n" +
// " <if test=\"statisticalParam.sqlStatisticalTime != null and statisticalParam.sqlStatisticalTimeFormat !=null\">\n" +
// " and to_char(TRUNC(\"CURRENT_TIME\"),'${statisticalParam.sqlStatisticalTimeFormat}') = (SELECT TO_CHAR (#{statisticalParam.sqlStatisticalTime}, '${statisticalParam.sqlStatisticalTimeFormat}') FROM DUAL)\n" +
// " </if>\n" +
// " </where>\n" +
// " group by to_char(\"CURRENT_TIME\",'${statisticalParam.timeIntervalFormat}')\n" +
// " order by to_char(\"CURRENT_TIME\",'${statisticalParam.timeIntervalFormat}')" +
// "</script>")
List<StatisticalResult> countLineChartByTimeInterval(@Param("statisticalParam") StatisticalParam statisticalParam);
// @Select("<script>" +
// " select to_char(\"CURRENT_TIME\",'${statisticalParam.timeIntervalFormat}') as statisticalTime ,SUM(SUCCESS_COUNT) as successCount,SUM(FAIL_COUNT) as failCount\n" +
// " from SC_BUSINESS_STATISTICS\n" +
// " <where>\n" +
// " <if test=\"statisticalParam.group != null and statisticalParam.group != ''\">\n" +
// " and \"GROUP\" = #{statisticalParam.group}\n" +
// " </if>\n" +
// " <if test=\"statisticalParam.sqlStatisticalTime != null and statisticalParam.sqlStatisticalTimeFormat !=null\">\n" +
// " and to_char(TRUNC(\"CURRENT_TIME\"),'${statisticalParam.sqlStatisticalTimeFormat}') = (SELECT TO_CHAR (#{statisticalParam.sqlStatisticalTime}, '${statisticalParam.sqlStatisticalTimeFormat}') FROM DUAL)\n" +
// " </if>\n" +
// " </where>\n" +
// " group by to_char(\"CURRENT_TIME\",'${statisticalParam.timeIntervalFormat}')\n" +
// " order by to_char(\"CURRENT_TIME\",'${statisticalParam.timeIntervalFormat}')" +
// "</script>")
List<StatisticalResult> countLineChartByKeyGroup(@Param("statisticalParam") StatisticalParam statisticalParam);
}

View File

@ -0,0 +1,14 @@
package com.sunyard.ssp.modules.monitor.transaction.service;
import com.sunyard.ssp.modules.monitor.transaction.entity.StatisticalParam;
public interface TransactionService {
/**
* 统计
* @param statisticalParam
* @return
*/
Object getTransactionData(StatisticalParam statisticalParam);
}

View File

@ -0,0 +1,90 @@
package com.sunyard.ssp.modules.monitor.transaction.serviceImpl;
import com.sunyard.ssp.modules.monitor.transaction.entity.StatisticalConstant;
import com.sunyard.ssp.modules.monitor.transaction.entity.StatisticalParam;
import com.sunyard.ssp.modules.monitor.transaction.entity.StatisticalResult;
import com.sunyard.ssp.modules.monitor.transaction.mapper.StatisticalMapper;
import com.sunyard.ssp.modules.monitor.transaction.service.TransactionService;
import com.sunyard.ssp.utils.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
@Transactional
@Slf4j
public class StatisticalServiceImpl implements TransactionService {
@Autowired
private StatisticalMapper statisticalMapper;
@Override
public Object getTransactionData(StatisticalParam statisticalParam) {
statisticalParam = dealWithTimeFormat(statisticalParam);
if (StatisticalConstant.STATISTICAL_METHOD_PIE_CHART.equals(statisticalParam.getStatisticalMethod())) {
return statisticalMapper.countPieChart(statisticalParam);
} else if (StatisticalConstant.STATISTICAL_METHOD_LINE_CHART_TIME_INTERVAL.equals(statisticalParam.getStatisticalMethod())) {
List<StatisticalResult> statisticalResults = statisticalMapper.countLineChartByTimeInterval(statisticalParam);
return dealReturnTimeFormat(statisticalResults, statisticalParam.getTimeInterval());
} else if (StatisticalConstant.STATISTICAL_METHOD_LINE_CHART_KEY_GROUP.equals(statisticalParam.getStatisticalMethod())) {
List<StatisticalResult> statisticalResults = statisticalMapper.countLineChartByKeyGroup(statisticalParam);
return dealReturnTimeFormat(statisticalResults, statisticalParam.getTimeInterval());
} else {
return null;
}
}
/**
* 处理时间格式
*
* @param statisticalParam
* @return
*/
private StatisticalParam dealWithTimeFormat(StatisticalParam statisticalParam) {
statisticalParam.setSqlStatisticalTime(DateUtil.StringToDate(statisticalParam.getInputStatisticalTime()));
if (StatisticalConstant.TIME_METHOD_MONTH.equals(statisticalParam.getTimeInterval())) {
statisticalParam.setSqlStatisticalTimeFormat(StatisticalConstant.TIME_MONTH_FORMAT);
statisticalParam.setTimeIntervalFormat(StatisticalConstant.TIME_MONTH_WEAK_FORMAT);
} else if (StatisticalConstant.TIME_METHOD_WEAK.equals(statisticalParam.getTimeInterval())) {
statisticalParam.setSqlStatisticalTimeFormat(StatisticalConstant.TIME_WEAK_FORMAT);
statisticalParam.setTimeIntervalFormat(StatisticalConstant.TIME_DAY_FORMAT);
} else {
statisticalParam.setSqlStatisticalTimeFormat(StatisticalConstant.TIME_DAY_FORMAT);
statisticalParam.setTimeIntervalFormat(StatisticalConstant.TIME_HOUR_FORMAT);
}
return statisticalParam;
}
/**
* 出来返回时间
*
* @param statisticalResults
* @param timeMethod
* @return
*/
private List<StatisticalResult> dealReturnTimeFormat(List<StatisticalResult> statisticalResults, String timeMethod) {
if (StatisticalConstant.TIME_METHOD_MONTH.equals(timeMethod)) {
statisticalResults.forEach(statisticalResult -> {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(statisticalResult.getStatisticalTime());
stringBuilder.setCharAt(7, '月');
stringBuilder.insert(8, "");
stringBuilder.append("");
statisticalResult.setStatisticalTime(stringBuilder.toString());
});
} else if (StatisticalConstant.TIME_METHOD_DAY.equals(timeMethod)) {
statisticalResults.forEach(statisticalResult -> {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(statisticalResult.getStatisticalTime());
stringBuilder.append("");
statisticalResult.setStatisticalTime(stringBuilder.toString());
});
} else {
}
return statisticalResults;
}
}

View File

@ -0,0 +1,230 @@
package com.sunyard.ssp.modules.sysconf.cipherunit.controller;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.PointerByReference;
import com.sunyard.proto.Util;
import com.sunyard.ssp.common.Result;
import com.sunyard.ssp.common.annotation.AuditControllerLog;
import com.sunyard.ssp.common.exception.SspwebException;
import com.sunyard.ssp.modules.jna.CipherJna;
import com.sunyard.ssp.modules.sysconf.cipherunit.entity.ScCipherMachine;
import com.sunyard.ssp.modules.sysconf.cipherunit.entity.ScCipherMachineVo;
import com.sunyard.ssp.modules.sysconf.cipherunit.enums.RetEnum;
import com.sunyard.ssp.modules.sysconf.cipherunit.service.ScCipherMachineService;
import com.sunyard.ssp.modules.sysconf.cipherunit.utils.IniFileUpdater;
import com.sunyard.ssp.modules.sysconf.paramconf.entity.ParamConf;
import com.sunyard.ssp.modules.sysconf.paramconf.service.IParamConfService;
import com.sunyard.ssp.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
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.ResponseBody;
/**
* 密码部件管理控制层
*
* @author admin
*/
@Controller
@Slf4j
@Api(description = "关键密码部件管理接口", tags = "关键密码部件管理")
@RequestMapping("/cipherMachine")
public class ScCipherMachineController {
@Autowired
private ScCipherMachineService scCipherMachineService;
@Autowired
private IParamConfService iParamConfService;
// @ControllerLog("获取关键密码部件部件")
@RequestMapping(value = "/query", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取关键密码部件部件")
public Result<ScCipherMachineVo> queryCipherMachine() {
log.info("get请求 /cipherMachine/query接口");
ScCipherMachineVo scCipherMachineVo = scCipherMachineService.queryCipherMachine();
log.info("获取密码部件功能响应结果:{}", scCipherMachineVo);
return new ResultUtil<ScCipherMachineVo>().setData(scCipherMachineVo);
}
// @ControllerLog("添加关键密码部件配置")
@RequestMapping(value = "/add", method = RequestMethod.POST)
@AuditControllerLog(description = "添加关键密码部件配置",operateType = "增加")
@ResponseBody
@ApiOperation(value = "添加关键密码部件配置")
public Result<Object> addCipherMachine(@RequestBody ScCipherMachine scCipherMachine) {
try {
ScCipherMachine scCipherMachineVo = scCipherMachineService.addCipherMachine(scCipherMachine);
IniFileUpdater.updateIniFile(scCipherMachine.getIp(),(String) scCipherMachine.getPort());
return new ResultUtil<>().setData(scCipherMachineVo);
} catch (SspwebException e) {
return new ResultUtil<Object>().setErrorMsg(e.getMsg());
}
}
// @ControllerLog("检测")
@RequestMapping(value = "/detection", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "检测")
public Result<Object> detection() {
int size = 16;
PointerByReference phDeviceHandle = new PointerByReference();
PointerByReference phSessionHandle = new PointerByReference();
int code = RetEnum.SUCCESS.getCode();
try {
// 打开设备
int ret = CipherJna.INSTANCE.SDF_OpenDevice(phDeviceHandle);
if (ret != code) {
return new ResultUtil<Object>().setErrorMsg(ret, "打开设备失败,密码模块初始化失败");
}
Pointer hDeviceHandle = phDeviceHandle.getValue();
// 打开会话
ret = CipherJna.INSTANCE.SDF_OpenSession(hDeviceHandle, phSessionHandle);
if (ret != code) {
return new ResultUtil<Object>().setErrorMsg(ret, "打开会话失败,密码模块初始化失败");
}
byte[] nakedSign = new byte[size];
// 生成随机数
ret = CipherJna.INSTANCE.SDF_GenerateRandom(phSessionHandle.getValue(), 16, nakedSign);
if (ret != code) {
return new ResultUtil<Object>().setErrorMsg(ret, "生成随机数失败,密码模块初始化失败");
}
// 返回结果
String result = Util.bytes2HexString(nakedSign);
log.info("检测功能响应结果:{}", result);
return new ResultUtil<>().setData(result);
} catch (SspwebException e) {
return new ResultUtil<Object>().setErrorMsg(e.getMsg());
} catch (Throwable e) {
log.error("检测异常:" + e);
return new ResultUtil<Object>().setErrorMsg("密码模块初始化失败");
} finally {
// 关闭会话
if (phSessionHandle.getValue() != null) {
int ret = CipherJna.INSTANCE.SDF_CloseSession(phSessionHandle.getValue());
if (ret != code) {
log.error("关闭会话失败:{}", ret);
}
}
// 关闭设备
if (phDeviceHandle.getValue() != null) {
int ret = CipherJna.INSTANCE.SDF_CloseDevice(phDeviceHandle.getValue());
if (ret != code) {
log.error("关闭设备失败:{}", ret);
}
}
}
}
// @ControllerLog("密码模块初始化")
@RequestMapping(value = "/init", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "密码模块初始化")
public Result<Object> init() {
int size = 16;
PointerByReference phDeviceHandle = new PointerByReference();
PointerByReference phSessionHandle = new PointerByReference();
int code = RetEnum.SUCCESS.getCode();
try {
// // 打开设备
// int ret = CipherJna.INSTANCE.SDF_OpenDevice(phDeviceHandle);
// if (ret != code) {
// return new ResultUtil<Object>().setErrorMsg(ret, "打开设备失败");
// }
// Pointer hDeviceHandle = phDeviceHandle.getValue();
// // 打开会话
// ret = CipherJna.INSTANCE.SDF_OpenSession(hDeviceHandle, phSessionHandle);
// if (ret != code) {
// return new ResultUtil<Object>().setErrorMsg(ret, "打开会话失败");
// }
// byte[] nakedSign = new byte[size];
// // 生成随机数
// ret = CipherJna.INSTANCE.SDF_GenerateRandom(phSessionHandle.getValue(), 16, nakedSign);
// if (ret != code) {
// return new ResultUtil<Object>().setErrorMsg(ret, "生成随机数失败");
// }
// // 返回结果
// String result = Util.bytes2HexString(nakedSign);
// log.info("检测功能响应结果:{}", result);
ParamConf paramConf = iParamConfService.selectByKey("initStatus");
if (paramConf != null) {
paramConf.setValue("1");
iParamConfService.updateById(paramConf);
}
return new ResultUtil<>().setSuccessMsg("初始化成功");
} catch (SspwebException e) {
return new ResultUtil<Object>().setErrorMsg(e.getMsg());
} catch (Throwable e) {
log.error("检测异常:" + e);
return new ResultUtil<Object>().setErrorMsg("检测失败");
} finally {
// 关闭会话
if (phSessionHandle.getValue() != null) {
int ret = CipherJna.INSTANCE.SDF_CloseSession(phSessionHandle.getValue());
if (ret != code) {
log.error("关闭会话失败:{}", ret);
}
}
// 关闭设备
if (phDeviceHandle.getValue() != null) {
int ret = CipherJna.INSTANCE.SDF_CloseDevice(phDeviceHandle.getValue());
if (ret != code) {
log.error("关闭设备失败:{}", ret);
}
}
}
}
// @ControllerLog("密码模块初始化状态获取")
@RequestMapping(value = "/init/status", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "密码模块初始化状态获取")
public Result<Object> initStatus() {
ParamConf paramConf = iParamConfService.selectByKey("initStatus");
if (paramConf != null) {
return new ResultUtil<>().setData(paramConf.getValue());
} else {
return new ResultUtil<>().setErrorMsg("获取初始化状态失败");
}
}
// @ControllerLog("编辑关键密码部件配置")
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
@AuditControllerLog(description = "编辑关键密码部件配置",operateType = "修改")
@ResponseBody
@ApiOperation(value = "编辑关键密码部件配置")
public Result<Object> editCipherMachine(@RequestBody ScCipherMachine scCipherMachine) {
try {
log.info("put请求 /cipherMachine/edit 请求参数:{}", scCipherMachine);
ScCipherMachine scCipherMachineVo = scCipherMachineService.editCipherMachine(scCipherMachine);
log.info("编辑关键密码部件功能响应结果:{}", scCipherMachineVo);
IniFileUpdater.updateIniFile(scCipherMachine.getIp(),(String) scCipherMachine.getPort());
return new ResultUtil<>().setData(scCipherMachineVo);
} catch (SspwebException e) {
return new ResultUtil<Object>().setErrorMsg(e.getMsg());
}
}
// @ControllerLog("删除关键密码部件配置")
@RequestMapping(value = "/delete/{id}", method = RequestMethod.DELETE)
@AuditControllerLog(description = "删除关键密码部件配置",operateType = "删除")
@ResponseBody
@ApiOperation(value = "删除关键密码部件配置")
public Result<Object> deleteCipherMachine(@PathVariable("id") Long id) {
try {
log.info("delete请求 /cipherMachine/delete 请求参数:{}", id);
scCipherMachineService.deleteCipherMachine(id);
return new ResultUtil<>().setData(null);
} catch (SspwebException e) {
return new ResultUtil<Object>().setErrorMsg(e.getMsg());
}
}
}

View File

@ -0,0 +1,48 @@
package com.sunyard.ssp.modules.sysconf.cipherunit.controller;
import com.sunyard.ssp.common.Result;
import com.sunyard.ssp.modules.sysconf.paramconf.entity.ParamConf;
import com.sunyard.ssp.modules.sysconf.paramconf.service.IParamConfService;
import com.sunyard.ssp.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
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.ResponseBody;
@Controller
@Slf4j
@Api(description = "密码部件管理接口", tags = "全局密码模块状态显示")
@RequestMapping("/status")
public class StatusController {
@Autowired
IParamConfService iParamConfService;
// @ControllerLog("获取全局密码模块状态")
@RequestMapping(value = "/query", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取密码模块状态")
public Result<Object> queryStatus() {
/*
* status = 0 初始化状态; status = 1 密码主管状态; status = 2 密码主管状态; status = 3 自测试状态; status = 4 错误报警状态;
* status = 5 核准状态; status = 6 关键参数输入状态;status = 7 核准状态
*/
ParamConf status = iParamConfService.selectByKey("status");
return new ResultUtil<Object>().setData(status.getValue());
}
// @ControllerLog("修改全局密码模块状态")
@RequestMapping(value = "/set", method = RequestMethod.PUT)
@ResponseBody
@ApiOperation(value = "修改密码模块状态")
public Result<Object> setStatus(@RequestParam("value") String value) {
ParamConf status = iParamConfService.selectByKey("status");
status.setValue(value);
iParamConfService.updateById(status);
return new ResultUtil<Object>().setData(status.getValue());
}
}

View File

@ -0,0 +1,134 @@
package com.sunyard.ssp.modules.sysconf.cipherunit.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 密码部件配置
* @TableName SC_CIPHER_MACHINE
*/
@TableName(value ="SC_CIPHER_MACHINE")
@Data
public class ScCipherMachine implements Serializable {
/**
* 主键id
*/
@TableId(type = IdType.AUTO)
private Object id;
/**
* ip
*/
private String ip;
/**
* 端口号
*/
private Object port;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改时间
*/
private Date updateTime;
/**
* 预留字段1
*/
private String c1;
/**
* 预留字段2
*/
private String c2;
/**
* 预留字段3
*/
private String c3;
/**
* 预留字段4
*/
private String c4;
/**
* 预留字段5
*/
private String c5;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
ScCipherMachine other = (ScCipherMachine) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getIp() == null ? other.getIp() == null : this.getIp().equals(other.getIp()))
&& (this.getPort() == null ? other.getPort() == null : this.getPort().equals(other.getPort()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
&& (this.getC1() == null ? other.getC1() == null : this.getC1().equals(other.getC1()))
&& (this.getC2() == null ? other.getC2() == null : this.getC2().equals(other.getC2()))
&& (this.getC3() == null ? other.getC3() == null : this.getC3().equals(other.getC3()))
&& (this.getC4() == null ? other.getC4() == null : this.getC4().equals(other.getC4()))
&& (this.getC5() == null ? other.getC5() == null : this.getC5().equals(other.getC5()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getIp() == null) ? 0 : getIp().hashCode());
result = prime * result + ((getPort() == null) ? 0 : getPort().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
result = prime * result + ((getC1() == null) ? 0 : getC1().hashCode());
result = prime * result + ((getC2() == null) ? 0 : getC2().hashCode());
result = prime * result + ((getC3() == null) ? 0 : getC3().hashCode());
result = prime * result + ((getC4() == null) ? 0 : getC4().hashCode());
result = prime * result + ((getC5() == null) ? 0 : getC5().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", ip=").append(ip);
sb.append(", port=").append(port);
sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", c1=").append(c1);
sb.append(", c2=").append(c2);
sb.append(", c3=").append(c3);
sb.append(", c4=").append(c4);
sb.append(", c5=").append(c5);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

View File

@ -0,0 +1,30 @@
package com.sunyard.ssp.modules.sysconf.cipherunit.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.io.Serializable;
/**
* 密码部件vo类
* @author admin
*/
@Data
public class ScCipherMachineVo implements Serializable{
/**
* 主键id
*/
@TableId(type = IdType.AUTO)
private Object id;
/**
* ip
*/
private String ip;
/**
* 端口号
*/
private Object port;
}

View File

@ -0,0 +1,29 @@
package com.sunyard.ssp.modules.sysconf.cipherunit.enums;
/**
* c配置文件的枚举类
* @author admin
*/
public enum ConfigEnum {
/**
* 配置项头
*/
TARGET_SECTION("DEV-0")
,
/**
* 配置文件路径
*/
CONFIG_FILE_PATH("./config/SYD_SDF.ini");
/**
* 配置项
*/
private final String value;
ConfigEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
}

View File

@ -0,0 +1,28 @@
package com.sunyard.ssp.modules.sysconf.cipherunit.enums;
/**
* 动态库枚举类
* @author admin
*/
public enum LibEnum {
/**
* 动态库路径
*/
LIB_PATH("./lib"),
LIB_NAME("sydsdf"),
LIB_CONFIG_FILE("./config/SYD_SDF.ini");
/**
*
*/
private final String value;
LibEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
}

View File

@ -0,0 +1,35 @@
package com.sunyard.ssp.modules.sysconf.cipherunit.enums;
/**
* 响应码枚举类
* @author admin
*/
public enum RetEnum {
/**
* 成功
*/
SUCCESS(0, "成功");
/**
* 响应码
*/
private final int code;
/**
* 响应描述
*/
private final String desc;
RetEnum(int code, String desc) {
this.code = code;
this.desc = desc;
}
public int getCode() {
return code;
}
public String getDesc() {
return desc;
}
}

View File

@ -0,0 +1,18 @@
package com.sunyard.ssp.modules.sysconf.cipherunit.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sunyard.ssp.modules.sysconf.cipherunit.entity.ScCipherMachine;
/**
* @author admin
* @description 针对表SC_CIPHER_MACHINE(密码部件配置)的数据库操作Mapper
* @createDate 2024-05-16 14:20:57
* @Entity com.sunyard.ssp.modules.sysconf.cipherunit.entity.ScCipherMachine
*/
public interface ScCipherMachineMapper extends BaseMapper<ScCipherMachine> {
}

View File

@ -0,0 +1,38 @@
package com.sunyard.ssp.modules.sysconf.cipherunit.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.sunyard.ssp.modules.sysconf.cipherunit.entity.ScCipherMachine;
import com.sunyard.ssp.modules.sysconf.cipherunit.entity.ScCipherMachineVo;
/**
* @author admin
* @description 针对表SC_CIPHER_MACHINE(密码部件配置)的数据库操作Service
* @createDate 2024-05-16 14:20:57
*/
public interface ScCipherMachineService extends IService<ScCipherMachine> {
/**
* 查询密码部件配置
* @return 密码部件vo类 ScCipherMachine
*/
ScCipherMachineVo queryCipherMachine();
/**
* 添加密码部件配置
* @param scCipherMachine 密码部件配置
* @return scCipherMachine 添加后的结果
*/
ScCipherMachine addCipherMachine(ScCipherMachine scCipherMachine);
/**
* 修改密码部件配置
* @param scCipherMachine 密码部件配置
* @return scCipherMachine 添加后的结果
*/
ScCipherMachine editCipherMachine(ScCipherMachine scCipherMachine);
/**
* 删除密码部件配置
* @param id 要删除的id
*/
void deleteCipherMachine(Long id);
}

View File

@ -0,0 +1,78 @@
package com.sunyard.ssp.modules.sysconf.cipherunit.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sunyard.ssp.common.exception.SspwebException;
import com.sunyard.ssp.modules.sysconf.cipherunit.entity.ScCipherMachine;
import com.sunyard.ssp.modules.sysconf.cipherunit.entity.ScCipherMachineVo;
import com.sunyard.ssp.modules.sysconf.cipherunit.mapper.ScCipherMachineMapper;
import com.sunyard.ssp.modules.sysconf.cipherunit.service.ScCipherMachineService;
import org.springframework.stereotype.Service;
import java.util.Objects;
/**
* @author admin
* @description 针对表SC_CIPHER_MACHINE(密码部件配置)的数据库操作Service实现
* @createDate 2024-05-16 14:20:57
*/
@Service
public class ScCipherMachineServiceImpl extends ServiceImpl<ScCipherMachineMapper, ScCipherMachine>
implements ScCipherMachineService{
@Override
public ScCipherMachineVo queryCipherMachine() {
ScCipherMachine scCipherMachine = baseMapper.selectOne(new QueryWrapper<>());
ScCipherMachineVo scCipherMachineVo = new ScCipherMachineVo();
BeanUtil.copyProperties(scCipherMachine,scCipherMachineVo);
return scCipherMachineVo;
}
@Override
public ScCipherMachine addCipherMachine(ScCipherMachine scCipherMachine) {
if (Objects.isNull(scCipherMachine)){
throw new SspwebException("必要参数不能为空");
}
Long count = baseMapper.selectCount(new QueryWrapper<>());
if (count>=1){
throw new SspwebException("已经存在密码部件配置");
}
int insert = baseMapper.insert(scCipherMachine);
if (insert<=0){
throw new SspwebException("添加失败");
}
return scCipherMachine;
}
@Override
public ScCipherMachine editCipherMachine(ScCipherMachine scCipherMachine) {
if (Objects.isNull(scCipherMachine)){
throw new SspwebException("必要参数不能为空");
}
Long count = baseMapper.selectCount(new QueryWrapper<ScCipherMachine>().eq("id",scCipherMachine.getId()));
if (count<1){
throw new SspwebException("不存在密码部件配置");
}
int update = baseMapper.updateById(scCipherMachine);
if (update<=0){
throw new SspwebException("修改失败");
}
return scCipherMachine;
}
@Override
public void deleteCipherMachine(Long id) {
if (Objects.isNull(id)){
throw new SspwebException("必要参数不能为空");
}
int i = baseMapper.deleteById(id);
if (i<1){
throw new SspwebException("删除失败");
}
}
}

View File

@ -0,0 +1,62 @@
package com.sunyard.ssp.modules.sysconf.cipherunit.utils;
import com.sunyard.ssp.modules.sysconf.cipherunit.enums.ConfigEnum;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
/**
* ini文件更新工具类
*
*/
public class IniFileUpdater {
/**
* 更新ini文件
*
* @param ip IP地址
* @param port 端口号
*/
public static void updateIniFile(String ip, String port) {
String filePath = ConfigEnum.CONFIG_FILE_PATH.getValue();
String targetSection = ConfigEnum.TARGET_SECTION.getValue();
try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
StringBuilder content = new StringBuilder();
String line;
boolean sectionFound = false;
while ((line = reader.readLine()) != null) {
if (line.trim().startsWith("[" + targetSection + "]")) {
// 找到目标部分
sectionFound = true;
content.append(line).append(System.lineSeparator());
// 修改[DEV-0]部分的配置
content.append("IP=").append(ip).append(System.lineSeparator());
content.append("PORT=").append(port).append(System.lineSeparator());
// 添加回车符
content.append(System.lineSeparator());
} else if (sectionFound && line.trim().startsWith("[")) {
// 目标部分已处理完毕遇到下一个部分
sectionFound = false;
content.append(line).append(System.lineSeparator());
} else if (!sectionFound) {
// 非目标部分
content.append(line).append(System.lineSeparator());
}
}
// 将修改后的内容写回原始文件
FileWriter writer = new FileWriter(filePath);
writer.write(content.toString());
writer.close();
System.out.println("INI file updated successfully.");
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,140 @@
package com.sunyard.ssp.modules.sysconf.dict.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.conditions.update.UpdateChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sunyard.ssp.common.PageVo;
import com.sunyard.ssp.common.Result;
import com.sunyard.ssp.common.annotation.AuditControllerLog;
import com.sunyard.ssp.common.constant.SqlConstant;
import com.sunyard.ssp.modules.sysconf.dict.entity.ScDict;
import com.sunyard.ssp.modules.sysconf.dict.service.IScDictDataService;
import com.sunyard.ssp.modules.sysconf.dict.service.IScDictService;
import com.sunyard.ssp.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.ModelAttribute;
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.ResponseBody;
import java.util.List;
import java.util.Map;
/**
* <p>
* 前端控制器
* </p>
*
* @author fyc
* @since 2020-03-13
*/
@Controller
@Slf4j
@RequestMapping("/sysconf/scDict")
@Transactional
@Api(description = "系统配置-字典管理", tags = "系统配置-字典管理")
public class ScDictController {
@Autowired
IScDictService iScDictService;
@Autowired
IScDictDataService iScDictDataService;
@RequestMapping(value = "/search", method = RequestMethod.GET)
@ResponseBody
@ApiOperation("根据字典关键字查询")
public Result<List<ScDict>> search(@RequestParam String key) {
List<ScDict> scDicts = iScDictService.selectByKey(key);
return new ResultUtil<List<ScDict>>().setData(scDicts);
}
@RequestMapping(value = "/getById", method = RequestMethod.GET)
@ResponseBody
@ApiOperation("根据ID获取字典")
public Result<ScDict> get(@RequestParam String id) {
ScDict entity = iScDictService.getById(id);
return new ResultUtil<ScDict>().setData(entity);
}
@RequestMapping(value = "/getAll", method = RequestMethod.GET)
@ResponseBody
@ApiOperation("获取所以字典(不分页)")
public Result<List<ScDict>> getAll() {
List<ScDict> list = iScDictService.list(new QueryWrapper<ScDict>().orderByAsc(SqlConstant.DB_SORT_COLUMN));
return new ResultUtil<List<ScDict>>().setData(list);
}
@RequestMapping(value = "/page", method = RequestMethod.GET)
@ResponseBody
@ApiOperation("获取所有字典(分页)")
public Result<IPage<ScDict>> getByPage(@ModelAttribute PageVo page) {
Page<ScDict> data = new Page<>(page.getPageNumber(), page.getPageSize());
IPage<ScDict> iPage = iScDictService.page(data);
return new ResultUtil<IPage<ScDict>>().setData(iPage);
}
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ResponseBody
@ApiOperation("添加字典")
@AuditControllerLog(description = "添加字典", operateType = "新增")
public Result<ScDict> save(@ModelAttribute ScDict entity) {
Map checkData = iScDictService.checkInputForm(entity);
if (!(Boolean) checkData.get("status")) {
return new ResultUtil<ScDict>().setErrorMsg((String) checkData.get("message"));
}
try {
boolean e = iScDictService.save(entity);
if (!e) {
return new ResultUtil<ScDict>().setErrorMsg("添加失败");
}
return new ResultUtil<ScDict>().setSuccessMsg("添加成功");
} catch (DuplicateKeyException e) {
return new ResultUtil<ScDict>().setErrorMsg("字典名称或字典类型已经存在");
}
}
@RequestMapping(value = "/update", method = RequestMethod.PUT)
@ResponseBody
@ApiOperation("更新字典")
@AuditControllerLog(description = "更新字典", operateType = "更新")
public Result<UpdateChainWrapper<ScDict>> update(@ModelAttribute ScDict entity) {
Map checkData = iScDictService.checkInputForm(entity);
if (!(Boolean) checkData.get("status")) {
return new ResultUtil<UpdateChainWrapper<ScDict>>().setErrorMsg((String) checkData.get("message"));
}
try {
boolean e = iScDictService.updateById(entity);
if (!e) {
return new ResultUtil<UpdateChainWrapper<ScDict>>().setErrorMsg("更新失败");
}
return new ResultUtil<UpdateChainWrapper<ScDict>>().setSuccessMsg("更新成功");
} catch (DuplicateKeyException e) {
return new ResultUtil<UpdateChainWrapper<ScDict>>().setErrorMsg("字典名称或字典类型已经存在");
}
}
@RequestMapping(value = "/deleteByIds", method = RequestMethod.DELETE)
@ResponseBody
@ApiOperation("删除字典(批量)")
@AuditControllerLog(description = "删除字典", operateType = "删除")
public Result<Object> delAllByIds(@RequestParam String[] ids) {
for (String id : ids) {
iScDictService.removeById(id);
iScDictDataService.deleteByDictId(Long.valueOf(id));
}
return new ResultUtil<Object>().setSuccessMsg("批量通过id删除数据成功");
}
}

View File

@ -0,0 +1,171 @@
package com.sunyard.ssp.modules.sysconf.dict.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.conditions.update.UpdateChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sunyard.ssp.common.PageVo;
import com.sunyard.ssp.common.Result;
import com.sunyard.ssp.common.annotation.AuditControllerLog;
import com.sunyard.ssp.modules.sysconf.dict.entity.ScDictData;
import com.sunyard.ssp.modules.sysconf.dict.service.IScDictDataService;
import com.sunyard.ssp.modules.sysconf.dict.service.IScDictService;
import com.sunyard.ssp.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.ModelAttribute;
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.ResponseBody;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* <p>
* 前端控制器
* </p>
*
* @author fyc
* @since 2020-03-13
*/
@Controller
@Slf4j
@RequestMapping("/sysconf/scDictData")
@Transactional
@Api(description = "系统配置-字典数据管理",tags = "系统配置-字典数据管理")
public class ScDictDataController {
@Autowired
IScDictDataService iScDictDataService;
@Autowired
IScDictService iScDictService;
@RequestMapping(value = "/getById",method = RequestMethod.GET)
@ResponseBody
@ApiOperation("根据Id获取字典数据")
public Result<ScDictData> get(@RequestParam String id){
ScDictData entity = iScDictDataService.getById(id);
log.info("根据Id获取字典数据");
return new ResultUtil<ScDictData>().setData(entity);
}
@RequestMapping(value = "/selectByType",method = RequestMethod.GET)
@ResponseBody
@ApiOperation("根据类型获取字典数据")
public Result<List<ScDictData>> selectByType(@RequestParam String type){
List<ScDictData> list = iScDictDataService.selectByDictType(type);
log.info("根据类型获取字典数据");
return new ResultUtil<List<ScDictData>>().setData(list);
}
@RequestMapping(value = "/selectVersion",method = RequestMethod.GET)
@ResponseBody
@ApiOperation("根据类型获取系统版本号")
public Result selectVersion(){
List<ScDictData> list = iScDictDataService.selectByDictType("version");
if (Objects.isNull(list)||list.size()<=0) {
return new ResultUtil<>().setErrorMsg("未获取到版本号");
}
ScDictData scDictData = list.get(0);
log.info("根据类型获取字典数据");
return new ResultUtil<>().setData(scDictData.getValue());
}
@ApiOperation("条件查询接口")
@RequestMapping(value = "/queryList",method = RequestMethod.POST)
@ResponseBody
public Result<IPage<ScDictData>> queryList(@RequestBody ScDictData scDictData){
try {
IPage<ScDictData> scDictDataIPage = iScDictDataService.queryList(scDictData);
log.info("条件查询接口");
return new ResultUtil<IPage<ScDictData>>().setData(scDictDataIPage);
}catch (Exception e){
log.error(e.getMessage());
return null;
}
}
@RequestMapping(value = "/getAll",method = RequestMethod.GET)
@ResponseBody
@ApiOperation("获取全部字典数据(不分页)")
public Result<List<ScDictData>> getAll(){
List<ScDictData> list = iScDictDataService.list();
return new ResultUtil<List<ScDictData>>().setData(list);
}
@RequestMapping(value = "/page",method = RequestMethod.GET)
@ResponseBody
@ApiOperation("获取全部字典数据(分页)")
public Result<IPage<ScDictData>> getByPage(@ModelAttribute PageVo page){
Page<ScDictData> data = new Page<>( page.getPageNumber(),page.getPageSize());
IPage<ScDictData> iPage = iScDictDataService.page(data);
return new ResultUtil<IPage<ScDictData>>().setData(iPage);
}
@RequestMapping(value = "/save",method = RequestMethod.POST)
@ResponseBody
@ApiOperation("添加字典数据")
@AuditControllerLog(description = "添加字典数据",operateType = "新增")
public Result<ScDictData> save(@ModelAttribute ScDictData entity){
Map checkData = iScDictDataService.checkInputData(entity);
if(!(Boolean)checkData.get("status")){
return new ResultUtil<ScDictData>().setErrorMsg((String)checkData.get("message"));
}
entity.setCreateTime(LocalDateTime.now());
try {
boolean e = iScDictDataService.save(entity);
if (!e) {
return new ResultUtil<ScDictData>().setErrorMsg("添加失败");
}
return new ResultUtil<ScDictData>().setSuccessMsg("添加成功");
}catch (DuplicateKeyException e){
return new ResultUtil<ScDictData>().setErrorMsg("数据名称已经存在");
}
}
@RequestMapping(value = "/update",method = RequestMethod.PUT)
@ResponseBody
@ApiOperation("更新字典数据")
@AuditControllerLog(description = "更新字典数据",operateType = "更新")
public Result<UpdateChainWrapper<ScDictData>> update(@ModelAttribute ScDictData entity){
Map checkData = iScDictDataService.checkInputData(entity);
if(!(Boolean)checkData.get("status")){
return new ResultUtil<UpdateChainWrapper<ScDictData>>().setErrorMsg((String)checkData.get("message"));
}
try {
boolean e = iScDictDataService.updateById(entity);
if (!e) {
return new ResultUtil<UpdateChainWrapper<ScDictData>>().setErrorMsg("更新失败");
}
return new ResultUtil<UpdateChainWrapper<ScDictData>>().setSuccessMsg("更新成功");
}catch (DuplicateKeyException e){
return new ResultUtil<UpdateChainWrapper<ScDictData>>().setErrorMsg("数据名称已经存在");
}
}
@RequestMapping(value = "/deleteByIds",method = RequestMethod.DELETE)
@ResponseBody
@ApiOperation("根据字典数据ID删除数据批量")
@AuditControllerLog(description = "删除字典数据",operateType = "删除")
public Result<Object> delAllByIds(@RequestParam String[] ids){
for(String id:ids){
iScDictDataService.removeById(id);
}
return new ResultUtil<Object>().setSuccessMsg("批量通过id删除数据成功");
}
}

View File

@ -0,0 +1,75 @@
package com.sunyard.ssp.modules.sysconf.dict.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
/**
* <p>
*
* </p>
*
* @author fyc
* @since 2020-03-13
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("SC_DICT")
public class ScDict implements Serializable {
private static final long serialVersionUID = 1L;
@TableId("ID")
private Long id;
@TableField("CREATE_TIME")
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
/**
* 备注
*/
@TableField("DESCRIPTION")
private String description;
/**
* 字典名称
*/
@TableField("TITLE")
private String title;
/**
* 字典类型
*/
@TableField("TYPE")
private String type;
/**
* 作用范围(仅对平台创建字典有效) 1 全部 2 隐藏
*/
@TableField("SCOPE")
private Integer scope;
/**
* 排序值
*/
@TableField("SORT_ORDER")
private Double sortOrder;
/**
* 字典数据非表映射关系
*/
@TableField(exist = false)
private List<ScDictData> scDictDataList;
}

View File

@ -0,0 +1,78 @@
package com.sunyard.ssp.modules.sysconf.dict.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.sunyard.ssp.common.PageVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* <p>
*
* </p>
*
* @author fyc
* @since 2020-03-13
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("SC_DICT_DATA")
@ApiModel(value="", description="")
public class ScDictData extends PageVo implements Serializable {
private static final long serialVersionUID = 1L;
@TableId("ID")
private Long id;
@ApiModelProperty(value = "创建时间")
@TableField("CREATE_TIME")
// @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
/**
* 备注
*/
@TableField("DESCRIPTION")
private String description;
/**
* 所属字典
*/
@TableField("DICT_ID")
private Long dictId;
/**
* 排序值
*/
@TableField("SORT_ORDER")
private Double sortOrder;
/**
* 是否启用 0启用 -1禁用
*/
@TableField("STATUS")
private Long status;
/**
* 数据名称
*/
@TableField("TITLE")
private String title;
/**
* 数据值
*/
@TableField("VALUE")
private String value;
}

View File

@ -0,0 +1,62 @@
package com.sunyard.ssp.modules.sysconf.dict.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sunyard.ssp.modules.sysconf.dict.entity.ScDictData;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author fyc
* @since 2020-03-13
*/
@Repository
public interface ScDictDataMapper extends BaseMapper<ScDictData> {
/**
* 按条件查询数据字典
* @param iPage 分页
* @param scDictData 条件参数
* @return
*/
@Select("<script>" +
" select * from Sc_DICT_DATA\n" +
" <where>\n" +
" <if test=\"scDictData.dictId != null\">\n" +
" and DICT_ID = #{scDictData.dictId}\n" +
" </if>\n" +
" <if test=\"scDictData.title != null and scDictData.title != ''\">\n" +
" and TITLE like '%${scDictData.title}%'\n" +
" </if>\n" +
" <if test=\"scDictData.status != null\">\n" +
" and STATUS = #{scDictData.status}\n" +
" </if>\n" +
" </where>\n" +
" order by ${scDictData.sort} ${scDictData.order} ,CREATE_TIME desc"+
"</script>")
List<ScDictData> queryList(IPage<ScDictData> iPage,@Param("scDictData") ScDictData scDictData);
/**
* 根据字典id 获取字典数据
* @param scDictId 字典边ID
* @return
*/
@Select("<script>"+
"select * from Sc_DICT_DATA where DICT_ID = #{ scDictId } and STATUS = 0 order by SORT_ORDER asc"+
"</script>")
List<ScDictData> selectByDictId(@Param("scDictId") Long scDictId);
@Delete("<script>"+
"delete from Sc_DICT_DATA where DICT_ID = #{ scDictId }"+
"</script>")
void deleteByDictId(@Param("scDictId") Long scDictId);
}

View File

@ -0,0 +1,25 @@
package com.sunyard.ssp.modules.sysconf.dict.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sunyard.ssp.modules.sysconf.dict.entity.ScDict;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
/**
* <p>
* Mapper 接口
* </p>
*
* @author fyc
* @since 2020-03-13
*/
@Repository
public interface ScDictMapper extends BaseMapper<ScDict> {
@Select("<script>" +
"select * from SC_DICT where type = #{type}"+
"</script>")
ScDict selectByType(@Param("type") String type);
}

View File

@ -0,0 +1,48 @@
package com.sunyard.ssp.modules.sysconf.dict.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.sunyard.ssp.modules.sysconf.dict.entity.ScDictData;
import java.util.List;
import java.util.Map;
/**
* <p>
* 服务类
* </p>
*
* @author fyc
* @since 2020-03-13
*/
public interface IScDictDataService extends IService<ScDictData> {
/**
* 获取字典数据列表
* @param scDictData 查询参数
* @return
*/
IPage<ScDictData> queryList(ScDictData scDictData);
/**
* 根据字典类型返回字典数据
* @param type 字典类型
* @return
*/
List<ScDictData> selectByDictType(String type);
/**
* 通过字典ID删除字典数据
* @param dictId
*/
void deleteByDictId(Long dictId);
/**
* 检测传入数据
* @param scDictData
* @return
*/
Map checkInputData(ScDictData scDictData);
}

View File

@ -0,0 +1,22 @@
package com.sunyard.ssp.modules.sysconf.dict.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.sunyard.ssp.modules.sysconf.dict.entity.ScDict;
import java.util.List;
import java.util.Map;
/**
* <p>
* 服务类
* </p>
*
* @author fyc
* @since 2020-03-13
*/
public interface IScDictService extends IService<ScDict> {
List<ScDict> selectByKey(String key);
Map checkInputForm(ScDict scDict);
}

View File

@ -0,0 +1,116 @@
package com.sunyard.ssp.modules.sysconf.dict.serviceimpl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sunyard.ssp.common.constant.SqlConstant;
import com.sunyard.ssp.modules.sysconf.dict.entity.ScDict;
import com.sunyard.ssp.modules.sysconf.dict.entity.ScDictData;
import com.sunyard.ssp.modules.sysconf.dict.mapper.ScDictDataMapper;
import com.sunyard.ssp.modules.sysconf.dict.mapper.ScDictMapper;
import com.sunyard.ssp.modules.sysconf.dict.service.IScDictDataService;
import com.sunyard.ssp.utils.CommonUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <p>
* 服务实现类
* </p>
*
* @author fyc
* @since 2020-03-13
*/
@Slf4j
@Service
@Transactional
public class ScDictDataServiceImpl extends ServiceImpl<ScDictDataMapper, ScDictData> implements IScDictDataService {
@Autowired
private ScDictDataMapper scDictDataMapper;
@Autowired
private ScDictMapper scDictMapper;
@Override
public IPage<ScDictData> queryList(ScDictData scDictData){
if(scDictData.getSort()==null || scDictData.getSort()==""){
scDictData.setSort(SqlConstant.DB_SORT_COLUMN);
}else {
String sort = CommonUtil.underscoreName(scDictData.getSort());
scDictData.setSort(sort);
}
Page<ScDictData> scDictDataPage = new Page<>(scDictData.getPageNumber(),scDictData.getPageSize());
IPage<ScDictData> scDictDataIPage = scDictDataPage.setRecords(scDictDataMapper.queryList(scDictDataPage,scDictData));
return scDictDataIPage;
}
@Override
public List<ScDictData> selectByDictType(String type) {
ScDict scDict = scDictMapper.selectByType(type);
List<ScDictData> scDictDataList = new ArrayList<>();
if(scDict != null){
scDictDataList = scDictDataMapper.selectByDictId(scDict.getId());
}
return scDictDataList;
}
@Override
public void deleteByDictId(Long dictId) {
scDictDataMapper.deleteByDictId(dictId);
}
@Override
public Map checkInputData(ScDictData scDictData) {
Map result = new HashMap();
//检测数据是否为空
if(scDictData == null){
result.put("status",false);
result.put("message","传入数据不合法");
return result;
}
//检测字段是否为空
if(scDictData.getDictId()==null || scDictData.getTitle()== null || scDictData.getValue()==null){
result.put("status",false);
result.put("message","传入数据不合法");
return result;
}
//检测字典标题是否超过上限
if(scDictData.getTitle().length()>255){
result.put("status",false);
result.put("message","名称字符超过上限");
return result;
}
//检测字典数据值是否超过上限
if(scDictData.getValue().length()>255){
result.put("status",false);
result.put("message","数据值字符超过上限");
return result;
}
//检测描述是否超过上限
if(scDictData.getDescription()!=null) {
if (scDictData.getDescription().length() > 255) {
result.put("status", false);
result.put("message", "备注字符超过上限");
return result;
}
}
result.put("status",true);
return result;
}
}

View File

@ -0,0 +1,76 @@
package com.sunyard.ssp.modules.sysconf.dict.serviceimpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sunyard.ssp.common.constant.SqlConstant;
import com.sunyard.ssp.modules.sysconf.dict.entity.ScDict;
import com.sunyard.ssp.modules.sysconf.dict.mapper.ScDictMapper;
import com.sunyard.ssp.modules.sysconf.dict.service.IScDictService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <p>
* 服务实现类
* </p>
*
* @author fyc
* @since 2020-03-13
*/
@Slf4j
@Service
@Transactional
public class ScDictServiceImpl extends ServiceImpl<ScDictMapper, ScDict> implements IScDictService {
@Autowired
private ScDictMapper scDictMapper;
@Override
public List<ScDict> selectByKey(String key) {
QueryWrapper queryWrapper = new QueryWrapper<ScDict>().like("TITLE",key).orderByAsc(SqlConstant.DB_SORT_COLUMN);
List<ScDict> dicts = scDictMapper.selectList(queryWrapper);
return dicts;
}
@Override
public Map checkInputForm(ScDict scDict) {
Map result = new HashMap();
//是否为空检测
if(scDict == null){
result.put("status",false);
result.put("message","传入数据不合法");
return result;
}
//字典名称长度检测
if(scDict.getTitle().length()>255){
result.put("status",false);
result.put("message","字典名称字符超出上限");
return result;
}
//字典类型长度检测
if(scDict.getType().length()>255){
result.put("status",false);
result.put("message","字典类型字符超出上限");
return result;
}
//备注字符长度检测
if(scDict.getDescription()!=null) {
if (scDict.getDescription().length() > 255) {
result.put("status", false);
result.put("message", "备注字符超出上限");
return result;
}
}
result.put("status",true);
return result;
}
}

View File

@ -19,9 +19,9 @@ import java.util.List;
@Repository
public interface ParamConfMapper extends BaseMapper<ParamConf> {
// @Select("<script>"+
// " select * from SC_PARAM_CONF where KEY = #{key}"+
// "</script>")
@Select("<script>"+
" select * from SC_PARAM_CONF where KEY = #{key}"+
"</script>")
ParamConf selectByKey(@Param("key")String key);
@Select("<script>"+

View File

@ -0,0 +1,70 @@
<?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.sunyard.ssp.modules.user.mapper.ScPermissionMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.sunyard.ssp.modules.user.entity.ScPermission">
<id column="ID" property="id" />
<result column="DESCRIPTION" property="description" />
<result column="NAME" property="name" />
<result column="PARENT_ID" property="parentId" />
<result column="P_TYPE" property="pType" />
<result column="SORT_ORDER" property="sortOrder" />
<result column="COMPONENT" property="component" />
<result column="PATH" property="path" />
<result column="TITLE" property="title" />
<result column="ICON" property="icon" />
<result column="P_LEVEL" property="pLevel" />
<result column="BUTTON_TYPE" property="buttonType" />
<result column="P_STATUS" property="pStatus" />
<result column="URL" property="url" />
<result column="NEED_VERIFY" property="needVerify"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
ID, DESCRIPTION, NAME, PARENT_ID, P_TYPE, SORT_ORDER, COMPONENT, PATH, TITLE, ICON, P_LEVEL, BUTTON_TYPE, P_STATUS, URL, NEED_VERIFY
</sql>
<sql id="FindByParent_Column_List">
tp.id,
tp.description,
tp.name,
tp.parent_id,
tp.p_type,
tp.sort_order,
tp.component,
tp.path,
tp.title,
tp.icon,
tp.p_level,
tp.button_type,
tp.p_status,
tp.url,
tp.need_verify
</sql>
<select id="findByUserId" resultType="com.sunyard.ssp.modules.user.entity.ScPermission">
SELECT DISTINCT tp.*
FROM sc_user u
LEFT JOIN sc_user_role ur ON u.id = ur.user_id
LEFT JOIN sc_role_permission rp ON ur.role_id = rp.role_id
LEFT JOIN sc_permission tp ON tp.id = rp.permission_id
WHERE u.id = #{userId} AND tp.p_status = 0
ORDER BY tp.sort_order ASC
</select>
<select id="findByLevelOrderBySortOrder" resultType="com.sunyard.ssp.modules.user.entity.ScPermission">
SELECT DISTINCT tp.* from sc_permission tp
WHERE
tp.p_level = #{level}
order by tp.sort_order
</select>
<select id="findByParentIdOrderBySortOrder" resultType="com.sunyard.ssp.modules.user.entity.ScPermission">
SELECT DISTINCT tp.* from sc_permission tp
where
tp.parent_id = #{parentId}
order by tp.sort_order
</select>
<select id="findAll" resultType="com.sunyard.ssp.modules.user.entity.ScPermission">
select <include refid="Base_Column_List"></include> from sc_permission
</select>
</mapper>

View File

@ -0,0 +1,20 @@
<?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.sunyard.ssp.modules.user.mapper.ScPositionMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.sunyard.ssp.modules.user.entity.ScPosition">
<result column="ID" property="id" />
<result column="NAME" property="name" />
<result column="STATUS" property="status" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
ID, NAME, STATUS
</sql>
<select id="getNameById" resultType="java.lang.String">
select name from sc_position where id = #{0}
</select>
</mapper>

View File

@ -0,0 +1,128 @@
<?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.sunyard.ssp.modules.user.mapper.ScUserMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.sunyard.ssp.modules.user.entity.ScUser">
<result column="ID" property="id"/>
<result column="USERNAME" property="username"/>
<result column="PASSWORD" property="password"/>
<result column="REALNAME" property="realname"/>
<result column="ORGANIZATION_ID" property="organizationId"/>
<result column="TEL" property="tel"/>
<result column="EMAIL" property="email"/>
<result column="STATUS" property="status"/>
<result column="UPDATE_TIME" property="updateTime"/>
<result column="PASS_UPDATE_TIME" property="passUpdateTime"/>
<result column="POSITION_ID" property="positionId"/>
<result column="AVATAR" property="avatar"/>
<result column="SEX" property="sex"/>
</resultMap>
<resultMap id="UserResultMap" type="com.sunyard.ssp.modules.user.entity.ScUser">
<result column="id" property="id"/>
<result column="username" property="username"/>
<result column="password" property="password"/>
<result column="realname" property="realname"/>
<result column="organization_id" property="organizationId"/>
<result column="tel" property="tel"/>
<result column="email" property="email"/>
<result column="status" property="status"/>
<result column="update_time" property="updateTime"/>
<result column="pass_update_time" property="passUpdateTime"/>
<result column="position_id" property="positionId"/>
<result column="avatar" property="avatar"/>
<result column="sex" property="sex"/>
<result column="u_publickey" property="uPublickey"/>
<association property="positionName" select="com.sunyard.ssp.modules.user.mapper.ScPositionMapper.getNameById"
column="position_id"/>
<collection property="roles" ofType="com.sunyard.ssp.modules.user.entity.ScRole">
<result column="role_id" property="id"/>
<result column="role_name" property="name"/>
<result column="role_default_role" property="defaultRole"/>
<result column="role_data_type" property="dataType"/>
<result column="role_description" property="description"/>
</collection>
<collection property="permissions" ofType="com.sunyard.ssp.modules.user.entity.ScPermission">
<result column="permission_id" property="id"/>
<result column="permission_name" property="name"/>
<result column="permission_parent_id" property="parentId"/>
<result column="permission_type" property="pType"/>
<result column="permission_sort_order" property="sortOrder"/>
<result column="permission_component" property="component"/>
<result column="permission_path" property="path"/>
<result column="permission_title" property="title"/>
<result column="permission_icon" property="icon"/>
<result column="permission_level" property="pLevel"/>
<result column="permission_button_type" property="buttonType"/>
<result column="permission_status" property="pStatus"/>
<result column="permission_url" property="url"/>
<result column="permission_need_verify" property="needVerify"/>
</collection>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
ID
, USERNAME, PASSWORD, REALNAME, ORGANIZATION_ID, TEL, EMAIL, STATUS, UPDATE_TIME, POSITION_ID, AVATAR, SEX, PASS_UPDATE_TIME
</sql>
<sql id="User_Vo_Column_List">
tu
.
id
,
tu.username,
tu.realname,
tu.organization_id,
tu.tel,
tu.email,
tu.status,
tu.update_time,
tu.pass_update_time,
tu.position_id,
tu.password,
tu.sex,
tu.avatar,
tu.u_publickey,
tr.id as role_id,
tr.name as role_name,
tr.default_role as role_default_role,
tr.data_type as role_data_type,
tr.description as role_description,
tp.id as permission_id,
tp.name as permission_name,
tp.parent_id as permission_parent_id,
tp.p_type as permission_type,
tp.sort_order as permission_sort_order,
tp.component as permission_component,
tp.path as permission_path,
tp.title as permission_title,
tp.icon as permission_icon,
tp.p_level as permission_level,
tp.button_type as permission_button_type,
tp.p_status as permission_status,
tp.url as permission_url,
tp.need_verify as permission_need_verify
</sql>
<select id="findByUsername" resultMap="UserResultMap">
select DISTINCT
<include refid="User_Vo_Column_List"/>
from sc_user tu
left join sc_user_role tur on tu.id = tur.user_id
left join sc_role_permission trp on tur.role_id = trp.role_id
left join sc_permission tp on tp.id = trp.permission_id
left join sc_role tr on tr.id = tur.role_id
where username = #{username}
</select>
<select id="findall" resultMap="UserResultMap">
select
<include refid="Base_Column_List"/>
from sc_user
</select>
</mapper>

View File

@ -0,0 +1,31 @@
<?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.sunyard.ssp.modules.user.mapper.ScUserRoleMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.sunyard.ssp.modules.user.entity.ScUserRole">
<result column="ID" property="id" />
<result column="ROLE_ID" property="roleId" />
<result column="USER_ID" property="userId" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
ID, ROLE_ID, USER_ID
</sql>
<select id="findByUserId" resultType="com.sunyard.ssp.modules.user.entity.ScRole">
SELECT r.id id, name, r.data_type
FROM sc_user_role ur
LEFT JOIN sc_role r
ON ur.role_id = r.id
WHERE user_Id = #{userId}
</select>
<select id="findDepIdsByUserId" resultType="java.lang.String">
SELECT DISTINCT rd.department_id
FROM sc_role_department rd
WHERE role_id IN
( SELECT ur.role_id FROM sc_user_role ur WHERE ur.user_id = #{userId} )
</select>
</mapper>

View File

@ -0,0 +1,217 @@
<?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.sunyard.ssp.modules.monitor.transaction.mapper.StatisticalMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.sunyard.ssp.modules.monitor.transaction.entity.StatisticalResult">
<id column="successCount" property="successCount"/>
<result column="failCount" property="failCount"/>
<result column="statisticalTime" property="statisticalTime"/>
</resultMap>
<select id="countPieChart" resultMap="BaseResultMap" databaseId="mysql">
select SUM (SUCCESS_COUNT) as successCount,SUM (FAIL_COUNT) as failCount
from SC_BUSINESS_STATISTICS
<where>
<if test="statisticalParam.server != null and statisticalParam.server != ''">
and SERVER = #{statisticalParam.server}
</if>
<if test="statisticalParam.channelId != null">
and CHANNEL_ID = #{statisticalParam.channelId}
</if>
<if test="statisticalParam.solutionId != null">
and SOLUTION__ID = #{statisticalParam.solutionId}
</if>
<if test="statisticalParam.startTime != null and statisticalParam.endTime != null">
and `CURRENT_TIME` between str_to_date(#{statisticalParam.startTime},'%Y-%m-%d %H:%i:%s') and to_date(#{statisticalParam.endTime},'%Y-%m-%d %H:%i:%s')
</if>
</where>
</select>
<select id="countPieChart" resultMap="BaseResultMap" databaseId="oracle">
select SUM (SUCCESS_COUNT) as successCount,SUM (FAIL_COUNT) as failCount
from SC_BUSINESS_STATISTICS
<where>
<if test="statisticalParam.server != null and statisticalParam.server != ''">
and SERVER = #{statisticalParam.server}
</if>
<if test="statisticalParam.channelId != null">
and CHANNEL_ID = #{statisticalParam.channelId}
</if>
<if test="statisticalParam.solutionId != null">
and SOLUTION__ID = #{statisticalParam.solutionId}
</if>
<if test="statisticalParam.startTime != null and statisticalParam.endTime != null">
and "CURRENT_TIME" between to_date(#{statisticalParam.startTime},'YYYY-MM-DD HH24:MI:SS') and to_date(#{statisticalParam.endTime},'YYYY-MM-DD HH24:MI:SS')
</if>
</where>
</select>
<select id="countPieChart" resultMap="BaseResultMap" databaseId="dm">
select SUM (SUCCESS_COUNT) as successCount,SUM (FAIL_COUNT) as failCount
from SC_BUSINESS_STATISTICS
<where>
<if test="statisticalParam.server != null and statisticalParam.server != ''">
and SERVER = #{statisticalParam.server}
</if>
<if test="statisticalParam.channelId != null">
and CHANNEL_ID = #{statisticalParam.channelId}
</if>
<if test="statisticalParam.solutionId != null">
and SOLUTION__ID = #{statisticalParam.solutionId}
</if>
<if test="statisticalParam.startTime != null and statisticalParam.endTime != null">
and "CURRENT_TIME" between to_date(#{statisticalParam.startTime},'YYYY-MM-DD HH24:MI:SS') and to_date(#{statisticalParam.endTime},'YYYY-MM-DD HH24:MI:SS')
</if>
</where>
</select>
<select id="countLineChartByTimeInterval" resultMap="BaseResultMap" databaseId="mysql">
select
<if test="statisticalParam.timeInterval != null and statisticalParam.timeInterval == 'month'">
CONCAT(DATE_FORMAT(`CURRENT_TIME`, '%Y-%m-'),(DAY(`CURRENT_TIME`)+WEEKDAY(`CURRENT_TIME`-INTERVAL DAY(`CURRENT_TIME`) DAY)) DIV 7 + 1) as statisticalTime ,
</if>
<if test="statisticalParam.timeInterval != null and statisticalParam.timeInterval == 'week'">
DATE_FORMAT(`CURRENT_TIME`,'%Y-%m-%d') as statisticalTime,
</if>
<if test="statisticalParam.timeInterval != null and statisticalParam.timeInterval == 'day'">
DATE_FORMAT(`CURRENT_TIME`,'%Y-%m-%d %H') as statisticalTime,
</if>
SUM(SUCCESS_COUNT) as successCount,
SUM(FAIL_COUNT) as failCount
from SC_BUSINESS_STATISTICS
<where>
<if test="statisticalParam.server != null and statisticalParam.server != ''">
and SERVER = #{statisticalParam.server}
</if>
<if test="statisticalParam.channelId != null">
and CHANNEL_ID = #{statisticalParam.channelId}
</if>
<if test="statisticalParam.solutionNumber != null">
and SOLUTION_NUMBER = #{statisticalParam.solutionNumber}
</if>
<if test="statisticalParam.timeInterval != null and statisticalParam.timeInterval == 'month'">
and DATE_FORMAT(`CURRENT_TIME`,'%Y-%m') = date_format(#{statisticalParam.sqlStatisticalTime}, '%Y-%m')
</if>
<if test="statisticalParam.timeInterval != null and statisticalParam.timeInterval == 'week'">
and DATE_FORMAT(`CURRENT_TIME`,'%x-%v') = date_format(#{statisticalParam.sqlStatisticalTime}, '%x-%v')
</if>
<if test="statisticalParam.timeInterval != null and statisticalParam.timeInterval == 'day'">
and DATE_FORMAT(`CURRENT_TIME`,'%Y-%m-%d') = date_format(#{statisticalParam.sqlStatisticalTime}, '%Y-%m-%d')
</if>
</where>
group by statisticalTime
order by statisticalTime
</select>
<select id="countLineChartByTimeInterval" resultMap="BaseResultMap" databaseId="oracle">
select to_char("CURRENT_TIME",'${statisticalParam.timeIntervalFormat}') as statisticalTime,
SUM(SUCCESS_COUNT) as successCount,
SUM(FAIL_COUNT) as failCount
from SC_BUSINESS_STATISTICS
<where>
<if test="statisticalParam.server != null and statisticalParam.server != ''">
and SERVER = #{statisticalParam.server}
</if>
<if test="statisticalParam.channelId != null">
and CHANNEL_ID = #{statisticalParam.channelId}
</if>
<if test="statisticalParam.solutionNumber != null">
and SOLUTION_NUMBER = #{statisticalParam.solutionNumber}
</if>
<if test="statisticalParam.sqlStatisticalTime != null and statisticalParam.sqlStatisticalTimeFormat !=null">
and to_char(TRUNC("CURRENT_TIME"),'${statisticalParam.sqlStatisticalTimeFormat}') = (SELECT TO_CHAR (#{statisticalParam.sqlStatisticalTime}, '${statisticalParam.sqlStatisticalTimeFormat}') FROM DUAL)
</if>
</where>
group by to_char("CURRENT_TIME",'${statisticalParam.timeIntervalFormat}')
order by to_char("CURRENT_TIME",'${statisticalParam.timeIntervalFormat}')
</select>
<select id="countLineChartByTimeInterval" resultMap="BaseResultMap" databaseId="dm">
select to_char("CURRENT_TIME",'${statisticalParam.timeIntervalFormat}') as statisticalTime,
SUM(SUCCESS_COUNT) as successCount,
SUM(FAIL_COUNT) as failCount
from SC_BUSINESS_STATISTICS
<where>
<if test="statisticalParam.server != null and statisticalParam.server != ''">
and SERVER = #{statisticalParam.server}
</if>
<if test="statisticalParam.channelId != null">
and CHANNEL_ID = #{statisticalParam.channelId}
</if>
<if test="statisticalParam.solutionNumber != null">
and SOLUTION_NUMBER = #{statisticalParam.solutionNumber}
</if>
<if test="statisticalParam.sqlStatisticalTime != null and statisticalParam.sqlStatisticalTimeFormat !=null">
and to_char(TRUNC("CURRENT_TIME"),'${statisticalParam.sqlStatisticalTimeFormat}') = (SELECT TO_CHAR (#{statisticalParam.sqlStatisticalTime}, '${statisticalParam.sqlStatisticalTimeFormat}') FROM DUAL)
</if>
</where>
group by to_char("CURRENT_TIME",'${statisticalParam.timeIntervalFormat}')
order by to_char("CURRENT_TIME",'${statisticalParam.timeIntervalFormat}')
</select>
<select id="countLineChartByKeyGroup" resultMap="BaseResultMap" databaseId="mysql">
select
<if test="statisticalParam.timeInterval != null and statisticalParam.timeInterval == 'month'">
CONCAT(DATE_FORMAT(`CURRENT_TIME`, '%Y-%m-'),(DAY(`CURRENT_TIME`)+WEEKDAY(`CURRENT_TIME`-INTERVAL DAY(`CURRENT_TIME`) DAY)) DIV 7 + 1) as statisticalTime ,
</if>
<if test="statisticalParam.timeInterval != null and statisticalParam.timeInterval == 'week'">
DATE_FORMAT(`CURRENT_TIME`,'%Y-%m-%d') as statisticalTime,
</if>
<if test="statisticalParam.timeInterval != null and statisticalParam.timeInterval == 'day'">
DATE_FORMAT(`CURRENT_TIME`,'%Y-%m-%d %H') as statisticalTime,
</if>
SUM(SUCCESS_COUNT) as successCount,
SUM(FAIL_COUNT) as failCount
from SC_BUSINESS_STATISTICS
<where>
<if test="statisticalParam.group != null and statisticalParam.group != ''">
and "GROUP" = #{statisticalParam.group}
</if>
<if test="statisticalParam.timeInterval != null and statisticalParam.timeInterval == 'month'">
and DATE_FORMAT(`CURRENT_TIME`,'%Y-%m') = date_format(#{statisticalParam.sqlStatisticalTime}, '%Y-%m')
</if>
<if test="statisticalParam.timeInterval != null and statisticalParam.timeInterval == 'week'">
and DATE_FORMAT(`CURRENT_TIME`,'%x-%v') = date_format(#{statisticalParam.sqlStatisticalTime}, '%x-%v')
</if>
<if test="statisticalParam.timeInterval != null and statisticalParam.timeInterval == 'day'">
and DATE_FORMAT(`CURRENT_TIME`,'%Y-%m-%d') = date_format(#{statisticalParam.sqlStatisticalTime}, '%Y-%m-%d')
</if>
</where>
group by statisticalTime
order by statisticalTime
</select>
<select id="countLineChartByKeyGroup" resultMap="BaseResultMap" databaseId="oracle">
select to_char("CURRENT_TIME",'${statisticalParam.timeIntervalFormat}') as statisticalTime ,
SUM(SUCCESS_COUNT) as successCount,
SUM(FAIL_COUNT) as failCount
from SC_BUSINESS_STATISTICS
<where>
<if test="statisticalParam.group != null and statisticalParam.group != ''">
and "GROUP" = #{statisticalParam.group}
</if>
<if test="statisticalParam.sqlStatisticalTime != null and statisticalParam.sqlStatisticalTimeFormat !=null">
and to_char(TRUNC("CURRENT_TIME"),'${statisticalParam.sqlStatisticalTimeFormat}') = (SELECT TO_CHAR (#{statisticalParam.sqlStatisticalTime}, '${statisticalParam.sqlStatisticalTimeFormat}') FROM DUAL)
</if>
</where>
group by to_char("CURRENT_TIME",'${statisticalParam.timeIntervalFormat}')
order by to_char("CURRENT_TIME",'${statisticalParam.timeIntervalFormat}')
</select>
<select id="countLineChartByKeyGroup" resultMap="BaseResultMap" databaseId="dm">
select to_char("CURRENT_TIME",'${statisticalParam.timeIntervalFormat}') as statisticalTime ,
SUM(SUCCESS_COUNT) as successCount,
SUM(FAIL_COUNT) as failCount
from SC_BUSINESS_STATISTICS
<where>
<if test="statisticalParam.group != null and statisticalParam.group != ''">
and "GROUP" = #{statisticalParam.group}
</if>
<if test="statisticalParam.sqlStatisticalTime != null and statisticalParam.sqlStatisticalTimeFormat !=null">
and to_char(TRUNC("CURRENT_TIME"),'${statisticalParam.sqlStatisticalTimeFormat}') = (SELECT TO_CHAR (#{statisticalParam.sqlStatisticalTime}, '${statisticalParam.sqlStatisticalTimeFormat}') FROM DUAL)
</if>
</where>
group by to_char("CURRENT_TIME",'${statisticalParam.timeIntervalFormat}')
order by to_char("CURRENT_TIME",'${statisticalParam.timeIntervalFormat}')
</select>
</mapper>