U盾管理
parent
b73f9521ae
commit
dac572e817
@ -0,0 +1,140 @@
|
|||||||
|
package com.glxp.api.controller.ud;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.github.pagehelper.Page;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.glxp.api.annotation.AuthRuleAnnotation;
|
||||||
|
import com.glxp.api.annotation.Log;
|
||||||
|
import com.glxp.api.common.enums.ResultEnum;
|
||||||
|
import com.glxp.api.common.res.BaseResponse;
|
||||||
|
import com.glxp.api.common.util.ResultVOUtils;
|
||||||
|
import com.glxp.api.constant.BusinessType;
|
||||||
|
import com.glxp.api.controller.BaseController;
|
||||||
|
import com.glxp.api.entity.anno.AnncmntDevEntity;
|
||||||
|
import com.glxp.api.entity.auth.AuthAdmin;
|
||||||
|
import com.glxp.api.entity.ud.UdInfoEntity;
|
||||||
|
import com.glxp.api.entity.ud.UdProducePlanEntity;
|
||||||
|
import com.glxp.api.req.anno.AnncmntDevEntityRequest;
|
||||||
|
import com.glxp.api.req.system.DeleteRequest;
|
||||||
|
import com.glxp.api.req.ud.UdInfoEntityRequest;
|
||||||
|
import com.glxp.api.res.PageSimpleResponse;
|
||||||
|
import com.glxp.api.service.anno.AnncmntDevService;
|
||||||
|
import com.glxp.api.service.ud.UdInfoService;
|
||||||
|
import com.glxp.api.util.BeanCopyUtils;
|
||||||
|
import com.glxp.api.util.StringUtils;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户信息
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@ApiIgnore
|
||||||
|
@Validated
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/ud/info")
|
||||||
|
public class UdInfoController extends BaseController {
|
||||||
|
|
||||||
|
private final UdInfoService udInfoService;
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/list")
|
||||||
|
public BaseResponse list(UdInfoEntityRequest request, BindingResult bindingResult) {
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
||||||
|
}
|
||||||
|
int offset = (request.getPage() - 1) * request.getLimit();
|
||||||
|
Page<UdInfoEntity> pages = PageHelper.offsetPage(offset, request.getLimit());
|
||||||
|
List<UdInfoEntity> list = udInfoService.list(getQueryWrapper(request));
|
||||||
|
PageSimpleResponse<UdInfoEntity> pageSimpleResponse = new PageSimpleResponse<>();
|
||||||
|
pageSimpleResponse.setTotal(pages.getTotal());
|
||||||
|
pageSimpleResponse.setList(list);
|
||||||
|
|
||||||
|
return ResultVOUtils.success(pageSimpleResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AuthRuleAnnotation("")
|
||||||
|
@PostMapping("/save")
|
||||||
|
@Log(title = "U盾管理", businessType = BusinessType.INSERT)
|
||||||
|
public BaseResponse save(@RequestBody UdInfoEntity entity,
|
||||||
|
BindingResult bindingResult) {
|
||||||
|
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
||||||
|
}
|
||||||
|
AuthAdmin authAdmin = getUser();
|
||||||
|
entity.setStatus("2");
|
||||||
|
entity.setCheckStatus("2");
|
||||||
|
entity.setCreateTime(new Date());
|
||||||
|
entity.setCreateUser(authAdmin.getId()+"");
|
||||||
|
entity.setUpdateTime(new Date());
|
||||||
|
entity.setUpdateUser( authAdmin.getId()+"");
|
||||||
|
boolean b = udInfoService.save(entity);
|
||||||
|
if (!b) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
|
||||||
|
}
|
||||||
|
return ResultVOUtils.success("添加成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@AuthRuleAnnotation("")
|
||||||
|
@PostMapping("/edit")
|
||||||
|
@Log(title = "U盾管理", businessType = BusinessType.UPDATE)
|
||||||
|
public BaseResponse edit(@RequestBody @Valid UdInfoEntity entity,
|
||||||
|
BindingResult bindingResult) {
|
||||||
|
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
||||||
|
}
|
||||||
|
if (entity.getId() == null) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
||||||
|
}
|
||||||
|
UdInfoEntity originEntity = udInfoService.getById(entity.getId());
|
||||||
|
if (originEntity == null) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
||||||
|
}
|
||||||
|
AuthAdmin authAdmin = getUser();
|
||||||
|
entity.setUpdateTime(new Date());
|
||||||
|
entity.setUpdateUser( authAdmin.getId()+"");
|
||||||
|
boolean b = udInfoService.updateById(entity);
|
||||||
|
if (!b) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResultVOUtils.success("修改成功!");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@AuthRuleAnnotation("")
|
||||||
|
@PostMapping("/delete")
|
||||||
|
@Log(title = "U盾管理", businessType = BusinessType.DELETE)
|
||||||
|
public BaseResponse delete(@RequestBody DeleteRequest deleteRequest) {
|
||||||
|
|
||||||
|
if (StringUtils.isEmpty(deleteRequest.getId())) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
||||||
|
}
|
||||||
|
boolean b = udInfoService.removeById(deleteRequest.getId());
|
||||||
|
|
||||||
|
if (!b) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
|
||||||
|
}
|
||||||
|
return ResultVOUtils.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static QueryWrapper<UdInfoEntity> getQueryWrapper(UdInfoEntityRequest request) {
|
||||||
|
UdInfoEntity entity = new UdInfoEntity();
|
||||||
|
BeanCopyUtils.copy(request, entity);
|
||||||
|
QueryWrapper queryWrapper = new QueryWrapper(entity);
|
||||||
|
return queryWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,201 @@
|
|||||||
|
package com.glxp.api.controller.ud;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.github.pagehelper.Page;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.glxp.api.annotation.AuthRuleAnnotation;
|
||||||
|
import com.glxp.api.annotation.Log;
|
||||||
|
import com.glxp.api.common.enums.ResultEnum;
|
||||||
|
import com.glxp.api.common.res.BaseResponse;
|
||||||
|
import com.glxp.api.common.util.ResultVOUtils;
|
||||||
|
import com.glxp.api.constant.BusinessType;
|
||||||
|
import com.glxp.api.constant.Constant;
|
||||||
|
import com.glxp.api.controller.BaseController;
|
||||||
|
import com.glxp.api.entity.anno.AnncmntDevEntity;
|
||||||
|
import com.glxp.api.entity.auth.AuthAdmin;
|
||||||
|
import com.glxp.api.entity.ud.UdProducePlanEntity;
|
||||||
|
import com.glxp.api.entity.ud.UdProducePlanEntity;
|
||||||
|
import com.glxp.api.req.system.DeleteRequest;
|
||||||
|
import com.glxp.api.req.ud.UdProducePlanEntityRequest;
|
||||||
|
import com.glxp.api.res.PageSimpleResponse;
|
||||||
|
import com.glxp.api.service.auth.AuthAdminService;
|
||||||
|
import com.glxp.api.service.ud.UdProducePlanService;
|
||||||
|
import com.glxp.api.util.BeanCopyUtils;
|
||||||
|
import com.glxp.api.util.GennerOrderUtils;
|
||||||
|
import com.glxp.api.util.OrderNoTypeBean;
|
||||||
|
import com.glxp.api.util.StringUtils;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户信息
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@ApiIgnore
|
||||||
|
@Validated
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/ud/plan")
|
||||||
|
public class UdProducePlanController extends BaseController {
|
||||||
|
|
||||||
|
private final UdProducePlanService udProducePlanService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AuthAdminService authAdminService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
GennerOrderUtils gennerOrderUtils;
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/list")
|
||||||
|
public BaseResponse list(UdProducePlanEntityRequest request, BindingResult bindingResult) {
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
||||||
|
}
|
||||||
|
Map<Long,String> userMap = authAdminService.getEmployeeNameMap();
|
||||||
|
|
||||||
|
int offset = (request.getPage() - 1) * request.getLimit();
|
||||||
|
Page<UdProducePlanEntity> pages = PageHelper.offsetPage(offset, request.getLimit());
|
||||||
|
List<UdProducePlanEntity> list = udProducePlanService.list(getQueryWrapper(request));
|
||||||
|
for(UdProducePlanEntity entity:list){
|
||||||
|
entity.setCreateUserName(StringUtils.isNotEmpty(entity.getCreateUser())?userMap.get(Long.parseLong(entity.getCreateUser())):"");
|
||||||
|
entity.setAuditUserName(StringUtils.isNotEmpty(entity.getAuditUser())?userMap.get(Long.parseLong(entity.getAuditUser())):"");
|
||||||
|
}
|
||||||
|
|
||||||
|
PageSimpleResponse<UdProducePlanEntity> pageSimpleResponse = new PageSimpleResponse<>();
|
||||||
|
pageSimpleResponse.setTotal(pages.getTotal());
|
||||||
|
pageSimpleResponse.setList(list);
|
||||||
|
|
||||||
|
return ResultVOUtils.success(pageSimpleResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AuthRuleAnnotation("")
|
||||||
|
@PostMapping("/save")
|
||||||
|
@Log(title = "U盾制作计划管理", businessType = BusinessType.INSERT)
|
||||||
|
public BaseResponse save(@RequestBody UdProducePlanEntity entity,
|
||||||
|
BindingResult bindingResult) {
|
||||||
|
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
||||||
|
}
|
||||||
|
String orderNo = gennerOrderUtils.getUDNo();
|
||||||
|
AuthAdmin authAdmin = getUser();
|
||||||
|
entity.setRealityNumber(0);
|
||||||
|
entity.setStatus("2");
|
||||||
|
entity.setProduceNo(orderNo);
|
||||||
|
entity.setCreateTime(new Date());
|
||||||
|
entity.setCreateUser(authAdmin.getId()+"");
|
||||||
|
entity.setUpdateTime(new Date());
|
||||||
|
entity.setUpdateUser( authAdmin.getId()+"");
|
||||||
|
boolean b = udProducePlanService.save(entity);
|
||||||
|
if (!b) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
|
||||||
|
}
|
||||||
|
return ResultVOUtils.success("添加成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@AuthRuleAnnotation("")
|
||||||
|
@PostMapping("/edit")
|
||||||
|
@Log(title = "U盾制作计划管理", businessType = BusinessType.UPDATE)
|
||||||
|
public BaseResponse edit(@RequestBody @Valid UdProducePlanEntity entity,
|
||||||
|
BindingResult bindingResult) {
|
||||||
|
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
||||||
|
}
|
||||||
|
if (entity.getId() == null) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
||||||
|
}
|
||||||
|
UdProducePlanEntity originEntity = udProducePlanService.getById(entity.getId());
|
||||||
|
if (originEntity == null) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
||||||
|
}
|
||||||
|
AuthAdmin authAdmin = getUser();
|
||||||
|
entity.setUpdateTime(new Date());
|
||||||
|
entity.setUpdateUser( authAdmin.getId()+"");
|
||||||
|
boolean b = udProducePlanService.updateById(entity);
|
||||||
|
if (!b) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResultVOUtils.success("修改成功!");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@AuthRuleAnnotation("")
|
||||||
|
@PostMapping("/updateStatus")
|
||||||
|
@Log(title = "U盾制作计划管理", businessType = BusinessType.DELETE)
|
||||||
|
public BaseResponse updateStatus(@RequestBody UdProducePlanEntity entity,
|
||||||
|
BindingResult bindingResult) {
|
||||||
|
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
||||||
|
}
|
||||||
|
if (entity.getId() == null) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
||||||
|
}
|
||||||
|
UdProducePlanEntity originEntity = udProducePlanService.getById(entity.getId());
|
||||||
|
if (originEntity == null) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
||||||
|
}
|
||||||
|
AuthAdmin authAdmin = getUser();
|
||||||
|
originEntity.setUpdateTime(new Date());
|
||||||
|
originEntity.setUpdateUser( authAdmin.getId()+"");
|
||||||
|
originEntity.setStatus("1");
|
||||||
|
boolean b = udProducePlanService.updateById(originEntity);
|
||||||
|
if (!b) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResultVOUtils.success("修改成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@AuthRuleAnnotation("")
|
||||||
|
@PostMapping("/delete")
|
||||||
|
@Log(title = "U盾制作计划管理", businessType = BusinessType.DELETE)
|
||||||
|
public BaseResponse delete(@RequestBody DeleteRequest deleteRequest) {
|
||||||
|
|
||||||
|
if (StringUtils.isEmpty(deleteRequest.getId())) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
|
||||||
|
}
|
||||||
|
boolean b = udProducePlanService.removeById(deleteRequest.getId());
|
||||||
|
|
||||||
|
if (!b) {
|
||||||
|
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
|
||||||
|
}
|
||||||
|
return ResultVOUtils.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static QueryWrapper<UdProducePlanEntity> getQueryWrapper(UdProducePlanEntityRequest request) {
|
||||||
|
UdProducePlanEntity entity = new UdProducePlanEntity();
|
||||||
|
BeanCopyUtils.copy(request, entity);
|
||||||
|
QueryWrapper queryWrapper = new QueryWrapper(entity);
|
||||||
|
if(StringUtils.isNotBlank(request.getEndTime())){
|
||||||
|
queryWrapper.le("produceTime",request.getEndTime());
|
||||||
|
}
|
||||||
|
if(StringUtils.isNotBlank(request.getStartTime())){
|
||||||
|
queryWrapper.ge("produceTime",request.getStartTime());
|
||||||
|
}
|
||||||
|
if(StringUtils.isNotBlank(request.getEndAduditTime())){
|
||||||
|
queryWrapper.le("auditTime",request.getEndAduditTime());
|
||||||
|
}
|
||||||
|
if(StringUtils.isNotBlank(request.getStartAduditTime())){
|
||||||
|
queryWrapper.ge("auditTime",request.getStartAduditTime());
|
||||||
|
}
|
||||||
|
return queryWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.glxp.api.dao.ud;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.glxp.api.entity.ud.UdInfoEntity;
|
||||||
|
import com.glxp.api.entity.ud.UdProducePlanEntity;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface UdInfoMapper extends BaseMapper<UdInfoEntity> {
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.glxp.api.dao.ud;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.glxp.api.entity.anno.AnncmntDevEntity;
|
||||||
|
import com.glxp.api.entity.ud.UdProducePlanEntity;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface UdProducePlanMapper extends BaseMapper<UdProducePlanEntity> {
|
||||||
|
}
|
@ -0,0 +1,115 @@
|
|||||||
|
package com.glxp.api.entity.ud;
|
||||||
|
|
||||||
|
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.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@TableName(value = "ud_info")
|
||||||
|
public class UdInfoEntity implements Serializable {
|
||||||
|
@TableId(value = "id")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 企业id
|
||||||
|
*/
|
||||||
|
@TableField(value = "companyId")
|
||||||
|
private Integer companyId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生产计划id
|
||||||
|
*/
|
||||||
|
@TableField(value = "producePlanId")
|
||||||
|
private String producePlanId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* U盾唯一ID
|
||||||
|
*/
|
||||||
|
@TableField(value = "uniqueId")
|
||||||
|
private String uniqueId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* U盾序列号
|
||||||
|
*/
|
||||||
|
@TableField(value = "serialNumber")
|
||||||
|
private String serialNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 密文字符串
|
||||||
|
*/
|
||||||
|
@TableField(value = "ciphertext")
|
||||||
|
private String ciphertext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分配时间
|
||||||
|
*/
|
||||||
|
@TableField(value = "allocateTime")
|
||||||
|
private Date allocateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分配状态
|
||||||
|
*/
|
||||||
|
@TableField(value = "allocateStatus")
|
||||||
|
private String allocateStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验时间
|
||||||
|
*/
|
||||||
|
@TableField(value = "checkTime")
|
||||||
|
private Date checkTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验时间
|
||||||
|
*/
|
||||||
|
@TableField(value = "checkStatus")
|
||||||
|
private String checkStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
@TableField(value = "status")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
@TableField(value = "`createUser`")
|
||||||
|
private String createUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@TableField(value = "createTime")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新人
|
||||||
|
*/
|
||||||
|
@TableField(value = "updateUser")
|
||||||
|
private String updateUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@TableField(value = "updateTime")
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
@TableField(value = "remark")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
}
|
@ -0,0 +1,121 @@
|
|||||||
|
package com.glxp.api.entity.ud;
|
||||||
|
|
||||||
|
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.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@TableName(value = "ud_produce_plan")
|
||||||
|
public class UdProducePlanEntity implements Serializable {
|
||||||
|
@TableId(value = "id")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 制作单号
|
||||||
|
*/
|
||||||
|
@TableField(value = "produceNo")
|
||||||
|
private String produceNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 制作日期
|
||||||
|
*/
|
||||||
|
@TableField(value = "produceTime")
|
||||||
|
@JsonFormat( pattern = "yyyy-MM-dd")
|
||||||
|
private Date produceTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计划数量
|
||||||
|
*/
|
||||||
|
@TableField(value = "planNumber")
|
||||||
|
private Integer planNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实际数量
|
||||||
|
*/
|
||||||
|
@TableField(value = "realityNumber")
|
||||||
|
private Integer realityNumber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审核时间
|
||||||
|
*/
|
||||||
|
@TableField(value = "auditTime")
|
||||||
|
private Date auditTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审核人
|
||||||
|
*/
|
||||||
|
@TableField(value = "auditUser")
|
||||||
|
private String auditUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审核人
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String auditUserName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审核状态
|
||||||
|
*/
|
||||||
|
@TableField(value = "auditStatus")
|
||||||
|
private String auditStatus;
|
||||||
|
/**
|
||||||
|
* U盾生产厂家
|
||||||
|
*/
|
||||||
|
@TableField(value = "manufacturer")
|
||||||
|
private String manufacturer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
@TableField(value = "status")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
@TableField(value = "createUser")
|
||||||
|
private String createUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String createUserName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@TableField(value = "createTime")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新人
|
||||||
|
*/
|
||||||
|
@TableField(value = "updateUser")
|
||||||
|
private String updateUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@TableField(value = "updateTime")
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
@TableField(value = "remark")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.glxp.api.req.ud;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.glxp.api.util.page.ListPageRequest;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UdInfoEntityRequest extends ListPageRequest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生产计划id
|
||||||
|
*/
|
||||||
|
@TableField(value = "producePlanId")
|
||||||
|
private String producePlanId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* U盾唯一ID
|
||||||
|
*/
|
||||||
|
@TableField(value = "uniqueId")
|
||||||
|
private String uniqueId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* U盾序列号
|
||||||
|
*/
|
||||||
|
@TableField(value = "serialNumber")
|
||||||
|
private String serialNumber;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package com.glxp.api.req.ud;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.glxp.api.util.page.ListPageRequest;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UdProducePlanEntityRequest extends ListPageRequest {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
/**
|
||||||
|
* startTime
|
||||||
|
*/
|
||||||
|
private String startTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* endTime
|
||||||
|
*/
|
||||||
|
private String endTime;
|
||||||
|
/**
|
||||||
|
* startAduditTime
|
||||||
|
*/
|
||||||
|
private String startAduditTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* endAduditTime
|
||||||
|
*/
|
||||||
|
private String endAduditTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.glxp.api.service.ud;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.glxp.api.dao.anno.AnncmntDevMapper;
|
||||||
|
import com.glxp.api.dao.ud.UdInfoMapper;
|
||||||
|
import com.glxp.api.entity.anno.AnncmntDevEntity;
|
||||||
|
import com.glxp.api.entity.ud.UdInfoEntity;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class UdInfoService extends ServiceImpl<UdInfoMapper, UdInfoEntity> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.glxp.api.service.ud;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.glxp.api.dao.ud.UdInfoMapper;
|
||||||
|
import com.glxp.api.dao.ud.UdProducePlanMapper;
|
||||||
|
import com.glxp.api.entity.ud.UdInfoEntity;
|
||||||
|
import com.glxp.api.entity.ud.UdProducePlanEntity;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class UdProducePlanService extends ServiceImpl<UdProducePlanMapper, UdProducePlanEntity> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,312 @@
|
|||||||
|
package com.glxp.api.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
|
||||||
|
public class SoftKey {
|
||||||
|
|
||||||
|
private String myhex(byte indata)
|
||||||
|
{
|
||||||
|
String outstring;
|
||||||
|
outstring=String.format("%X",indata);
|
||||||
|
if(outstring.length()<2)outstring="0"+outstring;
|
||||||
|
return outstring;
|
||||||
|
}
|
||||||
|
|
||||||
|
//若某字节为负数则需将其转成无符号正数
|
||||||
|
private long conver(byte temp){
|
||||||
|
long tempInt = (int)temp;
|
||||||
|
if(tempInt < 0){
|
||||||
|
tempInt += 256;
|
||||||
|
}
|
||||||
|
return tempInt;
|
||||||
|
}
|
||||||
|
|
||||||
|
//以下用于将16进制字符串转化为无符号长整型
|
||||||
|
private int HexToInt(String s)
|
||||||
|
{
|
||||||
|
String [] hexch = { "0", "1", "2", "3", "4", "5", "6", "7",
|
||||||
|
"8", "9", "A", "B", "C", "D", "E", "F"};
|
||||||
|
int i, j;
|
||||||
|
int r, n, k;
|
||||||
|
String ch;
|
||||||
|
|
||||||
|
k = 1; r = 0;
|
||||||
|
for (i = s.length(); i > 0; i--)
|
||||||
|
{
|
||||||
|
ch = s.substring(i - 1, i-1+1);
|
||||||
|
n = 0;
|
||||||
|
for (j = 0; j < 16; j++)
|
||||||
|
{
|
||||||
|
if (ch.compareToIgnoreCase(hexch[j]) ==0 )
|
||||||
|
{
|
||||||
|
n = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
r += (n * k);
|
||||||
|
k *= 16;
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String StrEnc(String InString , String Key)//使用增强算法,加密字符串
|
||||||
|
{
|
||||||
|
|
||||||
|
byte [] b,outb;
|
||||||
|
byte []temp_b=InString.getBytes();
|
||||||
|
byte [] temp=new byte[8],outtemp=new byte[8];
|
||||||
|
int n,i,nlen,outlen;
|
||||||
|
String outstring;
|
||||||
|
|
||||||
|
nlen = temp_b.length;
|
||||||
|
nlen=nlen+1;
|
||||||
|
if( nlen < 8 )
|
||||||
|
outlen = 8;
|
||||||
|
else
|
||||||
|
outlen = nlen;
|
||||||
|
b=new byte[outlen];
|
||||||
|
outb=new byte[outlen];
|
||||||
|
|
||||||
|
for(n=0;n<nlen-1;n++)
|
||||||
|
{
|
||||||
|
b[n]=temp_b[n];
|
||||||
|
}
|
||||||
|
|
||||||
|
outb=b.clone();
|
||||||
|
|
||||||
|
for( n = 0; n<=outlen - 8 ;n=n+ 8)
|
||||||
|
{
|
||||||
|
for (i = 0; i < 8; i++) temp[i] = b[i + n];
|
||||||
|
EnCode(temp, outtemp, Key);
|
||||||
|
for( i = 0 ;i<8;i++) outb[i + n] = outtemp[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
outstring = "";
|
||||||
|
for (n = 0 ;n<= outlen - 1;n++)
|
||||||
|
{
|
||||||
|
outstring = outstring +myhex(outb[n]) ;
|
||||||
|
}
|
||||||
|
return outstring;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String StrDec(String InString , String Key)//使用增强算法,解密字符串
|
||||||
|
{
|
||||||
|
|
||||||
|
byte [] b,outb;
|
||||||
|
byte [] temp=new byte[8],outtemp=new byte[8];
|
||||||
|
int n,i,nlen,outlen;
|
||||||
|
String outstring,temp_string;
|
||||||
|
|
||||||
|
|
||||||
|
nlen = InString.length();
|
||||||
|
if( nlen < 16 ) outlen = 16;
|
||||||
|
outlen = nlen / 2;
|
||||||
|
b=new byte[outlen];
|
||||||
|
outb=new byte[outlen];
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
for (n = 1 ;n<= nlen ;n=n+2)
|
||||||
|
{
|
||||||
|
temp_string = InString.substring(n-1, n-1+2);
|
||||||
|
b[i] = (byte)HexToInt(temp_string);
|
||||||
|
i = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
outb=b.clone();
|
||||||
|
|
||||||
|
for( n = 0; n<=outlen - 8 ;n=n+ 8)
|
||||||
|
{
|
||||||
|
for (i = 0; i < 8; i++) temp[i] = b[i + n];
|
||||||
|
DeCode(temp, outtemp, Key);
|
||||||
|
for( i = 0 ;i<8;i++) outb[i + n] = outtemp[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
outstring=new String(outb);
|
||||||
|
outstring=outstring.trim();
|
||||||
|
return outstring;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EnCode(byte[] inb, byte[] outb, String Key )
|
||||||
|
{
|
||||||
|
|
||||||
|
long cnDelta,y,z,a,b,c,d,temp_2;
|
||||||
|
long [] buf=new long[16];
|
||||||
|
int n,i,nlen;
|
||||||
|
long sum;
|
||||||
|
long temp,temp_1;
|
||||||
|
long mask=4294967295L;
|
||||||
|
|
||||||
|
//UInt32 temp, temp_1;
|
||||||
|
String temp_String ;
|
||||||
|
|
||||||
|
|
||||||
|
cnDelta = 2654435769L;
|
||||||
|
sum = 0;
|
||||||
|
|
||||||
|
nlen = Key.length();
|
||||||
|
i = 0;
|
||||||
|
for( n = 1 ;n<= nlen ;n=n+2)
|
||||||
|
{
|
||||||
|
temp_String =Key.substring(n-1, n-1+2);
|
||||||
|
buf[i] =HexToInt(temp_String);
|
||||||
|
i = i + 1;
|
||||||
|
}
|
||||||
|
a = 0 ; b = 0 ; c = 0 ; d = 0;
|
||||||
|
for(n = 0;n<=3;n++)
|
||||||
|
{
|
||||||
|
a = (buf[n] << (n * 8)) | a;
|
||||||
|
b = (buf[n + 4] << (n * 8)) | b;
|
||||||
|
c = (buf[n + 4 + 4] << (n * 8)) | c;
|
||||||
|
d = (buf[n + 4 + 4 + 4] << (n * 8)) | d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
y = 0;
|
||||||
|
z = 0;
|
||||||
|
for(n = 0;n<=3;n++)
|
||||||
|
{
|
||||||
|
temp_2 = conver(inb[n]);
|
||||||
|
y = (temp_2 << (n * 8)) | y;
|
||||||
|
temp_2 = conver(inb[n + 4]);
|
||||||
|
z = (temp_2 << (n * 8)) | z;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
n = 32;
|
||||||
|
|
||||||
|
while (n > 0)
|
||||||
|
{
|
||||||
|
sum = (cnDelta + sum)& mask;
|
||||||
|
|
||||||
|
temp = (z << 4) & mask;
|
||||||
|
temp = (temp + a) & mask;
|
||||||
|
temp_1 = (z + sum) & mask;
|
||||||
|
temp = (temp ^ temp_1) & mask;
|
||||||
|
temp_1 = (z >> 5) & mask;
|
||||||
|
temp_1 = (temp_1 + b) & mask;
|
||||||
|
temp = (temp ^ temp_1) & mask;
|
||||||
|
temp = (temp + y) & mask;
|
||||||
|
y = temp & mask;
|
||||||
|
/*y += ((z << 4) + a) ^ (z + sum) ^ ((z >> 5) + b); */
|
||||||
|
|
||||||
|
temp = (y << 4) & mask;
|
||||||
|
temp = (temp + c) & mask;
|
||||||
|
temp_1 = (y + sum) & mask;
|
||||||
|
temp = (temp ^ temp_1) & mask;
|
||||||
|
temp_1 = (y >> 5) & mask;
|
||||||
|
temp_1 = (temp_1 + d) & mask;
|
||||||
|
temp = (temp ^ temp_1) & mask;
|
||||||
|
temp = (z + temp) & mask;
|
||||||
|
z = temp & mask;
|
||||||
|
/* z += ((y << 4) + c) ^ (y + sum) ^ ((y >> 5) + d); */
|
||||||
|
n = n - 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
for(n = 0;n<=3;n++)
|
||||||
|
{
|
||||||
|
outb[n] = (byte)((y >>> (n * 8)) & 255);
|
||||||
|
outb[n + 4] =(byte)((z >>> (n * 8)) & 255);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeCode(byte[] inb, byte[] outb, String Key )
|
||||||
|
{
|
||||||
|
|
||||||
|
long cnDelta,y,z,a,b,c,d,temp_2;
|
||||||
|
long [] buf=new long[16];
|
||||||
|
int n,i,nlen;
|
||||||
|
long sum;
|
||||||
|
long temp,temp_1;
|
||||||
|
|
||||||
|
long mask=4294967295L;
|
||||||
|
|
||||||
|
//UInt32 temp, temp_1;
|
||||||
|
String temp_String ;
|
||||||
|
|
||||||
|
|
||||||
|
cnDelta = 2654435769L;
|
||||||
|
sum = 3337565984L;
|
||||||
|
|
||||||
|
nlen = Key.length();
|
||||||
|
i = 0;
|
||||||
|
for( n = 1 ;n<= nlen ;n=n+2)
|
||||||
|
{
|
||||||
|
temp_String =Key.substring(n-1, n-1+2);
|
||||||
|
buf[i] =HexToInt(temp_String);
|
||||||
|
i = i + 1;
|
||||||
|
}
|
||||||
|
a = 0 ; b = 0 ; c = 0 ; d = 0;
|
||||||
|
for(n = 0;n<=3;n++)
|
||||||
|
{
|
||||||
|
a = (buf[n] << (n * 8)) | a;
|
||||||
|
b = (buf[n + 4] << (n * 8)) | b;
|
||||||
|
c = (buf[n + 4 + 4] << (n * 8)) | c;
|
||||||
|
d = (buf[n + 4 + 4 + 4] << (n * 8)) | d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
y = 0;
|
||||||
|
z = 0;
|
||||||
|
for(n = 0;n<=3;n++)
|
||||||
|
{
|
||||||
|
temp_2 = conver(inb[n]);
|
||||||
|
y = (temp_2 << (n * 8)) | y;
|
||||||
|
temp_2 = conver(inb[n + 4]);
|
||||||
|
z = (temp_2 << (n * 8)) | z;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
n = 32;
|
||||||
|
|
||||||
|
while (n > 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
temp = (y << 4) & mask;
|
||||||
|
temp = (temp + c) & mask;
|
||||||
|
temp_1 = (y + sum) & mask;
|
||||||
|
temp = (temp ^ temp_1) & mask;
|
||||||
|
temp_1 = (y >> 5) & mask;
|
||||||
|
temp_1 = (temp_1 + d) & mask;
|
||||||
|
temp = (temp ^ temp_1) & mask;
|
||||||
|
temp = (z - temp) & mask;
|
||||||
|
z = temp & mask;
|
||||||
|
/* z += ((y << 4) + c) ^ (y + sum) ^ ((y >> 5) + d); */
|
||||||
|
|
||||||
|
temp = (z << 4) & mask;
|
||||||
|
temp = (temp + a) & mask;
|
||||||
|
temp_1 = (z + sum) & mask;
|
||||||
|
temp = (temp ^ temp_1) & mask;
|
||||||
|
temp_1 = (z >> 5) & mask;
|
||||||
|
temp_1 = (temp_1 + b) & mask;
|
||||||
|
temp = (temp ^ temp_1) & mask;
|
||||||
|
temp = (y - temp ) & mask;
|
||||||
|
y = temp & mask;
|
||||||
|
/*y += ((z << 4) + a) ^ (z + sum) ^ ((z >> 5) + b); */
|
||||||
|
|
||||||
|
sum = (sum-cnDelta)& mask;
|
||||||
|
n = n - 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
for(n = 0;n<=3;n++)
|
||||||
|
{
|
||||||
|
outb[n] = (byte)((y >>> (n * 8)) & 255);
|
||||||
|
outb[n + 4] =(byte)((z >>> (n * 8)) & 255);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main (String[] args)
|
||||||
|
{
|
||||||
|
System.out.println(IdUtil.simpleUUID());
|
||||||
|
SoftKey mysoftkey = new SoftKey();
|
||||||
|
String InString,Outstring,Outstring_2;
|
||||||
|
InString="1122222222";
|
||||||
|
Outstring=mysoftkey.StrEnc(InString,"5cb4b5fcfe474657b5621f34d0ea6df9");
|
||||||
|
Outstring_2=mysoftkey.StrDec(Outstring,"5cb4b5fcfe474657b5621f34d0ea6df9");
|
||||||
|
System.out.println(Outstring);
|
||||||
|
System.out.println(Outstring_2);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,96 @@
|
|||||||
|
package com.glxp.api.util.sm2;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.HexUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.crypto.BCUtil;
|
||||||
|
import cn.hutool.crypto.SecureUtil;
|
||||||
|
import cn.hutool.crypto.SmUtil;
|
||||||
|
import cn.hutool.crypto.asymmetric.KeyType;
|
||||||
|
import cn.hutool.crypto.asymmetric.SM2;
|
||||||
|
import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey;
|
||||||
|
import org.bouncycastle.jce.ECNamedCurveTable;
|
||||||
|
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||||
|
import org.bouncycastle.jce.spec.ECNamedCurveParameterSpec;
|
||||||
|
import org.bouncycastle.jce.spec.ECNamedCurveSpec;
|
||||||
|
import org.bouncycastle.util.encoders.Hex;
|
||||||
|
|
||||||
|
import java.security.*;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.security.KeyFactory;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.interfaces.ECPublicKey;
|
||||||
|
import java.security.spec.*;
|
||||||
|
import java.util.Base64;
|
||||||
|
|
||||||
|
public class Test {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
|
||||||
|
String text = "wangjing";
|
||||||
|
|
||||||
|
//使用随机生成的密钥对加密或解密
|
||||||
|
System.out.println("使用随机生成的密钥对加密或解密====开始");
|
||||||
|
SM2 sm2 = SmUtil.sm2();
|
||||||
|
// 公钥加密
|
||||||
|
String encryptStr = sm2.encryptBcd(text, KeyType.PublicKey);
|
||||||
|
System.out.println("公钥加密:" + encryptStr);
|
||||||
|
//私钥解密
|
||||||
|
String decryptStr = StrUtil.utf8Str(sm2.decryptFromBcd(encryptStr, KeyType.PrivateKey));
|
||||||
|
System.out.println("私钥解密:" + decryptStr);
|
||||||
|
System.out.println("使用随机生成的密钥对加密或解密====结束");
|
||||||
|
|
||||||
|
|
||||||
|
//使用自定义密钥对加密或解密
|
||||||
|
System.out.println("使用自定义密钥对加密或解密====开始");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
String hutoolPrivateKeyHex = HexUtil.encodeHexStr(BCUtil.encodeECPrivateKey(sm2.getPrivateKey()));
|
||||||
|
String hutoolPublicKeyHex = HexUtil.encodeHexStr(((BCECPublicKey) sm2.getPublicKey()).getQ().getEncoded(false));
|
||||||
|
String hutoolPublicKeyHexX = HexUtil.encodeHexStr(((BCECPublicKey) sm2.getPublicKey()).getQ().getXCoord().getEncoded());
|
||||||
|
String hutoolPublicKeyHexY = HexUtil.encodeHexStr(((BCECPublicKey) sm2.getPublicKey()).getQ().getYCoord().getEncoded());
|
||||||
|
|
||||||
|
System.out.println(hutoolPrivateKeyHex);
|
||||||
|
System.out.println(hutoolPublicKeyHex);
|
||||||
|
System.out.println(hutoolPublicKeyHexX);
|
||||||
|
System.out.println(hutoolPublicKeyHexY);
|
||||||
|
|
||||||
|
|
||||||
|
ECPublicKey publicKey = hexToSM2PublicKey(hutoolPublicKeyHexX, hutoolPublicKeyHexY);
|
||||||
|
String hutoolPublicKeyHex1 = HexUtil.encodeHexStr(publicKey.getEncoded());
|
||||||
|
System.out.println(hutoolPublicKeyHex1);
|
||||||
|
SM2 sm22 = SmUtil.sm2(hutoolPrivateKeyHex, hutoolPublicKeyHex1);
|
||||||
|
// 公钥加密
|
||||||
|
String encryptStr2 = sm22.encryptBcd(text, KeyType.PublicKey);
|
||||||
|
System.out.println("公钥加密:" + encryptStr2);
|
||||||
|
//私钥解密
|
||||||
|
String decryptStr2 = StrUtil.utf8Str(sm22.decryptFromBcd(encryptStr2, KeyType.PrivateKey));
|
||||||
|
System.out.println("私钥解密:" + decryptStr2);
|
||||||
|
System.out.println("使用自定义密钥对加密或解密====结束");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static ECPublicKey hexToSM2PublicKey(String x, String y) {
|
||||||
|
ECPublicKey pubkey = null;
|
||||||
|
try {
|
||||||
|
KeyFactory keyFactory = KeyFactory.getInstance("EC");
|
||||||
|
ECPoint ecPoint = new ECPoint(
|
||||||
|
new BigInteger(x, 16), new BigInteger(y, 16));
|
||||||
|
|
||||||
|
ECNamedCurveParameterSpec parameterSpec = ECNamedCurveTable.getParameterSpec("sm2p256v1");
|
||||||
|
ECNamedCurveSpec spec = new ECNamedCurveSpec("sm2p256v1", parameterSpec.getCurve(), parameterSpec.getG(), parameterSpec.getN(), parameterSpec.getH(), parameterSpec.getSeed());
|
||||||
|
|
||||||
|
ECPublicKeySpec keySpec = new ECPublicKeySpec(ecPoint, spec);
|
||||||
|
pubkey = new BCECPublicKey("BC", keySpec, BouncyCastleProvider.CONFIGURATION);
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return pubkey;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
<?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.glxp.api.dao.ud.UdInfoMapper">
|
||||||
|
|
||||||
|
</mapper>
|
@ -0,0 +1,5 @@
|
|||||||
|
<?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.glxp.api.dao.ud.UdProducePlanMapper">
|
||||||
|
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue