删除无用模块-docking模块
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.jero.boot</groupId>
|
||||
<artifactId>byd-structuredplugins</artifactId>
|
||||
<version>2.5.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>laws-modules-docking</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.jero.boot</groupId>
|
||||
<artifactId>laws-modules</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.banboocloud</groupId>
|
||||
<artifactId>bim-codec</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/bim-codec-1.0.0.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
-153
@@ -1,153 +0,0 @@
|
||||
package com.jero.modules.docking.asms.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.modules.docking.asms.entity.LawsAsmsDomestic;
|
||||
import com.jero.modules.docking.asms.service.ILawsAsmsDomesticService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.jero.common.system.base.controller.JeroController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import com.jero.common.aspect.annotation.AutoLog;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
|
||||
|
||||
/**
|
||||
* @Description: ASMS国内法规
|
||||
* @Author: jero-boot
|
||||
* @Date: 2023-10-20
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags="ASMS国内法规")
|
||||
@RestController
|
||||
@RequestMapping("/docking/asms/lawsAsmsDomestic")
|
||||
@Slf4j
|
||||
public class LawsAsmsDomesticController extends JeroController<LawsAsmsDomestic, ILawsAsmsDomesticService> {
|
||||
@Autowired
|
||||
private ILawsAsmsDomesticService lawsAsmsDomesticService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param lawsAsmsDomestic
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "ASMS国内法规-分页列表查询")
|
||||
@ApiOperation(value="ASMS国内法规-分页列表查询", notes="ASMS国内法规-分页列表查询")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<IPage<LawsAsmsDomestic>> queryPageList(LawsAsmsDomestic lawsAsmsDomestic,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
IPage<LawsAsmsDomestic> pageList = lawsAsmsDomesticService.queryPage(lawsAsmsDomestic, pageNo, pageSize, req);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param lawsAsmsDomestic
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "ASMS国内法规-列表查询")
|
||||
@ApiOperation(value="ASMS国内法规-列表查询", notes="ASMS国内法规-列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<List<LawsAsmsDomestic>> queryList(LawsAsmsDomestic lawsAsmsDomestic, HttpServletRequest req) {
|
||||
List<LawsAsmsDomestic> list = lawsAsmsDomesticService.queryList(lawsAsmsDomestic, req);
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param lawsAsmsDomestic
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "ASMS国内法规-添加")
|
||||
@ApiOperation(value="ASMS国内法规-添加", notes="ASMS国内法规-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<T> add(@Validated @RequestBody LawsAsmsDomestic lawsAsmsDomestic) {
|
||||
lawsAsmsDomesticService.add(lawsAsmsDomestic);
|
||||
return Result.OK("操作成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param lawsAsmsDomestic
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "ASMS国内法规-编辑")
|
||||
@ApiOperation(value="ASMS国内法规-编辑", notes="ASMS国内法规-编辑")
|
||||
@PostMapping(value = "/edit")
|
||||
public Result<T> edit(@Validated @RequestBody LawsAsmsDomestic lawsAsmsDomestic) {
|
||||
lawsAsmsDomesticService.editById(lawsAsmsDomestic);
|
||||
return Result.OK("操作成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "ASMS国内法规-通过id删除")
|
||||
@ApiOperation(value="ASMS国内法规-通过id删除", notes="ASMS国内法规-通过id删除")
|
||||
@PostMapping(value = "/delete")
|
||||
public Result<T> delete(@RequestBody Map<String, String> map) {
|
||||
if(!map.containsKey("id") || StringUtils.isEmpty(map.get("id"))){
|
||||
return Result.error("请选择数据!");
|
||||
}
|
||||
lawsAsmsDomesticService.deleteById(map.get("id"));
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "ASMS国内法规-批量删除")
|
||||
@ApiOperation(value="ASMS国内法规-批量删除", notes="ASMS国内法规-批量删除")
|
||||
@PostMapping(value = "/deleteBatch")
|
||||
public Result<T> deleteBatch(@RequestBody Map<String, String> map) {
|
||||
if(!map.containsKey("ids") || StringUtils.isEmpty(map.get("ids"))){
|
||||
return Result.error("请选择数据!");
|
||||
}
|
||||
this.lawsAsmsDomesticService.deleteByIds(Arrays.asList(map.get("ids").split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "ASMS国内法规-通过id查询")
|
||||
@ApiOperation(value="ASMS国内法规-通过id查询", notes="ASMS国内法规-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<LawsAsmsDomestic> queryById(@RequestParam(name="id") String id) {
|
||||
LawsAsmsDomestic lawsAsmsDomestic = lawsAsmsDomesticService.queryById(id);
|
||||
if(lawsAsmsDomestic==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(lawsAsmsDomestic);
|
||||
}
|
||||
|
||||
}
|
||||
-188
@@ -1,188 +0,0 @@
|
||||
package com.jero.modules.docking.asms.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.modules.docking.asms.entity.LawsAsmsOpenApi;
|
||||
import com.jero.modules.docking.asms.service.ILawsAsmsOpenApiService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.jero.modules.docking.asms.util.AsmsPostUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.jero.common.system.base.controller.JeroController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import com.jero.common.aspect.annotation.AutoLog;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 汽车标准数字化平台ASMS开放API接口管理
|
||||
* @Author: jero-boot
|
||||
* @Date: 2023-10-18
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags="汽车标准数字化平台ASMS开放API接口管理")
|
||||
@RestController
|
||||
@RequestMapping("/docking/asms/api/lawsAsmsOpenApi")
|
||||
@Slf4j
|
||||
public class LawsAsmsOpenApiController extends JeroController<LawsAsmsOpenApi, ILawsAsmsOpenApiService> {
|
||||
@Autowired
|
||||
private ILawsAsmsOpenApiService lawsAsmsOpenApiService;
|
||||
@Autowired
|
||||
private AsmsPostUtil asmsPostUtil;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param lawsAsmsOpenApi
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "汽车标准数字化平台ASMS开放API接口管理-分页列表查询")
|
||||
@ApiOperation(value="汽车标准数字化平台ASMS开放API接口管理-分页列表查询", notes="汽车标准数字化平台ASMS开放API接口管理-分页列表查询")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<IPage<LawsAsmsOpenApi>> queryPageList(LawsAsmsOpenApi lawsAsmsOpenApi,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
IPage<LawsAsmsOpenApi> pageList = lawsAsmsOpenApiService.queryPage(lawsAsmsOpenApi, pageNo, pageSize, req);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param lawsAsmsOpenApi
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "汽车标准数字化平台ASMS开放API接口管理-列表查询")
|
||||
@ApiOperation(value="汽车标准数字化平台ASMS开放API接口管理-列表查询", notes="汽车标准数字化平台ASMS开放API接口管理-列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<List<LawsAsmsOpenApi>> queryList(LawsAsmsOpenApi lawsAsmsOpenApi, HttpServletRequest req) {
|
||||
List<LawsAsmsOpenApi> list = lawsAsmsOpenApiService.queryList(lawsAsmsOpenApi, req);
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param lawsAsmsOpenApi
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "汽车标准数字化平台ASMS开放API接口管理-添加")
|
||||
@ApiOperation(value="汽车标准数字化平台ASMS开放API接口管理-添加", notes="汽车标准数字化平台ASMS开放API接口管理-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<T> add(@Validated @RequestBody LawsAsmsOpenApi lawsAsmsOpenApi) {
|
||||
lawsAsmsOpenApi.setStatus("0");
|
||||
lawsAsmsOpenApiService.add(lawsAsmsOpenApi);
|
||||
return Result.OK("操作成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param lawsAsmsOpenApi
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "汽车标准数字化平台ASMS开放API接口管理-编辑")
|
||||
@ApiOperation(value="汽车标准数字化平台ASMS开放API接口管理-编辑", notes="汽车标准数字化平台ASMS开放API接口管理-编辑")
|
||||
@PostMapping(value = "/edit")
|
||||
public Result<T> edit(@Validated @RequestBody LawsAsmsOpenApi lawsAsmsOpenApi) {
|
||||
lawsAsmsOpenApiService.editById(lawsAsmsOpenApi);
|
||||
return Result.OK("操作成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "汽车标准数字化平台ASMS开放API接口管理-通过id删除")
|
||||
@ApiOperation(value="汽车标准数字化平台ASMS开放API接口管理-通过id删除", notes="汽车标准数字化平台ASMS开放API接口管理-通过id删除")
|
||||
@PostMapping(value = "/delete")
|
||||
public Result<T> delete(@RequestBody Map<String, String> map) {
|
||||
if(!map.containsKey("id") || StringUtils.isEmpty(map.get("id"))){
|
||||
return Result.error("请选择数据!");
|
||||
}
|
||||
lawsAsmsOpenApiService.deleteById(map.get("id"));
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "汽车标准数字化平台ASMS开放API接口管理-批量删除")
|
||||
@ApiOperation(value="汽车标准数字化平台ASMS开放API接口管理-批量删除", notes="汽车标准数字化平台ASMS开放API接口管理-批量删除")
|
||||
@PostMapping(value = "/deleteBatch")
|
||||
public Result<T> deleteBatch(@RequestBody Map<String, String> map) {
|
||||
if(!map.containsKey("ids") || StringUtils.isEmpty(map.get("ids"))){
|
||||
return Result.error("请选择数据!");
|
||||
}
|
||||
this.lawsAsmsOpenApiService.deleteByIds(Arrays.asList(map.get("ids").split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "汽车标准数字化平台ASMS开放API接口管理-通过id查询")
|
||||
@ApiOperation(value="汽车标准数字化平台ASMS开放API接口管理-通过id查询", notes="汽车标准数字化平台ASMS开放API接口管理-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<LawsAsmsOpenApi> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
LawsAsmsOpenApi lawsAsmsOpenApi = lawsAsmsOpenApiService.queryById(id);
|
||||
if(lawsAsmsOpenApi==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(lawsAsmsOpenApi);
|
||||
}
|
||||
|
||||
@AutoLog(value = "查询接口返回信息")
|
||||
@ApiOperation(value="查询接口返回信息", notes="查询接口返回信息")
|
||||
@GetMapping(value = "/getInfoById")
|
||||
public Result<Object> getInfoById(@RequestParam(name="id") String id) {
|
||||
LawsAsmsOpenApi lawsAsmsOpenApi = lawsAsmsOpenApiService.queryById(id);
|
||||
if(lawsAsmsOpenApi==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
Map<String, String> map = null;
|
||||
if (StringUtils.isNotBlank(lawsAsmsOpenApi.getQueryParamJson())) {
|
||||
map = (Map<String, String>) JSON.parse(lawsAsmsOpenApi.getQueryParamJson());
|
||||
}
|
||||
return Result.OK(asmsPostUtil.sendGetReq(lawsAsmsOpenApi.getApiUrl(), map));
|
||||
}
|
||||
|
||||
@AutoLog(value = "批量同步")
|
||||
@ApiOperation(value="批量同步", notes="批量同步")
|
||||
@GetMapping(value = "/syncBatch")
|
||||
public Result<Object> syncBatch(@RequestParam(name="ids") String ids) {
|
||||
lawsAsmsOpenApiService.syncBatch(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("操作成功");
|
||||
}
|
||||
|
||||
@AutoLog(value = "批量删除原字典配置项")
|
||||
@ApiOperation(value="批量删除原字典配置项", notes="批量删除原字典配置项")
|
||||
@GetMapping(value = "/removeDictItemBatch")
|
||||
public Result<Object> removeDictItemBatch(@RequestParam(name="ids") String ids) {
|
||||
lawsAsmsOpenApiService.removeDictItemBatch(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("操作成功");
|
||||
}
|
||||
|
||||
}
|
||||
-143
@@ -1,143 +0,0 @@
|
||||
package com.jero.modules.docking.asms.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import com.jero.common.aspect.annotation.Dict;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
|
||||
|
||||
/**
|
||||
* @Description: ASMS国内法规
|
||||
* @Author: jero-boot
|
||||
* @Date: 2023-10-20
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("laws_asms_domestic")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="laws_asms_domestic对象", description="ASMS国内法规")
|
||||
public class LawsAsmsDomestic implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键ID*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
private java.lang.String id;
|
||||
/**标准法规编号/标准号*/
|
||||
@Excel(name = "标准法规编号/标准号", width = 15)
|
||||
@ApiModelProperty(value = "标准法规编号/标准号")
|
||||
private java.lang.String code;
|
||||
/**标准法规名称/标准名称*/
|
||||
@Excel(name = "标准法规名称/标准名称", width = 15)
|
||||
@ApiModelProperty(value = "标准法规名称/标准名称")
|
||||
private java.lang.String name;
|
||||
/**法规英文名称*/
|
||||
@Excel(name = "法规英文名称", width = 15)
|
||||
@ApiModelProperty(value = "法规英文名称")
|
||||
private java.lang.String englishName;
|
||||
/**标准法规类别/标准类别*/
|
||||
@Excel(name = "标准法规类别/标准类别", width = 15)
|
||||
@ApiModelProperty(value = "标准法规类别/标准类别")
|
||||
private java.lang.String type;
|
||||
/**适用认证*/
|
||||
@Excel(name = "适用认证", width = 15)
|
||||
@ApiModelProperty(value = "适用认证")
|
||||
private java.lang.String applicableCertificationListString;
|
||||
/**适用车型拼接名称*/
|
||||
@Excel(name = "适用车型拼接名称", width = 15)
|
||||
@ApiModelProperty(value = "适用车型拼接名称")
|
||||
private java.lang.String applicableModelsListString;
|
||||
/**采标程度*/
|
||||
@Excel(name = "采标程度", width = 15)
|
||||
@ApiModelProperty(value = "采标程度")
|
||||
private java.lang.String degreeAdoption;
|
||||
/**起草人*/
|
||||
@Excel(name = "起草人", width = 15)
|
||||
@ApiModelProperty(value = "起草人")
|
||||
private java.lang.String draftingPeople;
|
||||
/**起草单位*/
|
||||
@Excel(name = "起草单位", width = 15)
|
||||
@ApiModelProperty(value = "起草单位")
|
||||
private java.lang.String draftingUnit;
|
||||
/**标准领域名称*/
|
||||
@Excel(name = "标准领域名称", width = 15)
|
||||
@ApiModelProperty(value = "标准领域名称")
|
||||
private java.lang.String focalPointName;
|
||||
/**实施日期*/
|
||||
@Excel(name = "实施日期", width = 15)
|
||||
@ApiModelProperty(value = "实施日期")
|
||||
private java.lang.String implementationDate;
|
||||
/**采用国际标准号*/
|
||||
@Excel(name = "采用国际标准号", width = 15)
|
||||
@ApiModelProperty(value = "采用国际标准号")
|
||||
private java.lang.String internationalStandard;
|
||||
/**新车实施日期*/
|
||||
@Excel(name = "新车实施日期", width = 15)
|
||||
@ApiModelProperty(value = "新车实施日期")
|
||||
private java.lang.String newCarImplementationDate;
|
||||
/**新注册车实施日期*/
|
||||
@Excel(name = "新注册车实施日期", width = 15)
|
||||
@ApiModelProperty(value = "新注册车实施日期")
|
||||
private java.lang.String newRegisterCarImplementationDate;
|
||||
/**动力类型*/
|
||||
@Excel(name = "动力类型", width = 15)
|
||||
@ApiModelProperty(value = "动力类型")
|
||||
private java.lang.String powerTypeListString;
|
||||
/**在产车实施日期*/
|
||||
@Excel(name = "在产车实施日期", width = 15)
|
||||
@ApiModelProperty(value = "在产车实施日期")
|
||||
private java.lang.String productionCarImplementationDate;
|
||||
/**提出部门*/
|
||||
@Excel(name = "提出部门", width = 15)
|
||||
@ApiModelProperty(value = "提出部门")
|
||||
private java.lang.String proposingDepartment;
|
||||
/**发布日期*/
|
||||
@Excel(name = "发布日期", width = 15)
|
||||
@ApiModelProperty(value = "发布日期")
|
||||
private java.lang.String publishDate;
|
||||
/**代替标准号*/
|
||||
@Excel(name = "代替标准号", width = 15)
|
||||
@ApiModelProperty(value = "代替标准号")
|
||||
private java.lang.String replaceCode;
|
||||
/**适用范围*/
|
||||
@Excel(name = "适用范围", width = 15)
|
||||
@ApiModelProperty(value = "适用范围")
|
||||
private java.lang.String scopeApplication;
|
||||
/**标准性质*/
|
||||
@Excel(name = "标准性质", width = 15)
|
||||
@ApiModelProperty(value = "标准性质")
|
||||
private java.lang.String standardNature;
|
||||
/**标准状态*/
|
||||
@Excel(name = "标准状态", width = 15)
|
||||
@ApiModelProperty(value = "标准状态")
|
||||
private java.lang.String standardStatus;
|
||||
/**分标委*/
|
||||
@Excel(name = "分标委", width = 15)
|
||||
@ApiModelProperty(value = "分标委")
|
||||
private java.lang.String subcommittee;
|
||||
/**创建时间*/
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private java.lang.String createTimeString;
|
||||
/**更新时间*/
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private java.lang.String updateTimeString;
|
||||
/**同步标识*/
|
||||
@Excel(name = "同步标识", width = 15)
|
||||
@ApiModelProperty(value = "同步标识")
|
||||
@Dict(dicCode = "sync_flag")
|
||||
private java.lang.String syncFlag;
|
||||
}
|
||||
-67
@@ -1,67 +0,0 @@
|
||||
package com.jero.modules.docking.asms.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import com.jero.common.aspect.annotation.Dict;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 汽车标准数字化平台ASMS开放API接口管理
|
||||
* @Author: jero-boot
|
||||
* @Date: 2023-10-18
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("laws_asms_open_api")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="laws_asms_open_api对象", description="汽车标准数字化平台ASMS开放API接口管理")
|
||||
public class LawsAsmsOpenApi implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键ID*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
private java.lang.String id;
|
||||
/**api名称*/
|
||||
@Excel(name = "api名称", width = 15)
|
||||
@ApiModelProperty(value = "api名称")
|
||||
private java.lang.String apiName;
|
||||
/**api路径*/
|
||||
@Excel(name = "api路径", width = 15)
|
||||
@ApiModelProperty(value = "api路径")
|
||||
private java.lang.String apiUrl;
|
||||
/**数据字典id*/
|
||||
@Excel(name = "数据字典id", width = 15)
|
||||
@ApiModelProperty(value = "数据字典id")
|
||||
@Dict(dictTable = "sys_dict", dicCode = "id", dicText = "dict_name")
|
||||
private java.lang.String dictId;
|
||||
/**接口类型(1字典,2分标委,3法规)*/
|
||||
@Excel(name = "接口类型(1字典,2分标委,3法规)", width = 15)
|
||||
@ApiModelProperty(value = "接口类型(1字典,2分标委,3法规)")
|
||||
@Dict(dicCode = "asms_open_api_type")
|
||||
private java.lang.String apiType;
|
||||
/**参数map*/
|
||||
@Excel(name = "参数map", width = 15)
|
||||
@ApiModelProperty(value = "参数map")
|
||||
private java.lang.String queryParamJson;
|
||||
/**状态(0未同步、1已同步)*/
|
||||
@Excel(name = "状态(0未同步、1已同步)", width = 15)
|
||||
@ApiModelProperty(value = "状态(0未同步、1已同步)")
|
||||
@Dict(dicCode = "sync_status")
|
||||
private java.lang.String status;
|
||||
}
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
package com.jero.modules.docking.asms.job;
|
||||
|
||||
import com.jero.common.util.SpringContextUtils;
|
||||
import com.jero.modules.docking.asms.service.impl.SynchronizationAsmsService;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/11/3 13:43
|
||||
* @Description: 同步asms国内法规
|
||||
*/
|
||||
public class AsmsDomesticJob implements Job {
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
SynchronizationAsmsService bean = SpringContextUtils.getBean(SynchronizationAsmsService.class);
|
||||
bean.syncDomestic();
|
||||
}
|
||||
}
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
package com.jero.modules.docking.asms.job;
|
||||
|
||||
import com.jero.common.util.SpringContextUtils;
|
||||
import com.jero.modules.docking.asms.service.impl.SynchronizationAsmsService;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/11/3 13:44
|
||||
* @Description: 同步asms文档拆分
|
||||
*/
|
||||
public class AsmsSplitJob implements Job {
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
SynchronizationAsmsService bean = SpringContextUtils.getBean(SynchronizationAsmsService.class);
|
||||
bean.syncSplit();
|
||||
}
|
||||
}
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
package com.jero.modules.docking.asms.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.jero.modules.docking.asms.entity.LawsAsmsDomestic;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: ASMS国内法规
|
||||
* @Author: jero-boot
|
||||
* @Date: 2023-10-20
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface LawsAsmsDomesticMapper extends BaseMapper<LawsAsmsDomestic> {
|
||||
|
||||
}
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
package com.jero.modules.docking.asms.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.jero.modules.docking.asms.entity.LawsAsmsOpenApi;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 汽车标准数字化平台ASMS开放API接口管理
|
||||
* @Author: jero-boot
|
||||
* @Date: 2023-10-18
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface LawsAsmsOpenApiMapper extends BaseMapper<LawsAsmsOpenApi> {
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/18 16:25
|
||||
* @Description: 物理删除字典配置项数据
|
||||
**/
|
||||
void removeDictItemBatch(@Param("dictIdList") List<String> dictIdList);
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/23 9:54
|
||||
* @Description: 获取asms国内法规的标准性质列表
|
||||
**/
|
||||
List<String> getStandardTypeList();
|
||||
|
||||
}
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
<?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.jero.modules.docking.asms.mapper.LawsAsmsDomesticMapper">
|
||||
<resultMap id="LawsAsmsDomesticResultMap" type="com.jero.modules.docking.asms.entity.LawsAsmsDomestic">
|
||||
<id column="id" property="id" />
|
||||
<result column="code" property="code" />
|
||||
<result column="name" property="name" />
|
||||
<result column="english_name" property="englishName" />
|
||||
<result column="type" property="type" />
|
||||
<result column="applicable_certification_list_string" property="applicableCertificationListString" />
|
||||
<result column="applicable_models_list_string" property="applicableModelsListString" />
|
||||
<result column="degree_adoption" property="degreeAdoption" />
|
||||
<result column="drafting_people" property="draftingPeople" />
|
||||
<result column="drafting_unit" property="draftingUnit" />
|
||||
<result column="focal_point_name" property="focalPointName" />
|
||||
<result column="implementation_date" property="implementationDate" />
|
||||
<result column="international_standard" property="internationalStandard" />
|
||||
<result column="new_car_implementation_date" property="newCarImplementationDate" />
|
||||
<result column="new_register_car_implementation_date" property="newRegisterCarImplementationDate" />
|
||||
<result column="power_type_list_string" property="powerTypeListString" />
|
||||
<result column="production_car_implementation_date" property="productionCarImplementationDate" />
|
||||
<result column="proposing_department" property="proposingDepartment" />
|
||||
<result column="publish_date" property="publishDate" />
|
||||
<result column="replace_code" property="replaceCode" />
|
||||
<result column="scope_application" property="scopeApplication" />
|
||||
<result column="standard_nature" property="standardNature" />
|
||||
<result column="standard_status" property="standardStatus" />
|
||||
<result column="subcommittee" property="subcommittee" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
<result column="sync_flag" property="syncFlag" />
|
||||
</resultMap>
|
||||
</mapper>
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
<?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.jero.modules.docking.asms.mapper.LawsAsmsOpenApiMapper">
|
||||
<resultMap id="LawsAsmsOpenApiResultMap" type="com.jero.modules.docking.asms.entity.LawsAsmsOpenApi">
|
||||
<id column="id" property="id" />
|
||||
<result column="api_name" property="apiName" />
|
||||
<result column="api_url" property="apiUrl" />
|
||||
<result column="dict_id" property="dictId" />
|
||||
<result column="api_type" property="apiType" />
|
||||
<result column="query_param_json" property="queryParamJson" />
|
||||
</resultMap>
|
||||
<delete id="removeDictItemBatch">
|
||||
DELETE FROM sys_dict_item WHERE dict_id IN
|
||||
<foreach collection="dictIdList" item="item" index="index" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</delete>
|
||||
<select id="getStandardTypeList" resultType="java.lang.String">
|
||||
SELECT DISTINCT SUBSTRING_INDEX(code, ' ', 1) AS standard_class
|
||||
FROM laws_asms_domestic;
|
||||
</select>
|
||||
</mapper>
|
||||
-76
@@ -1,76 +0,0 @@
|
||||
package com.jero.modules.docking.asms.service;
|
||||
|
||||
import com.jero.modules.docking.asms.entity.LawsAsmsDomestic;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: ASMS国内法规
|
||||
* @Author: jero-boot
|
||||
* @Date: 2023-10-20
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ILawsAsmsDomesticService extends IService<LawsAsmsDomestic> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param lawsAsmsDomestic
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
IPage<LawsAsmsDomestic> queryPage(LawsAsmsDomestic lawsAsmsDomestic, Integer pageNo, Integer pageSize, HttpServletRequest req);
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param lawsAsmsDomestic
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
List<LawsAsmsDomestic> queryList(LawsAsmsDomestic lawsAsmsDomestic, HttpServletRequest req);
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param lawsAsmsDomestic
|
||||
* @return
|
||||
*/
|
||||
void add(LawsAsmsDomestic lawsAsmsDomestic);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param lawsAsmsDomestic
|
||||
* @return
|
||||
*/
|
||||
void editById(LawsAsmsDomestic lawsAsmsDomestic);
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
void deleteById(String id);
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
void deleteByIds(List<String> ids);
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
LawsAsmsDomestic queryById(String id);
|
||||
}
|
||||
-90
@@ -1,90 +0,0 @@
|
||||
package com.jero.modules.docking.asms.service;
|
||||
|
||||
import com.jero.modules.docking.asms.entity.LawsAsmsOpenApi;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 汽车标准数字化平台ASMS开放API接口管理
|
||||
* @Author: jero-boot
|
||||
* @Date: 2023-10-18
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ILawsAsmsOpenApiService extends IService<LawsAsmsOpenApi> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param lawsAsmsOpenApi
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
IPage<LawsAsmsOpenApi> queryPage(LawsAsmsOpenApi lawsAsmsOpenApi, Integer pageNo, Integer pageSize, HttpServletRequest req);
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param lawsAsmsOpenApi
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
List<LawsAsmsOpenApi> queryList(LawsAsmsOpenApi lawsAsmsOpenApi, HttpServletRequest req);
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param lawsAsmsOpenApi
|
||||
* @return
|
||||
*/
|
||||
void add(LawsAsmsOpenApi lawsAsmsOpenApi);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param lawsAsmsOpenApi
|
||||
* @return
|
||||
*/
|
||||
void editById(LawsAsmsOpenApi lawsAsmsOpenApi);
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
void deleteById(String id);
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
void deleteByIds(List<String> ids);
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
LawsAsmsOpenApi queryById(String id);
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/18 13:46
|
||||
* @Description: 批量同步
|
||||
**/
|
||||
void syncBatch(List<String> idList);
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/18 16:20
|
||||
* @Description: 批量删除原字典配置项
|
||||
**/
|
||||
void removeDictItemBatch(List<String> idList);
|
||||
}
|
||||
-113
@@ -1,113 +0,0 @@
|
||||
package com.jero.modules.docking.asms.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.jero.modules.docking.asms.entity.LawsAsmsDomestic;
|
||||
import com.jero.modules.docking.asms.mapper.LawsAsmsDomesticMapper;
|
||||
import com.jero.modules.docking.asms.service.ILawsAsmsDomesticService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.system.query.QueryGenerator;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
|
||||
/**
|
||||
* @Description: ASMS国内法规
|
||||
* @Author: jero-boot
|
||||
* @Date: 2023-10-20
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = JeroBootException.class)
|
||||
public class LawsAsmsDomesticServiceImpl extends ServiceImpl<LawsAsmsDomesticMapper, LawsAsmsDomestic> implements ILawsAsmsDomesticService {
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param lawsAsmsDomestic
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public IPage<LawsAsmsDomestic> queryPage(LawsAsmsDomestic lawsAsmsDomestic, Integer pageNo, Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<LawsAsmsDomestic> queryWrapper = QueryGenerator.initQueryWrapper(lawsAsmsDomestic, req.getParameterMap());
|
||||
Page<LawsAsmsDomestic> page = new Page<>(pageNo, pageSize);
|
||||
return page(page, queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param lawsAsmsDomestic
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<LawsAsmsDomestic> queryList(LawsAsmsDomestic lawsAsmsDomestic, HttpServletRequest req) {
|
||||
return list(QueryGenerator.initQueryWrapper(lawsAsmsDomestic, req.getParameterMap()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param lawsAsmsDomestic
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void add(LawsAsmsDomestic lawsAsmsDomestic) {
|
||||
save(lawsAsmsDomestic);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param lawsAsmsDomestic
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void editById(LawsAsmsDomestic lawsAsmsDomestic) {
|
||||
saveOrUpdate(lawsAsmsDomestic);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void deleteById(String id) {
|
||||
removeById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void deleteByIds(List<String> ids) {
|
||||
removeByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public LawsAsmsDomestic queryById(String id) {
|
||||
return getById(id);
|
||||
}
|
||||
}
|
||||
-880
@@ -1,880 +0,0 @@
|
||||
package com.jero.modules.docking.asms.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
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.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.query.QueryGenerator;
|
||||
import com.jero.common.util.MinioUtil;
|
||||
import com.jero.common.util.UUIDUtils;
|
||||
import com.jero.modules.docking.asms.entity.LawsAsmsDomestic;
|
||||
import com.jero.modules.docking.asms.entity.LawsAsmsOpenApi;
|
||||
import com.jero.modules.docking.asms.mapper.LawsAsmsOpenApiMapper;
|
||||
import com.jero.modules.docking.asms.service.ILawsAsmsDomesticService;
|
||||
import com.jero.modules.docking.asms.service.ILawsAsmsOpenApiService;
|
||||
import com.jero.modules.docking.asms.util.AlphanumericComparator;
|
||||
import com.jero.modules.docking.asms.util.AsmsPostUtil;
|
||||
import com.jero.modules.oss.entity.OSSFile;
|
||||
import com.jero.modules.oss.service.IOSSFileService;
|
||||
import com.jero.modules.split.entity.SarFileSplitInfoEO;
|
||||
import com.jero.modules.split.entity.SarFileSplitItemsValEO;
|
||||
import com.jero.modules.split.entity.SarFileSplitMenuEO;
|
||||
import com.jero.modules.split.mapper.SarFileSplitMenuEOMapper;
|
||||
import com.jero.modules.split.service.ISarFileSplitInfoService;
|
||||
import com.jero.modules.split.service.ISarFileSplitItemsValEOService;
|
||||
import com.jero.modules.split.service.ISarFileSplitMenuEOService;
|
||||
import com.jero.modules.system.entity.SysDict;
|
||||
import com.jero.modules.system.entity.SysDictItem;
|
||||
import com.jero.modules.system.service.ISysDictItemService;
|
||||
import com.jero.modules.system.service.ISysDictService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.InputStream;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 汽车标准数字化平台ASMS开放API接口管理
|
||||
* @Author: jero-boot
|
||||
* @Date: 2023-10-18
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = JeroBootException.class)
|
||||
public class LawsAsmsOpenApiServiceImpl extends ServiceImpl<LawsAsmsOpenApiMapper, LawsAsmsOpenApi> implements ILawsAsmsOpenApiService {
|
||||
|
||||
@Autowired
|
||||
private AsmsPostUtil asmsPostUtil;
|
||||
@Autowired
|
||||
private ISysDictItemService sysDictItemService;
|
||||
@Autowired
|
||||
private ILawsAsmsDomesticService lawsAsmsDomesticService;
|
||||
@Autowired
|
||||
private LawsAsmsOpenApiMapper lawsAsmsOpenApiMapper;
|
||||
@Autowired
|
||||
private ISarFileSplitInfoService sarFileSplitInfoService;
|
||||
@Autowired
|
||||
private ISarFileSplitMenuEOService sarFileSplitMenuEOService;
|
||||
@Autowired
|
||||
private SarFileSplitMenuEOMapper sarFileSplitMenuEOMapper;
|
||||
@Autowired
|
||||
private ISarFileSplitItemsValEOService sarFileSplitItemsValEOService;
|
||||
@Autowired
|
||||
private IOSSFileService ossFileService;
|
||||
@Autowired
|
||||
private ISysDictService sysDictService;
|
||||
|
||||
private final static String filePath = "asms/";
|
||||
private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
private static SimpleDateFormat oldDateFormat = new SimpleDateFormat("yyyy年MM月dd日");
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param lawsAsmsOpenApi
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public IPage<LawsAsmsOpenApi> queryPage(LawsAsmsOpenApi lawsAsmsOpenApi, Integer pageNo, Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<LawsAsmsOpenApi> queryWrapper = QueryGenerator.initQueryWrapper(lawsAsmsOpenApi, req.getParameterMap());
|
||||
queryWrapper.orderByAsc("api_name");
|
||||
Page<LawsAsmsOpenApi> page = new Page<>(pageNo, pageSize);
|
||||
return page(page, queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param lawsAsmsOpenApi
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<LawsAsmsOpenApi> queryList(LawsAsmsOpenApi lawsAsmsOpenApi, HttpServletRequest req) {
|
||||
return list(QueryGenerator.initQueryWrapper(lawsAsmsOpenApi, req.getParameterMap()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param lawsAsmsOpenApi
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void add(LawsAsmsOpenApi lawsAsmsOpenApi) {
|
||||
save(lawsAsmsOpenApi);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param lawsAsmsOpenApi
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void editById(LawsAsmsOpenApi lawsAsmsOpenApi) {
|
||||
saveOrUpdate(lawsAsmsOpenApi);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void deleteById(String id) {
|
||||
removeById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void deleteByIds(List<String> ids) {
|
||||
removeByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public LawsAsmsOpenApi queryById(String id) {
|
||||
return getById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/18 13:46
|
||||
* @Description: 批量同步
|
||||
**/
|
||||
@Override
|
||||
@Transactional
|
||||
public void syncBatch(List<String> idList) {
|
||||
List<LawsAsmsOpenApi> lawsAsmsOpenApiList = listByIds(idList);
|
||||
|
||||
lawsAsmsOpenApiList.forEach(lawsAsmsOpenApi -> {
|
||||
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if (StringUtils.isNotBlank(lawsAsmsOpenApi.getQueryParamJson())) {
|
||||
map = (Map<String, String>) JSON.parse(lawsAsmsOpenApi.getQueryParamJson());
|
||||
}
|
||||
|
||||
if ("1".equals(lawsAsmsOpenApi.getApiType()) && StringUtils.isNotBlank(lawsAsmsOpenApi.getDictId())) {
|
||||
// 如果是下拉字典(普通)、字典id不为空、返回的数据不为空,则进行数据字典同步操作
|
||||
// 查询该字典全部数据项
|
||||
List<Map<String, String>> mapList = asmsPostUtil.sendGetReq(lawsAsmsOpenApi.getApiUrl(), map);
|
||||
if (CollectionUtils.isNotEmpty(mapList)) {
|
||||
LambdaQueryWrapper<SysDictItem> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysDictItem::getDictId, lawsAsmsOpenApi.getDictId());
|
||||
List<SysDictItem> dictItemList = sysDictItemService.list(queryWrapper);
|
||||
List<String> codeList;
|
||||
List<SysDictItem> insertDictItemList = new ArrayList();
|
||||
List<SysDictItem> updateDictItemList = new ArrayList();
|
||||
if (CollectionUtils.isNotEmpty(dictItemList)) {
|
||||
codeList = dictItemList.stream().map(SysDictItem::getItemValue).collect(Collectors.toList());
|
||||
} else {
|
||||
codeList = new ArrayList();
|
||||
}
|
||||
SysDict sysDict = sysDictService.getById(lawsAsmsOpenApi.getDictId());
|
||||
// 遍历返回数据,封装字典数据项
|
||||
for (int i = 0; i < mapList.size(); i++) {
|
||||
Map<String, String> eMap = mapList.get(i);
|
||||
SysDictItem dictItem = new SysDictItem();
|
||||
// 字典id
|
||||
dictItem.setDictId(lawsAsmsOpenApi.getDictId());
|
||||
// 是否标签管理显示(显示)
|
||||
dictItem.setIsTagDict(1);
|
||||
// 状态(启用)
|
||||
dictItem.setStatus(1);
|
||||
dictItem.setDelFlag(0);
|
||||
// 排序
|
||||
dictItem.setSortOrder(i + 1);
|
||||
|
||||
// 是否固定
|
||||
dictItem.setIsReadOnly(sysDict.getIsReadOnly());
|
||||
|
||||
eMap.forEach((k, v) -> {
|
||||
if ("code".equals(k)) {
|
||||
// 字典项值
|
||||
dictItem.setItemValue(v);
|
||||
} else if ("name".equals(k)) {
|
||||
// 字典项名称
|
||||
dictItem.setItemText(v);
|
||||
} else if ("id".equals(k)) {
|
||||
// 主键
|
||||
dictItem.setId(v);
|
||||
} else if ("pid".equals(k)) {
|
||||
// 父节点id
|
||||
dictItem.setParentId(v);
|
||||
} else if ("source".equals(k)) {
|
||||
// 来源
|
||||
dictItem.setDescription(v);
|
||||
}
|
||||
});
|
||||
if (StringUtils.isBlank(dictItem.getItemValue())) {
|
||||
throw new JeroBootException("字典值不能为空");
|
||||
}
|
||||
if (codeList.contains(dictItem.getItemValue())) {
|
||||
// 如果code在数据库存在,则将数据库的id赋予对接的数据
|
||||
dictItem.setId(dictItemList.stream().filter(e ->
|
||||
e.getItemValue().equals(dictItem.getItemValue()))
|
||||
.collect(Collectors.toList()).get(0).getId());
|
||||
updateDictItemList.add(dictItem);
|
||||
} else {
|
||||
// 如果不存在则新增
|
||||
insertDictItemList.add(dictItem);
|
||||
}
|
||||
}
|
||||
// 操作数据库
|
||||
if (CollectionUtils.isNotEmpty(updateDictItemList)) {
|
||||
// 更新
|
||||
sysDictItemService.updateBatchById(updateDictItemList);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(insertDictItemList)) {
|
||||
// 新增
|
||||
sysDictItemService.saveBatch(insertDictItemList);
|
||||
}
|
||||
// 状态设置为已同步
|
||||
lawsAsmsOpenApi.setStatus("1");
|
||||
}
|
||||
|
||||
log.info("{}同步成功{}条数据", lawsAsmsOpenApi.getApiName(), mapList.size());
|
||||
} else if ("2".equals(lawsAsmsOpenApi.getApiType())) {
|
||||
// 如果是分标委
|
||||
List<Map<String, String>> mapList = asmsPostUtil.sendGetReq(lawsAsmsOpenApi.getApiUrl(), map);
|
||||
List<LawsStandardization> lawsStandardizationList = new ArrayList();
|
||||
|
||||
// LambdaQueryWrapper<LawsStandardization> parentQueryWrapper = new LambdaQueryWrapper<>();
|
||||
// parentQueryWrapper.eq(LawsStandardization::getPid, "0");
|
||||
// List<LawsStandardization> parentList = lawsStandardizationService.list(parentQueryWrapper);
|
||||
// String parentId;
|
||||
// if (CollectionUtils.isEmpty(parentList)) {
|
||||
// parentId = "0";
|
||||
// } else {
|
||||
// parentId = parentList.get(0).getId();
|
||||
// }
|
||||
|
||||
mapList.forEach(eMap -> {
|
||||
LawsStandardization lawsStandardization = new LawsStandardization();
|
||||
lawsStandardization.setStandardizationType(LawsStandardizationCommon.FBW);
|
||||
// 固定放到“其他”层级下
|
||||
lawsStandardization.setPid("1752134517340114944");
|
||||
eMap.forEach((k,v) -> {
|
||||
if ("code".equals(k)) {
|
||||
lawsStandardization.setNum(v);
|
||||
} else if ("name".equals(k)) {
|
||||
lawsStandardization.setName(v);
|
||||
} else if ("field".equals(k)) {
|
||||
lawsStandardization.setWorkingArea(v);
|
||||
}
|
||||
});
|
||||
lawsStandardizationList.add(lawsStandardization);
|
||||
});
|
||||
lawsStandardizationService.saveBatch(lawsStandardizationList);
|
||||
// 状态设置为已同步
|
||||
lawsAsmsOpenApi.setStatus("1");
|
||||
} else if ("3".equals(lawsAsmsOpenApi.getApiType()) && "xiaobodata/openApi/domesticLaws/list".equals(lawsAsmsOpenApi.getApiUrl())) {
|
||||
// 如果是国内法规,并且url为国内法规标准检索列表
|
||||
|
||||
// 法规列表
|
||||
String url = "xiaobodata/openApi/domesticLaws/list";
|
||||
map.put("pageNo", "1");
|
||||
map.put("pageSize", "2");
|
||||
Map<String, Object> totalMap = asmsPostUtil.sendGetReq2(url, map);
|
||||
Integer total = (Integer) totalMap.get("total");
|
||||
map.put("pageSize", total.toString());
|
||||
|
||||
List<Map<String, String>> mapList = asmsPostUtil.sendGetReq(lawsAsmsOpenApi.getApiUrl(), map);
|
||||
if (CollectionUtils.isNotEmpty(mapList)) {
|
||||
List<LawsAsmsDomestic> lawsAsmsDomesticList = new ArrayList();
|
||||
mapList.forEach(eMap -> {
|
||||
LawsAsmsDomestic lawsAsmsDomestic = JSONObject.parseObject(JSONObject.toJSONString(eMap), LawsAsmsDomestic.class);
|
||||
lawsAsmsDomestic.setCreateTimeString(eMap.get("createTime"));
|
||||
lawsAsmsDomestic.setUpdateTimeString(eMap.get("updateTime"));
|
||||
lawsAsmsDomestic.setFocalPointName(eMap.get("focalPoint"));
|
||||
lawsAsmsDomestic.setSyncFlag("A");
|
||||
lawsAsmsDomesticList.add(lawsAsmsDomestic);
|
||||
});
|
||||
lawsAsmsDomesticService.saveBatch(lawsAsmsDomesticList);
|
||||
}
|
||||
// 已同步
|
||||
lawsAsmsOpenApi.setStatus("1");
|
||||
|
||||
log.info("{}同步成功{}条数据", lawsAsmsOpenApi.getApiName(), mapList.size());
|
||||
} else if ("3".equals(lawsAsmsOpenApi.getApiType()) && "xiaobodata/openApi/domesticLaws/getInfo".equals(lawsAsmsOpenApi.getApiUrl())) {
|
||||
// 如果是国内法规,并且url为国内法规标准基本信息
|
||||
List<LawsAsmsDomestic> lawsAsmsDomesticList = lawsAsmsDomesticService.list();
|
||||
if (CollectionUtils.isEmpty(lawsAsmsDomesticList)) {
|
||||
lawsAsmsOpenApi.setStatus("1");
|
||||
}
|
||||
List<LawsAsmsDomestic> updateList = new ArrayList();
|
||||
if (CollectionUtils.isNotEmpty(lawsAsmsDomesticList)) {
|
||||
Map<String, String> paramMap = new HashMap<>();
|
||||
lawsAsmsDomesticList.forEach(lawsAsmsDomestic -> {
|
||||
paramMap.put("lawCode", lawsAsmsDomestic.getCode());
|
||||
List<Map<String, String>> mapList = asmsPostUtil.sendGetReq(lawsAsmsOpenApi.getApiUrl(), paramMap);
|
||||
LawsAsmsDomestic parseObject = JSONObject.parseObject(JSONObject.toJSONString(mapList.get(0)), LawsAsmsDomestic.class);
|
||||
log.info(parseObject.toString());
|
||||
parseObject.setSyncFlag("B");
|
||||
parseObject.setId(lawsAsmsDomestic.getId());
|
||||
parseObject.setCreateTimeString(mapList.get(0).get("createTime"));
|
||||
parseObject.setUpdateTimeString(mapList.get(0).get("updateTime"));
|
||||
parseObject.setFocalPointName(mapList.get(0).get("focalPoint"));
|
||||
updateList.add(parseObject);
|
||||
});
|
||||
lawsAsmsDomesticService.updateBatchById(updateList);
|
||||
log.info("{}同步成功{}条数据", lawsAsmsOpenApi.getApiName(), lawsAsmsDomesticList.size());
|
||||
}
|
||||
} else if ("4".equals(lawsAsmsOpenApi.getApiType()) && "A".equals(lawsAsmsOpenApi.getApiUrl())) {
|
||||
// 同步标准类别(国内)
|
||||
String standardTypeDictId = "1695983156705095681";
|
||||
List<String> standardTypeList = lawsAsmsOpenApiMapper.getStandardTypeList();
|
||||
LambdaQueryWrapper<SysDictItem> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysDictItem::getDictId, standardTypeDictId);
|
||||
queryWrapper.in(SysDictItem::getItemValue, standardTypeList);
|
||||
List<SysDictItem> sysDictItems = sysDictItemService.list(queryWrapper);
|
||||
if (CollectionUtils.isNotEmpty(sysDictItems)) {
|
||||
List<String> itemValueList = sysDictItems.stream().map(SysDictItem::getItemValue).collect(Collectors.toList());
|
||||
standardTypeList.removeAll(itemValueList);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(standardTypeList)) {
|
||||
List<SysDictItem> dictItemList = new ArrayList();
|
||||
for (int i = 0; i < standardTypeList.size(); i++) {
|
||||
SysDictItem dictItem = new SysDictItem();
|
||||
// 字典id
|
||||
dictItem.setDictId(standardTypeDictId);
|
||||
// 是否标签管理显示(显示)
|
||||
dictItem.setIsTagDict(1);
|
||||
// 状态(启用)
|
||||
dictItem.setStatus(1);
|
||||
dictItem.setDelFlag(0);
|
||||
// 排序
|
||||
dictItem.setSortOrder(i + 1);
|
||||
String standardType = standardTypeList.get(i);
|
||||
dictItem.setItemValue(standardType);
|
||||
String itemText;
|
||||
switch (standardType) {
|
||||
case "GB":
|
||||
itemText = "强制性国家标准GB";
|
||||
break;
|
||||
case "GB/T":
|
||||
itemText = "推荐性国家标准GB/T";
|
||||
break;
|
||||
case "QC/T":
|
||||
itemText = "汽车行业标准QC/T";
|
||||
break;
|
||||
case "QCn":
|
||||
itemText = "汽车行业标准QCn";
|
||||
break;
|
||||
case "HJ/T":
|
||||
itemText = "环境保护行业标准HJ/T";
|
||||
break;
|
||||
case "GB/Z":
|
||||
itemText = "国家职业卫生标准GB/Z";
|
||||
break;
|
||||
default:
|
||||
itemText = standardType;
|
||||
}
|
||||
|
||||
dictItem.setItemText(itemText);
|
||||
|
||||
dictItemList.add(dictItem);
|
||||
}
|
||||
sysDictItemService.saveBatch(dictItemList);
|
||||
}
|
||||
// 状态设置为已同步
|
||||
lawsAsmsOpenApi.setStatus("1");
|
||||
} else if ("4".equals(lawsAsmsOpenApi.getApiType()) && "B".equals(lawsAsmsOpenApi.getApiUrl())) {
|
||||
// 国内法规同步到业务表
|
||||
LambdaQueryWrapper<LawsAsmsDomestic> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.orderByAsc(LawsAsmsDomestic::getId);
|
||||
List<LawsAsmsDomestic> lawsAsmsDomesticList = lawsAsmsDomesticService.list(queryWrapper);
|
||||
List<SysDictItem> sysDictItemList = sysDictItemService.list();
|
||||
List<LawsStandardization> lawsStandardizationList = lawsStandardizationService.list();
|
||||
lawsAsmsDomesticList.forEach(lawsAsmsDomestic -> {
|
||||
String[] parts = lawsAsmsDomestic.getCode().split("[-\\s]"); // 使用空格或破折号作为分隔符
|
||||
if (parts.length < 3) {
|
||||
parts = lawsAsmsDomestic.getCode().split("[—\\s]"); // 使用空格或破折号作为分隔符
|
||||
}
|
||||
// 封装实例
|
||||
LawsDomesticStandard lawsDomesticStandard = new LawsDomesticStandard();
|
||||
// 主键
|
||||
lawsDomesticStandard.setId(lawsAsmsDomestic.getId());
|
||||
// 对接标识
|
||||
lawsDomesticStandard.setIsAsmsImport("1");
|
||||
// 标准编号
|
||||
lawsDomesticStandard.setStandardNumber(lawsAsmsDomestic.getCode());
|
||||
// 标准类别
|
||||
lawsDomesticStandard.setStandardClass(parts[0]);
|
||||
// 标准号
|
||||
lawsDomesticStandard.setStandardNumberTemp(parts[1]);
|
||||
// 年代号
|
||||
lawsDomesticStandard.setYearNumber(parts[2]);
|
||||
// 标准名称
|
||||
lawsDomesticStandard.setStandardName(lawsAsmsDomestic.getName());
|
||||
// 标准英文名称
|
||||
lawsDomesticStandard.setStandardEnglishName(lawsAsmsDomestic.getEnglishName());
|
||||
// 适用认证
|
||||
String itemValues = getItemValues(lawsAsmsDomestic.getApplicableCertificationListString(),
|
||||
"1696008107352854529", sysDictItemList);
|
||||
lawsDomesticStandard.setApplicableCertification(itemValues);
|
||||
// 适用车型
|
||||
itemValues = getItemValues(lawsAsmsDomestic.getApplicableModelsListString(),
|
||||
"1702518672924110850", sysDictItemList);
|
||||
lawsDomesticStandard.setApplicableVehicle(itemValues);
|
||||
// 采标程度
|
||||
itemValues = getItemValues(lawsAsmsDomestic.getDegreeAdoption(),
|
||||
"1696042735686049793", sysDictItemList);
|
||||
lawsDomesticStandard.setDegreeOfBidAcquisition(itemValues);
|
||||
// 实施日期
|
||||
lawsDomesticStandard.setImplementationDate(getSimpleDate(lawsAsmsDomestic.getImplementationDate()));
|
||||
// 采用国际标准号
|
||||
lawsDomesticStandard.setAdoptTheInternationalStandardNumber(lawsAsmsDomestic.getInternationalStandard());
|
||||
// 新车实施日期
|
||||
lawsDomesticStandard.setNewModelImplementationDate(getManyDateString(lawsAsmsDomestic.getNewCarImplementationDate()));
|
||||
// 动力类型
|
||||
itemValues = getItemValues(lawsAsmsDomestic.getPowerTypeListString(),
|
||||
"1702518671166697474", sysDictItemList);
|
||||
lawsDomesticStandard.setDynamicType(itemValues);
|
||||
// 在产车实施日期
|
||||
lawsDomesticStandard.setOnTheProductionDate(getManyDateString(lawsAsmsDomestic.getProductionCarImplementationDate()));
|
||||
// 发布日期
|
||||
lawsDomesticStandard.setReleaseDate(getSimpleDate(lawsAsmsDomestic.getPublishDate()));
|
||||
// 代替标准号
|
||||
lawsReplacedStandardService.addRelation(lawsAsmsDomestic.getReplaceCode(), lawsAsmsDomestic.getCode(), 1);
|
||||
// 标准性质
|
||||
/*itemValues = getItemValues(lawsAsmsDomestic.getStandardNature(),
|
||||
"1695010513489833985", sysDictItemList);*/
|
||||
lawsDomesticStandard.setStandardProperty("SN002");
|
||||
// 标准状态
|
||||
itemValues = getItemValues(lawsAsmsDomestic.getStandardStatus(),
|
||||
"1695991936599715842", sysDictItemList);
|
||||
lawsDomesticStandard.setStandardState(itemValues);
|
||||
// 分标委
|
||||
String subcommittee = lawsAsmsDomestic.getSubcommittee();
|
||||
if (StringUtils.isNotBlank(subcommittee)) {
|
||||
lawsDomesticStandard.setBiddingCommittee(lawsStandardizationList.stream()
|
||||
.filter(e -> subcommittee.equals(e.getName())).collect(Collectors.toList()).get(0).getId());
|
||||
}
|
||||
// 创建时间
|
||||
lawsDomesticStandard.setCreateTime(getSimpleDate2(lawsAsmsDomestic.getCreateTimeString()));
|
||||
// 更新时间
|
||||
lawsDomesticStandard.setUpdateTime(getSimpleDate2(lawsAsmsDomestic.getUpdateTimeString()));
|
||||
lawsDomesticStandardService.saveOrUpdate(lawsDomesticStandard);
|
||||
// 同步es数据库
|
||||
lawsHomeSearchService.updateEsData(LawsHomeSearchCommon.LAWS_DOMESTIC_STANDARD, lawsDomesticStandard.getId(), LawsHomeSearchCommon.LAWS_ES_ADD);
|
||||
});
|
||||
// 状态设置为已同步
|
||||
lawsAsmsOpenApi.setStatus("1");
|
||||
log.info("{}同步成功{}条数据", lawsAsmsOpenApi.getApiName(), lawsAsmsDomesticList.size());
|
||||
} else if ("3".equals(lawsAsmsOpenApi.getApiType()) && "xiaobodata/openApi/domesticLaws/getFile".equals(lawsAsmsOpenApi.getApiUrl())) {
|
||||
// 国内法规相关文档
|
||||
LambdaQueryWrapper<LawsAsmsDomestic> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.orderByAsc(LawsAsmsDomestic::getId);
|
||||
List<LawsAsmsDomestic> lawsAsmsDomesticList = lawsAsmsDomesticService.list(queryWrapper);
|
||||
lawsAsmsDomesticList.forEach(lawsAsmsDomestic -> {
|
||||
String id = lawsAsmsDomestic.getId();
|
||||
String code = lawsAsmsDomestic.getCode();
|
||||
Map<String, String> paramMap = new HashMap<>();
|
||||
paramMap.put("lawCode", code);
|
||||
Map<String, Object> objectMap = asmsPostUtil.sendGetReq2(lawsAsmsOpenApi.getApiUrl(), paramMap);
|
||||
if (Objects.isNull(objectMap)) return;
|
||||
Map<String, String> standardTextPdf = (Map<String, String>) objectMap.get("standardTextPdf");
|
||||
String fileName = standardTextPdf.get("fileName");
|
||||
String fileType = standardTextPdf.get("fileType");
|
||||
String url = standardTextPdf.get("url");
|
||||
if (StringUtils.isNotBlank(url)) {
|
||||
upload(url, fileName, fileType, id, code);
|
||||
}
|
||||
Map<String, String> standardTextWord = (Map<String, String>) objectMap.get("standardTextWord");
|
||||
fileName = standardTextWord.get("fileName");
|
||||
fileType = standardTextWord.get("fileType");
|
||||
url = standardTextWord.get("url");
|
||||
if (StringUtils.isNotBlank(url)) {
|
||||
upload(url, fileName, fileType, id, code);
|
||||
}
|
||||
});
|
||||
// 状态设置为已同步
|
||||
lawsAsmsOpenApi.setStatus("1");
|
||||
log.info("{}同步成功{}条数据", lawsAsmsOpenApi.getApiName(), lawsAsmsDomesticList.size());
|
||||
} else if ("3".equals(lawsAsmsOpenApi.getApiType()) && "xiaobodata/openApi/article/search".equals(lawsAsmsOpenApi.getApiUrl())) {
|
||||
|
||||
// 文档拆分
|
||||
String url = "xiaobodata/openApi/article/search";
|
||||
map.put("pageNo", "1");
|
||||
map.put("pageSize", "2");
|
||||
Map<String, Object> totalMap = asmsPostUtil.sendGetReq2(url, map);
|
||||
Integer total = (Integer) totalMap.get("total");
|
||||
map.put("pageSize", total.toString());
|
||||
|
||||
// 如果是国内法规,并且url为法规条文检索国内法规列表
|
||||
List<Map<String, String>> mapList = asmsPostUtil.sendGetReq(lawsAsmsOpenApi.getApiUrl(), map);
|
||||
mapList.forEach(eMap -> {
|
||||
String code = eMap.get("code");
|
||||
|
||||
LambdaQueryWrapper<LawsDomesticStandard> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(LawsDomesticStandard::getStandardNumber, code);
|
||||
LawsDomesticStandard lawsDomesticStandard = lawsDomesticStandardService.getOne(queryWrapper);
|
||||
|
||||
LambdaQueryWrapper<OSSFile> queryWrapper1 = new LambdaQueryWrapper<>();
|
||||
queryWrapper1.eq(OSSFile::getStandardId, lawsDomesticStandard.getId());
|
||||
queryWrapper1.eq(OSSFile::getStandardFileType, "publish_of_original");
|
||||
queryWrapper1.like(OSSFile::getFileName, ".docx");
|
||||
OSSFile ossFile = ossFileService.getOne(queryWrapper1);
|
||||
if (Objects.isNull(ossFile)){
|
||||
return;
|
||||
}
|
||||
SarFileSplitInfoEO sarFileSplitInfoEO = new SarFileSplitInfoEO();
|
||||
sarFileSplitInfoEO.setStandardId(lawsDomesticStandard.getId());
|
||||
sarFileSplitInfoEO.setSerialNumber(lawsDomesticStandard.getStandardNumber());
|
||||
sarFileSplitInfoEO.setTitle(lawsDomesticStandard.getStandardName());
|
||||
sarFileSplitInfoEO.setFileType("publish_of_original");
|
||||
sarFileSplitInfoEO.setFileId(ossFile.getId());
|
||||
sarFileSplitInfoEO.setFileName(ossFile.getFileName());
|
||||
sarFileSplitInfoEO.setSplitStatus("1");
|
||||
sarFileSplitInfoEO.setCreateTime(getSimpleDate2(eMap.get("createTime")));
|
||||
sarFileSplitInfoEO.setUpdateTime(getSimpleDate2(eMap.get("updateTime")));
|
||||
sarFileSplitInfoEO.setIsAsmsImport("1");
|
||||
sarFileSplitInfoEO.setAuthor("云平台");
|
||||
sarFileSplitInfoEO.setSplitResult("成功");
|
||||
|
||||
sarFileSplitInfoService.save(sarFileSplitInfoEO);
|
||||
});
|
||||
// 状态设置为已同步
|
||||
lawsAsmsOpenApi.setStatus("1");
|
||||
log.info("{}同步成功{}条数据", lawsAsmsOpenApi.getApiName(), mapList.size());
|
||||
} else if ("3".equals(lawsAsmsOpenApi.getApiType()) && "xiaobodata/openApi/article/details".equals(lawsAsmsOpenApi.getApiUrl())) {
|
||||
// 单个法规的条文列表
|
||||
LambdaQueryWrapper<SarFileSplitInfoEO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SarFileSplitInfoEO::getIsAsmsImport, "1");
|
||||
List<SarFileSplitInfoEO> sarFileSplitInfoEOList = sarFileSplitInfoService.list(queryWrapper);
|
||||
List<SysDictItem> sysDictItemList = sysDictItemService.list();
|
||||
Map<String, String> paramMap = new HashMap<>();
|
||||
Map<String, String> paramMap2 = new HashMap<>();
|
||||
Map<String, String> paramMap3 = new HashMap<>();
|
||||
sarFileSplitInfoEOList.forEach(sarFileSplitInfoEO -> {
|
||||
paramMap.put("standardCode", sarFileSplitInfoEO.getSerialNumber());
|
||||
List<Map<String, String>> mapList = asmsPostUtil.sendGetReq(lawsAsmsOpenApi.getApiUrl(), paramMap);
|
||||
mapList.forEach(eMap -> {
|
||||
// 单个法规的条文解读详情
|
||||
paramMap2.put("standardCode", sarFileSplitInfoEO.getSerialNumber());
|
||||
paramMap2.put("termsCode", eMap.get("termsNum"));
|
||||
Map<String, Object> objectMap = asmsPostUtil.sendGetReq2("xiaobodata/openApi/article/interpretation/details", paramMap2);
|
||||
|
||||
// 单个法规的条文标签详情
|
||||
paramMap3.put("standardCode", sarFileSplitInfoEO.getSerialNumber());
|
||||
paramMap3.put("termsCode", eMap.get("termsNum"));
|
||||
Map<String, Object> objectMap2 = asmsPostUtil.sendGetReq2("xiaobodata/openApi/article/label/details", paramMap3);
|
||||
|
||||
LawsDocumentSplit lawsDocumentSplit = new LawsDocumentSplit();
|
||||
lawsDocumentSplit.setInfoId(sarFileSplitInfoEO.getId());
|
||||
lawsDocumentSplit.setItemNum(eMap.get("termsNum"));
|
||||
lawsDocumentSplit.setItemTitle(eMap.get("termsName"));
|
||||
lawsDocumentSplit.setItemContent(eMap.get("articleContent"));
|
||||
lawsDocumentSplit.setCreateTime(getSimpleDate2(eMap.get("createTime")));
|
||||
lawsDocumentSplit.setUpdateTime(getSimpleDate2(eMap.get("updateTime")));
|
||||
|
||||
lawsDocumentSplit.setInterpretationArticles((String) objectMap.get("termsInterpretation"));
|
||||
|
||||
lawsDocumentSplit.setFunctionClassification((String) objectMap2.get("functionClassification"));
|
||||
lawsDocumentSplit.setFunctionProfessional((String) objectMap2.get("functionProfession"));
|
||||
//lawsDocumentSplit.setFunctionGroupName((String) objectMap2.get("groupingName"));
|
||||
lawsDocumentSplit.setFunctionGroupName((String) objectMap2.get("groupingNum"));
|
||||
lawsDocumentSplit.setFunctionGroupCode((String) objectMap2.get("groupingNum"));
|
||||
lawsDocumentSplit.setCerImplementDate((String) objectMap2.get("implementDateCertified"));
|
||||
lawsDocumentSplit.setNewCerImplementDate((String) objectMap2.get("implementDateNewCer"));
|
||||
lawsDocumentSplit.setNewRegisterImplementDate((String) objectMap2.get("implementDateNewRegister"));
|
||||
lawsDocumentSplit.setLawsRequireType((String) objectMap2.get("lawsRequireType"));
|
||||
lawsDocumentSplit.setApplications((String) objectMap2.get("modelsType"));
|
||||
lawsDocumentSplit.setDynamicType((String) objectMap2.get("powerType"));
|
||||
|
||||
lawsDocumentSplit.setLawsRequireType(getItemValues(lawsDocumentSplit.getLawsRequireType(),
|
||||
"1702212236079886338", sysDictItemList)); // 法规要求类型
|
||||
lawsDocumentSplit.setFunctionClassification(getItemValues(lawsDocumentSplit.getFunctionClassification(),
|
||||
"1702212237296234497", sysDictItemList)); // 功能分类
|
||||
lawsDocumentSplit.setFunctionProfessional(getItemValues(lawsDocumentSplit.getFunctionProfessional(),
|
||||
"1702202280677044226", sysDictItemList)); // 功能专业
|
||||
lawsDocumentSplit.setApplications(getItemValues(lawsDocumentSplit.getApplications(),
|
||||
"1702518672924110850", sysDictItemList)); // 适用车型
|
||||
lawsDocumentSplit.setDynamicType(getItemValues(lawsDocumentSplit.getDynamicType(),
|
||||
"1702518671166697474", sysDictItemList)); // 动力类型
|
||||
|
||||
lawsDocumentSplitMapper.insert(lawsDocumentSplit);
|
||||
});
|
||||
});
|
||||
// 状态设置为已同步
|
||||
lawsAsmsOpenApi.setStatus("1");
|
||||
log.info("{}同步成功{}条数据", lawsAsmsOpenApi.getApiName(), sarFileSplitInfoEOList.size());
|
||||
} else if ("4".equals(lawsAsmsOpenApi.getApiType()) && "C".equals(lawsAsmsOpenApi.getApiUrl())) {
|
||||
// 给拆分的条款加上左侧目录
|
||||
LambdaQueryWrapper<SarFileSplitInfoEO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SarFileSplitInfoEO::getIsAsmsImport, "1");
|
||||
List<SarFileSplitInfoEO> sarFileSplitInfoEOList = sarFileSplitInfoService.list(queryWrapper);
|
||||
sarFileSplitInfoEOList.forEach(sarFileSplitInfoEO -> {
|
||||
String infoId = sarFileSplitInfoEO.getId();
|
||||
LambdaQueryWrapper<LawsDocumentSplit> queryWrapper1 = new LambdaQueryWrapper<>();
|
||||
queryWrapper1.eq(LawsDocumentSplit::getInfoId, infoId);
|
||||
List<LawsDocumentSplit> lawsDocumentSplitList = lawsDocumentSplitMapper.selectList(queryWrapper1);
|
||||
List<String> itemNumList = lawsDocumentSplitList.stream().map(LawsDocumentSplit::getItemNum).collect(Collectors.toList());
|
||||
// 对目录排序
|
||||
Collections.sort(itemNumList, new AlphanumericComparator());
|
||||
Map<String, Long> sortMap = new HashMap<>();
|
||||
for (int i = 0; i < itemNumList.size(); i++) {
|
||||
sortMap.put(itemNumList.get(i), i+2L);
|
||||
}
|
||||
List<SarFileSplitMenuEO> sarFileSplitMenuEOList = new java.util.ArrayList<>();
|
||||
// 根目录
|
||||
SarFileSplitMenuEO rootEO = new SarFileSplitMenuEO();
|
||||
String rootId = UUIDUtils.randomUUID20();
|
||||
rootEO.setId(rootId);
|
||||
rootEO.setInfoId(infoId);
|
||||
rootEO.setName("总目录");
|
||||
rootEO.setDisplaySeq(1L);
|
||||
rootEO.setValidFlag(0);
|
||||
sarFileSplitMenuEOMapper.insertSelective(rootEO);
|
||||
|
||||
Map<String, String> idMap = new HashMap<>();
|
||||
lawsDocumentSplitList.forEach(lawsDocumentSplit -> {
|
||||
SarFileSplitMenuEO sarFileSplitMenuEO = new SarFileSplitMenuEO();
|
||||
String itemNum = lawsDocumentSplit.getItemNum();
|
||||
String id = UUIDUtils.randomUUID20();
|
||||
sarFileSplitMenuEO.setId(id);
|
||||
sarFileSplitMenuEO.setInfoId(infoId);
|
||||
sarFileSplitMenuEO.setName(itemNum);
|
||||
sarFileSplitMenuEO.setDisplaySeq(sortMap.get(itemNum));
|
||||
sarFileSplitMenuEO.setValidFlag(0);
|
||||
String itemTitle = lawsDocumentSplit.getItemTitle();
|
||||
sarFileSplitMenuEO.setItemName(itemTitle.substring(0, Math.min(10, itemTitle.length())));
|
||||
sarFileSplitMenuEOList.add(sarFileSplitMenuEO);
|
||||
idMap.put(itemNum, id);
|
||||
|
||||
lawsDocumentSplit.setMenuId(id);
|
||||
lawsDocumentSplitMapper.updateById(lawsDocumentSplit);
|
||||
});
|
||||
|
||||
// 设置父id
|
||||
sarFileSplitMenuEOList.forEach(sarFileSplitMenuEO -> {
|
||||
String itemNum = sarFileSplitMenuEO.getName();
|
||||
String[] split = itemNum.split("\\.");
|
||||
if (split.length == 1) {
|
||||
sarFileSplitMenuEO.setPId(rootId);
|
||||
} else {
|
||||
// 去除数组中的最后一个元素
|
||||
split = Arrays.copyOf(split, split.length - 1);
|
||||
String pid = idMap.get(StringUtils.join(split, "."));
|
||||
if (StringUtils.isBlank(pid)) {
|
||||
pid = rootId;
|
||||
}
|
||||
sarFileSplitMenuEO.setPId(pid);
|
||||
}
|
||||
});
|
||||
sarFileSplitMenuEOMapper.insertForeach(sarFileSplitMenuEOList);
|
||||
});
|
||||
// 状态设置为已同步
|
||||
lawsAsmsOpenApi.setStatus("1");
|
||||
log.info("{}同步成功{}条数据", lawsAsmsOpenApi.getApiName(), sarFileSplitInfoEOList.size());
|
||||
} else if ("4".equals(lawsAsmsOpenApi.getApiType()) && "D".equals(lawsAsmsOpenApi.getApiUrl())) {
|
||||
// 拆分的条款的条文列表
|
||||
LambdaQueryWrapper<SarFileSplitInfoEO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SarFileSplitInfoEO::getIsAsmsImport, "1");
|
||||
List<SarFileSplitInfoEO> sarFileSplitInfoEOList = sarFileSplitInfoService.list(queryWrapper);
|
||||
sarFileSplitInfoEOList.forEach(sarFileSplitInfoEO -> {
|
||||
String infoId = sarFileSplitInfoEO.getId();
|
||||
LambdaQueryWrapper<LawsDocumentSplit> queryWrapper1 = new LambdaQueryWrapper<>();
|
||||
queryWrapper1.eq(LawsDocumentSplit::getInfoId, infoId);
|
||||
List<LawsDocumentSplit> lawsDocumentSplitList = lawsDocumentSplitMapper.selectList(queryWrapper1);
|
||||
lawsDocumentSplitList.forEach(lawsDocumentSplit -> {
|
||||
String itemContent = lawsDocumentSplit.getItemContent();
|
||||
// 使用 jsoup 解析 HTML
|
||||
Document doc = Jsoup.parse(itemContent);
|
||||
|
||||
// 选择所有的 <p> 元素
|
||||
Elements paragraphs = doc.select("p");
|
||||
|
||||
// 存储提取的文本内容
|
||||
List<String> textContents = new java.util.ArrayList<>();
|
||||
|
||||
for (Element paragraph : paragraphs) {
|
||||
// 获取每个 <p> 元素的文本内容并添加到集合中
|
||||
String textContent = paragraph.text();
|
||||
textContents.add(textContent);
|
||||
}
|
||||
|
||||
//List<SarFileSplitItemsValEO> sarFileSplitItemsValEOList = new ArrayList<>();
|
||||
for (int i = 0; i < textContents.size(); i++) {
|
||||
SarFileSplitItemsValEO sarFileSplitItemsValEO = new SarFileSplitItemsValEO();
|
||||
sarFileSplitItemsValEO.setId(UUIDUtils.randomUUID20());
|
||||
sarFileSplitItemsValEO.setType("TEXT");
|
||||
sarFileSplitItemsValEO.setItemId(lawsDocumentSplit.getId());
|
||||
sarFileSplitItemsValEO.setItemContent(textContents.get(i));
|
||||
sarFileSplitItemsValEO.setDisplaySeq(i+1);
|
||||
sarFileSplitItemsValEO.setValidFlag(0);
|
||||
//sarFileSplitItemsValEOList.add(sarFileSplitItemsValEO);
|
||||
sarFileSplitItemsValEOService.insertSelective(sarFileSplitItemsValEO);
|
||||
}
|
||||
//sarFileSplitItemsValEOService.insertForeach(sarFileSplitItemsValEOList);
|
||||
});
|
||||
});
|
||||
// 状态设置为已同步
|
||||
lawsAsmsOpenApi.setStatus("1");
|
||||
log.info("{}同步成功{}条数据", lawsAsmsOpenApi.getApiName(), sarFileSplitInfoEOList.size());
|
||||
}
|
||||
});
|
||||
// 同步接口的状态
|
||||
updateBatchById(lawsAsmsOpenApiList);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void upload(String url, String fileName, String fileType, String id, String code) {
|
||||
InputStream inputStream = asmsPostUtil.getFileByteArray(url);
|
||||
try {
|
||||
MinioUtil.upload(inputStream, filePath + url);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new JeroBootException("文件上传错误");
|
||||
}
|
||||
OSSFile ossFile = new OSSFile();
|
||||
ossFile.setFileName(fileName + "." + fileType);
|
||||
ossFile.setUrl(filePath + url);
|
||||
ossFile.setStandardId(id);
|
||||
ossFile.setStandardNo(code);
|
||||
ossFile.setStandardFileType("publish_of_original");
|
||||
ossFileService.save(ossFile);
|
||||
log.info("存储文件:{},url:{}", fileName, url);
|
||||
}
|
||||
|
||||
private Date getSimpleDate(String dateStr) {
|
||||
if (StringUtils.isBlank(dateStr)) return null;
|
||||
try {
|
||||
return simpleDateFormat.parse(dateStr);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new JeroBootException("时间格式转换错误");
|
||||
}
|
||||
}
|
||||
|
||||
private Date getSimpleDate2(String dateStr) {
|
||||
if (StringUtils.isBlank(dateStr)) return null;
|
||||
try {
|
||||
return dateFormat.parse(dateStr);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new JeroBootException("时间格式转换错误");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/23 15:57
|
||||
* @Description: 获取多日期字符串
|
||||
**/
|
||||
private String getManyDateString(String oldManyDateString) {
|
||||
if (StringUtils.isBlank(oldManyDateString)) return "";
|
||||
List<String> oldValueList = Arrays.asList(oldManyDateString.split("、"));
|
||||
// 使用正则表达式提取日期部分
|
||||
Pattern pattern = Pattern.compile("\\d{4}年\\d{2}月\\d{2}日");
|
||||
|
||||
List<String> valueList = new java.util.ArrayList<>();
|
||||
oldValueList.forEach(value -> {
|
||||
Matcher matcher = pattern.matcher(value);
|
||||
String dateStr;
|
||||
if (matcher.find()) {
|
||||
dateStr = matcher.group(0);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Date parse = oldDateFormat.parse(dateStr);
|
||||
String format = simpleDateFormat.format(parse);
|
||||
valueList.add(format);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new JeroBootException("时间格式转换错误");
|
||||
}
|
||||
});
|
||||
if (valueList.size() == 1) {
|
||||
// 如果只有一个日期值,则复制成两个,用于查询和排序
|
||||
return valueList.get(0) + "," + valueList.get(0);
|
||||
}
|
||||
List<LocalDate> dateList = valueList.stream()
|
||||
.map(LocalDate::parse) // 解析日期字符串为 LocalDate 对象
|
||||
.sorted() // 按照日期大小进行排序
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 将排序后的 LocalDate 对象转换为字符串
|
||||
List<String> sortedDateStrList = dateList.stream()
|
||||
.map(LocalDate::toString)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return String.join(",", sortedDateStrList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/23 15:09
|
||||
* @Description: 获取字典值
|
||||
**/
|
||||
private String getItemValues(String itemTexts, String dictId, List<SysDictItem> sysDictItemList) {
|
||||
if (StringUtils.isBlank(itemTexts)) return "";
|
||||
List<String> itemTextList = Arrays.asList(itemTexts.split(";"));
|
||||
List<String> itemValues = sysDictItemList.stream()
|
||||
.filter(sysDictItem -> itemTextList.contains(sysDictItem.getItemText()) && dictId.equals(sysDictItem.getDictId()))
|
||||
.map(SysDictItem::getItemValue).collect(Collectors.toList());
|
||||
return StringUtils.join(itemValues, ",");
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/18 16:20
|
||||
* @Description: 批量删除原字典配置项
|
||||
**/
|
||||
@Override
|
||||
public void removeDictItemBatch(List<String> idList) {
|
||||
List<LawsAsmsOpenApi> lawsAsmsOpenApiList = listByIds(idList);
|
||||
lawsAsmsOpenApiList = lawsAsmsOpenApiList.stream()
|
||||
.filter(e -> StringUtils.isNotBlank(e.getDictId())).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(lawsAsmsOpenApiList)) {
|
||||
List<String> dictIdList = lawsAsmsOpenApiList.stream()
|
||||
.map(LawsAsmsOpenApi::getDictId).collect(Collectors.toList());
|
||||
// 状态转为未同步
|
||||
lawsAsmsOpenApiList.forEach(e -> e.setStatus("0"));
|
||||
updateBatchById(lawsAsmsOpenApiList);
|
||||
// 物理删除字典配置项
|
||||
lawsAsmsOpenApiMapper.removeDictItemBatch(dictIdList);
|
||||
}
|
||||
}
|
||||
}
|
||||
-634
@@ -1,634 +0,0 @@
|
||||
package com.jero.modules.docking.asms.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.util.MinioUtil;
|
||||
import com.jero.common.util.UUIDUtils;
|
||||
import com.jero.modules.docking.asms.entity.LawsAsmsDomestic;
|
||||
import com.jero.modules.docking.asms.mapper.LawsAsmsOpenApiMapper;
|
||||
import com.jero.modules.docking.asms.service.ILawsAsmsDomesticService;
|
||||
import com.jero.modules.docking.asms.util.AlphanumericComparator;
|
||||
import com.jero.modules.docking.asms.util.AsmsPostUtil;
|
||||
import com.jero.modules.laws.common.util.DateUtil;
|
||||
import com.jero.modules.laws.documenttool.entity.LawsDocumentSplit;
|
||||
import com.jero.modules.laws.documenttool.mapper.LawsDocumentSplitMapper;
|
||||
import com.jero.modules.laws.documenttool.service.IDocumentSplitService;
|
||||
import com.jero.modules.laws.home.common.LawsHomeSearchCommon;
|
||||
import com.jero.modules.laws.home.service.ILawsHomeSearchService;
|
||||
import com.jero.modules.laws.standard.entity.LawsDomesticStandard;
|
||||
import com.jero.modules.laws.standard.service.ILawsDomesticStandardService;
|
||||
import com.jero.modules.laws.standard.service.ILawsReplacedStandardService;
|
||||
import com.jero.modules.laws.standardization.entity.LawsStandardization;
|
||||
import com.jero.modules.laws.standardization.service.ILawsStandardizationService;
|
||||
import com.jero.modules.oss.entity.OSSFile;
|
||||
import com.jero.modules.oss.service.IOSSFileService;
|
||||
import com.jero.modules.split.entity.SarFileSplitInfoEO;
|
||||
import com.jero.modules.split.entity.SarFileSplitItemsValEO;
|
||||
import com.jero.modules.split.entity.SarFileSplitMenuEO;
|
||||
import com.jero.modules.split.mapper.SarFileSplitMenuEOMapper;
|
||||
import com.jero.modules.split.service.ISarFileSplitInfoService;
|
||||
import com.jero.modules.split.service.ISarFileSplitItemsValEOService;
|
||||
import com.jero.modules.split.service.ISarFileSplitMenuEOService;
|
||||
import com.jero.modules.system.entity.SysDictItem;
|
||||
import com.jero.modules.system.service.ISysDictItemService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.InputStream;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/11/3 13:46
|
||||
* @Description: 定时同步asms
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SynchronizationAsmsService {
|
||||
|
||||
@Autowired
|
||||
private AsmsPostUtil asmsPostUtil;
|
||||
@Autowired
|
||||
private ISysDictItemService sysDictItemService;
|
||||
@Autowired
|
||||
private ILawsAsmsDomesticService lawsAsmsDomesticService;
|
||||
@Autowired
|
||||
private LawsAsmsOpenApiMapper lawsAsmsOpenApiMapper;
|
||||
@Autowired
|
||||
private ILawsStandardizationService lawsStandardizationService;
|
||||
@Autowired
|
||||
private ILawsDomesticStandardService lawsDomesticStandardService;
|
||||
@Autowired
|
||||
private ISarFileSplitInfoService sarFileSplitInfoService;
|
||||
@Autowired
|
||||
private LawsDocumentSplitMapper lawsDocumentSplitMapper;
|
||||
@Autowired
|
||||
private ISarFileSplitMenuEOService sarFileSplitMenuEOService;
|
||||
@Autowired
|
||||
private SarFileSplitMenuEOMapper sarFileSplitMenuEOMapper;
|
||||
@Autowired
|
||||
private ISarFileSplitItemsValEOService sarFileSplitItemsValEOService;
|
||||
@Autowired
|
||||
private ILawsReplacedStandardService lawsReplacedStandardService;
|
||||
@Resource
|
||||
private ILawsHomeSearchService lawsHomeSearchService;
|
||||
@Autowired
|
||||
private IOSSFileService ossFileService;
|
||||
@Autowired
|
||||
private IDocumentSplitService documentSplitService;
|
||||
|
||||
private final static String filePath = "asms/";
|
||||
private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
private static SimpleDateFormat oldDateFormat = new SimpleDateFormat("yyyy年MM月dd日");
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/11/3 13:48
|
||||
* @Description: 定时同步国内法规
|
||||
**/
|
||||
@Transactional
|
||||
public void syncDomestic() {
|
||||
log.info("=====================定时同步国内法规=====================");
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
// 法规列表
|
||||
String url = "xiaobodata/openApi/domesticLaws/list";
|
||||
Map<String, String> paramMap = new HashMap<>();
|
||||
paramMap.put("pageNo", "1");
|
||||
paramMap.put("pageSize", "2");
|
||||
Map<String, Object> totalMap = asmsPostUtil.sendGetReq2(url, paramMap);
|
||||
Integer total = (Integer) totalMap.get("total");
|
||||
paramMap.put("pageSize", total.toString());
|
||||
|
||||
List<Map<String, String>> mapList = asmsPostUtil.sendGetReq(url, paramMap);
|
||||
if (Objects.isNull(mapList)) {
|
||||
log.info("=====================没有获取到ASMS系统数据,同步结束=====================");
|
||||
return;
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<LawsDomesticStandard> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.select(LawsDomesticStandard::getStandardNumber);
|
||||
List<LawsDomesticStandard> lawsDomesticStandards = lawsDomesticStandardService.list(queryWrapper);
|
||||
List<String> dupCodeList;
|
||||
if (CollectionUtils.isNotEmpty(lawsDomesticStandards)) {
|
||||
dupCodeList = lawsDomesticStandards.stream().map(LawsDomesticStandard::getStandardNumber).collect(Collectors.toList());
|
||||
} else {
|
||||
dupCodeList = new ArrayList<>();
|
||||
}
|
||||
|
||||
List<LawsAsmsDomestic> lawsAsmsDomesticList = new ArrayList();
|
||||
mapList.forEach(eMap -> {
|
||||
String createTimeString = eMap.get("createTime");
|
||||
Date createTime = DateUtil.getDateSecond(createTimeString);
|
||||
Date yesterday = DateUtil.getDateAddDays(new Date(), -1);
|
||||
// 创建时间为昨天的数据
|
||||
if (createTime.after(DateUtil.getDayStart(yesterday)) && createTime.before(DateUtil.getDayEnd(yesterday))) {
|
||||
if (!dupCodeList.contains((String) eMap.get("code"))) {
|
||||
LawsAsmsDomestic lawsAsmsDomestic = JSONObject.parseObject(JSONObject.toJSONString(eMap), LawsAsmsDomestic.class);
|
||||
lawsAsmsDomestic.setCreateTimeString(createTimeString);
|
||||
lawsAsmsDomestic.setUpdateTimeString(eMap.get("updateTime"));
|
||||
lawsAsmsDomestic.setFocalPointName(eMap.get("focalPoint"));
|
||||
lawsAsmsDomesticList.add(lawsAsmsDomestic);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (CollectionUtils.isEmpty(lawsAsmsDomesticList)) {
|
||||
log.info("=====================昨天新增法规0条,同步结束=====================");
|
||||
return;
|
||||
}
|
||||
|
||||
// 法规详情
|
||||
String detailUrl = "xiaobodata/openApi/domesticLaws/getInfo";
|
||||
List<LawsAsmsDomestic> detailList = new ArrayList();
|
||||
Map<String, String> detailMap = new HashMap<>();
|
||||
lawsAsmsDomesticList.forEach(lawsAsmsDomestic -> {
|
||||
detailMap.put("lawCode", lawsAsmsDomestic.getCode());
|
||||
Map<String, Object> objectMap = asmsPostUtil.sendGetReq2(detailUrl, detailMap);
|
||||
|
||||
LawsAsmsDomestic parseObject = JSONObject.parseObject(JSONObject.toJSONString(objectMap), LawsAsmsDomestic.class);
|
||||
parseObject.setCreateTimeString((String) objectMap.get("createTime"));
|
||||
parseObject.setUpdateTimeString((String) objectMap.get("updateTime"));
|
||||
parseObject.setFocalPointName((String) objectMap.get("focalPoint"));
|
||||
detailList.add(parseObject);
|
||||
});
|
||||
|
||||
// 同步到数据库
|
||||
List<SysDictItem> sysDictItemList = sysDictItemService.list();
|
||||
List<LawsStandardization> lawsStandardizationList = lawsStandardizationService.list();
|
||||
List<LawsDomesticStandard> insertDomesticList = new ArrayList<>();
|
||||
detailList.forEach(lawsAsmsDomestic -> {
|
||||
String[] parts = lawsAsmsDomestic.getCode().split("[-\\s]"); // 使用空格或破折号作为分隔符
|
||||
if (parts.length < 3) {
|
||||
parts = lawsAsmsDomestic.getCode().split("[—\\s]"); // 使用空格或破折号作为分隔符
|
||||
}
|
||||
// 封装实例
|
||||
LawsDomesticStandard lawsDomesticStandard = new LawsDomesticStandard();
|
||||
// 对接标识
|
||||
lawsDomesticStandard.setIsAsmsImport("1");
|
||||
// 标准编号
|
||||
lawsDomesticStandard.setStandardNumber(lawsAsmsDomestic.getCode());
|
||||
// 标准类别
|
||||
lawsDomesticStandard.setStandardClass(parts[0]);
|
||||
// 标准号
|
||||
lawsDomesticStandard.setStandardNumberTemp(parts[1]);
|
||||
// 年代号
|
||||
lawsDomesticStandard.setYearNumber(parts[2]);
|
||||
// 标准名称
|
||||
lawsDomesticStandard.setStandardName(lawsAsmsDomestic.getName());
|
||||
// 标准英文名称
|
||||
lawsDomesticStandard.setStandardEnglishName(lawsAsmsDomestic.getEnglishName());
|
||||
// 适用认证
|
||||
String itemValues = getItemValues(lawsAsmsDomestic.getApplicableCertificationListString(),
|
||||
"1696008107352854529", sysDictItemList);
|
||||
lawsDomesticStandard.setApplicableCertification(itemValues);
|
||||
// 适用车型
|
||||
itemValues = getItemValues(lawsAsmsDomestic.getApplicableModelsListString(),
|
||||
"1702518672924110850", sysDictItemList);
|
||||
lawsDomesticStandard.setApplicableVehicle(itemValues);
|
||||
// 采标程度
|
||||
itemValues = getItemValues(lawsAsmsDomestic.getDegreeAdoption(),
|
||||
"1696042735686049793", sysDictItemList);
|
||||
lawsDomesticStandard.setDegreeOfBidAcquisition(itemValues);
|
||||
// 实施日期
|
||||
lawsDomesticStandard.setImplementationDate(getSimpleDate(lawsAsmsDomestic.getImplementationDate()));
|
||||
// 采用国际标准号
|
||||
lawsDomesticStandard.setAdoptTheInternationalStandardNumber(lawsAsmsDomestic.getInternationalStandard());
|
||||
// 新车实施日期
|
||||
lawsDomesticStandard.setNewModelImplementationDate(getManyDateString(lawsAsmsDomestic.getNewCarImplementationDate()));
|
||||
// 动力类型
|
||||
itemValues = getItemValues(lawsAsmsDomestic.getPowerTypeListString(),
|
||||
"1702518671166697474", sysDictItemList);
|
||||
lawsDomesticStandard.setDynamicType(itemValues);
|
||||
// 在产车实施日期
|
||||
lawsDomesticStandard.setOnTheProductionDate(getManyDateString(lawsAsmsDomestic.getProductionCarImplementationDate()));
|
||||
// 发布日期
|
||||
lawsDomesticStandard.setReleaseDate(getSimpleDate(lawsAsmsDomestic.getPublishDate()));
|
||||
// 代替标准号
|
||||
lawsReplacedStandardService.addRelation(lawsAsmsDomestic.getReplaceCode(), lawsAsmsDomestic.getCode(), 1);
|
||||
// 标准性质
|
||||
/*itemValues = getItemValues(lawsAsmsDomestic.getStandardNature(),
|
||||
"1695010513489833985", sysDictItemList);*/
|
||||
lawsDomesticStandard.setStandardProperty("SN002");
|
||||
// 标准状态
|
||||
itemValues = getItemValues(lawsAsmsDomestic.getStandardStatus(),
|
||||
"1695991936599715842", sysDictItemList);
|
||||
lawsDomesticStandard.setStandardState(itemValues);
|
||||
// 分标委
|
||||
String subcommittee = lawsAsmsDomestic.getSubcommittee();
|
||||
if (StringUtils.isNotBlank(subcommittee)) {
|
||||
lawsDomesticStandard.setBiddingCommittee(lawsStandardizationList.stream()
|
||||
.filter(e -> subcommittee.equals(e.getName())).collect(Collectors.toList()).get(0).getId());
|
||||
}
|
||||
// 创建时间
|
||||
lawsDomesticStandard.setCreateTime(getSimpleDate2(lawsAsmsDomestic.getCreateTimeString()));
|
||||
// 更新时间
|
||||
lawsDomesticStandard.setUpdateTime(getSimpleDate2(lawsAsmsDomestic.getUpdateTimeString()));
|
||||
|
||||
// 生成id
|
||||
lawsDomesticStandard.setId(UUIDUtils.randomUUID20());
|
||||
|
||||
insertDomesticList.add(lawsDomesticStandard);
|
||||
});
|
||||
// 插入国内法规标准数据库
|
||||
lawsDomesticStandardService.saveBatch(insertDomesticList, insertDomesticList.size());
|
||||
// 同步es数据库
|
||||
insertDomesticList.forEach(e ->
|
||||
lawsHomeSearchService.updateEsData(LawsHomeSearchCommon.LAWS_DOMESTIC_STANDARD, e.getId(), LawsHomeSearchCommon.LAWS_ES_ADD));
|
||||
long time1 = System.currentTimeMillis();
|
||||
log.info("=====================同步国内法规标准数据:{}条,耗时:{}毫秒=====================", insertDomesticList.size(), time1 - start);
|
||||
|
||||
// 同步国内法规相关文档
|
||||
String fileUrl = "xiaobodata/openApi/domesticLaws/getFile";
|
||||
insertDomesticList.forEach(lawsDomesticStandard -> {
|
||||
String id = lawsDomesticStandard.getId();
|
||||
String code = lawsDomesticStandard.getStandardNumber();
|
||||
Map<String, String> fileParamMap = new HashMap<>();
|
||||
fileParamMap.put("lawCode", code);
|
||||
Map<String, Object> objectMap = asmsPostUtil.sendGetReq2(fileUrl, fileParamMap);
|
||||
if (!Objects.isNull(objectMap)) {
|
||||
Map<String, String> standardTextPdf = (Map<String, String>) objectMap.get("standardTextPdf");
|
||||
String fileName = standardTextPdf.get("fileName");
|
||||
String fileType = standardTextPdf.get("fileType");
|
||||
String uri = standardTextPdf.get("url");
|
||||
if (StringUtils.isNotBlank(uri)) {
|
||||
upload(uri, fileName, fileType, id, code);
|
||||
}
|
||||
Map<String, String> standardTextWord = (Map<String, String>) objectMap.get("standardTextWord");
|
||||
fileName = standardTextWord.get("fileName");
|
||||
fileType = standardTextWord.get("fileType");
|
||||
uri = standardTextWord.get("url");
|
||||
if (StringUtils.isNotBlank(uri)) {
|
||||
upload(uri, fileName, fileType, id, code);
|
||||
}
|
||||
}
|
||||
});
|
||||
long time2 = System.currentTimeMillis();
|
||||
log.info("=====================同步国内法规文件耗时:{}毫秒=====================", time2 - time1);
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
log.info("=====================全部同步完成,耗时:{} 毫秒=====================", end - start);
|
||||
log.info("=====================定时任务同步结束=====================");
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/11/3 13:49
|
||||
* @Description: 同步文档拆分
|
||||
**/
|
||||
@Transactional
|
||||
public void syncSplit() {
|
||||
log.info("=====================定时同步文档拆分=====================");
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
// 文档拆分
|
||||
String url = "xiaobodata/openApi/article/search";
|
||||
Map<String, String> paramMap = new HashMap<>();
|
||||
paramMap.put("pageNo", "1");
|
||||
paramMap.put("pageSize", "2");
|
||||
Map<String, Object> totalMap = asmsPostUtil.sendGetReq2(url, paramMap);
|
||||
Integer total = (Integer) totalMap.get("total");
|
||||
paramMap.put("pageSize", total.toString());
|
||||
|
||||
List<Map<String, String>> mapList = asmsPostUtil.sendGetReq(url, paramMap);
|
||||
if (Objects.isNull(mapList)) {
|
||||
log.info("=====================没有获取到ASMS系统数据,同步结束=====================");
|
||||
return;
|
||||
}
|
||||
|
||||
List<SarFileSplitInfoEO> allSplitList = sarFileSplitInfoService.list();
|
||||
List<String> codeList = allSplitList.stream().map(SarFileSplitInfoEO::getSerialNumber).collect(Collectors.toList());
|
||||
|
||||
List<SarFileSplitInfoEO> insertSplitList = new ArrayList<>();
|
||||
mapList.forEach(eMap -> {
|
||||
String code = eMap.get("code");
|
||||
if (CollectionUtils.isEmpty(codeList) || !codeList.contains(code)) {
|
||||
LambdaQueryWrapper<LawsDomesticStandard> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(LawsDomesticStandard::getStandardNumber, code);
|
||||
LawsDomesticStandard lawsDomesticStandard = lawsDomesticStandardService.getOne(queryWrapper);
|
||||
|
||||
LambdaQueryWrapper<OSSFile> queryWrapper1 = new LambdaQueryWrapper<>();
|
||||
queryWrapper1.eq(OSSFile::getStandardId, lawsDomesticStandard.getId());
|
||||
queryWrapper1.eq(OSSFile::getStandardFileType, "publish_of_original");
|
||||
queryWrapper1.like(OSSFile::getFileName, ".docx");
|
||||
OSSFile ossFile = ossFileService.getOne(queryWrapper1);
|
||||
|
||||
SarFileSplitInfoEO sarFileSplitInfoEO = new SarFileSplitInfoEO();
|
||||
sarFileSplitInfoEO.setStandardId(lawsDomesticStandard.getId());
|
||||
sarFileSplitInfoEO.setSerialNumber(lawsDomesticStandard.getStandardNumber());
|
||||
sarFileSplitInfoEO.setTitle(lawsDomesticStandard.getStandardName());
|
||||
sarFileSplitInfoEO.setFileType("publish_of_original");
|
||||
sarFileSplitInfoEO.setFileId(ossFile.getId());
|
||||
sarFileSplitInfoEO.setFileName(ossFile.getFileName());
|
||||
sarFileSplitInfoEO.setSplitStatus("1");
|
||||
sarFileSplitInfoEO.setCreateTime(getSimpleDate2(eMap.get("createTime")));
|
||||
sarFileSplitInfoEO.setUpdateTime(getSimpleDate2(eMap.get("updateTime")));
|
||||
sarFileSplitInfoEO.setIsAsmsImport("1");
|
||||
sarFileSplitInfoEO.setAuthor("云平台");
|
||||
sarFileSplitInfoEO.setSplitResult("成功");
|
||||
|
||||
sarFileSplitInfoEO.setId(UUIDUtils.randomUUID20());
|
||||
|
||||
insertSplitList.add(sarFileSplitInfoEO);
|
||||
}
|
||||
});
|
||||
if (CollectionUtils.isEmpty(insertSplitList)) {
|
||||
log.info("=====================昨天新增拆分0条,同步结束=====================");
|
||||
return;
|
||||
}
|
||||
|
||||
sarFileSplitInfoService.saveBatch(insertSplitList, insertSplitList.size());
|
||||
long time1 = System.currentTimeMillis();
|
||||
log.info("=====================同步标准拆分数据:{}条,耗时:{}毫秒=====================", insertSplitList.size(), time1 - start);
|
||||
|
||||
// 单条拆分的详情
|
||||
String splitUrl = "xiaobodata/openApi/article/details";
|
||||
List<SysDictItem> sysDictItemList = sysDictItemService.list();
|
||||
Map<String, String> paramMap1 = new HashMap<>();
|
||||
Map<String, String> paramMap2 = new HashMap<>();
|
||||
Map<String, String> paramMap3 = new HashMap<>();
|
||||
Map<String, List<LawsDocumentSplit>> infoMap = new HashMap<>();
|
||||
int[] n = {0};
|
||||
insertSplitList.forEach(sarFileSplitInfoEO -> {
|
||||
paramMap.put("standardCode", sarFileSplitInfoEO.getSerialNumber());
|
||||
paramMap1.put("standardCode", sarFileSplitInfoEO.getSerialNumber());
|
||||
List<Map<String, String>> mapListAll = asmsPostUtil.sendGetReq(splitUrl, paramMap1);
|
||||
List<LawsDocumentSplit> insertDocumentList = new ArrayList<>();
|
||||
mapListAll.forEach(eMap -> {
|
||||
// 单个法规的条文解读详情
|
||||
paramMap2.put("standardCode", sarFileSplitInfoEO.getSerialNumber());
|
||||
paramMap2.put("termsCode", eMap.get("termsNum"));
|
||||
Map<String, Object> objectMap = asmsPostUtil.sendGetReq2("xiaobodata/openApi/article/interpretation/details", paramMap2);
|
||||
|
||||
// 单个法规的条文标签详情
|
||||
paramMap3.put("standardCode", sarFileSplitInfoEO.getSerialNumber());
|
||||
paramMap3.put("termsCode", eMap.get("termsNum"));
|
||||
Map<String, Object> objectMap2 = asmsPostUtil.sendGetReq2("xiaobodata/openApi/article/label/details", paramMap3);
|
||||
|
||||
LawsDocumentSplit lawsDocumentSplit = new LawsDocumentSplit();
|
||||
lawsDocumentSplit.setInfoId(sarFileSplitInfoEO.getId());
|
||||
lawsDocumentSplit.setItemNum(eMap.get("termsNum"));
|
||||
lawsDocumentSplit.setItemTitle(eMap.get("termsName"));
|
||||
lawsDocumentSplit.setItemContent(eMap.get("articleContent"));
|
||||
lawsDocumentSplit.setCreateTime(getSimpleDate2(eMap.get("createTime")));
|
||||
lawsDocumentSplit.setUpdateTime(getSimpleDate2(eMap.get("updateTime")));
|
||||
|
||||
lawsDocumentSplit.setInterpretationArticles((String) objectMap.get("termsInterpretation"));
|
||||
|
||||
lawsDocumentSplit.setFunctionClassification((String) objectMap2.get("functionClassification"));
|
||||
lawsDocumentSplit.setFunctionProfessional((String) objectMap2.get("functionProfession"));
|
||||
lawsDocumentSplit.setFunctionGroupCode((String) objectMap2.get("groupingNum"));
|
||||
lawsDocumentSplit.setFunctionGroupName((String) objectMap2.get("groupingNum"));
|
||||
lawsDocumentSplit.setCerImplementDate((String) objectMap2.get("implementDateCertified"));
|
||||
lawsDocumentSplit.setNewCerImplementDate((String) objectMap2.get("implementDateNewCer"));
|
||||
lawsDocumentSplit.setNewRegisterImplementDate((String) objectMap2.get("implementDateNewRegister"));
|
||||
lawsDocumentSplit.setLawsRequireType((String) objectMap2.get("lawsRequireType"));
|
||||
lawsDocumentSplit.setApplications((String) objectMap2.get("modelsType"));
|
||||
lawsDocumentSplit.setDynamicType((String) objectMap2.get("powerType"));
|
||||
|
||||
lawsDocumentSplit.setId(UUIDUtils.randomUUID20());
|
||||
|
||||
lawsDocumentSplit.setLawsRequireType(getItemValues(lawsDocumentSplit.getLawsRequireType(),
|
||||
"1702212236079886338", sysDictItemList)); // 法规要求类型
|
||||
lawsDocumentSplit.setFunctionClassification(getItemValues(lawsDocumentSplit.getFunctionClassification(),
|
||||
"1702212237296234497", sysDictItemList)); // 功能分类
|
||||
lawsDocumentSplit.setFunctionProfessional(getItemValues(lawsDocumentSplit.getFunctionProfessional(),
|
||||
"1702202280677044226", sysDictItemList)); // 功能专业
|
||||
lawsDocumentSplit.setApplications(getItemValues(lawsDocumentSplit.getApplications(),
|
||||
"1702518672924110850", sysDictItemList)); // 适用车型
|
||||
lawsDocumentSplit.setDynamicType(getItemValues(lawsDocumentSplit.getDynamicType(),
|
||||
"1702518671166697474", sysDictItemList)); // 动力类型
|
||||
|
||||
insertDocumentList.add(lawsDocumentSplit);
|
||||
lawsDocumentSplitMapper.insert(lawsDocumentSplit);
|
||||
n[0]++;
|
||||
});
|
||||
infoMap.put(sarFileSplitInfoEO.getId(), insertDocumentList);
|
||||
});
|
||||
long time2 = System.currentTimeMillis();
|
||||
log.info("=====================同步DocumentSplit条文数据:{}条,耗时:{}毫秒=====================", n[0], time2 - time1);
|
||||
|
||||
insertSplitList.forEach(sarFileSplitInfoEO -> {
|
||||
String infoId = sarFileSplitInfoEO.getId();
|
||||
List<LawsDocumentSplit> lawsDocumentSplitList = infoMap.get(infoId);
|
||||
List<String> itemNumList = lawsDocumentSplitList.stream().map(LawsDocumentSplit::getItemNum).collect(Collectors.toList());
|
||||
|
||||
// 对目录排序
|
||||
Collections.sort(itemNumList, new AlphanumericComparator());
|
||||
Map<String, Long> sortMap = new HashMap<>();
|
||||
for (int i = 0; i < itemNumList.size(); i++) {
|
||||
sortMap.put(itemNumList.get(i), i+2L);
|
||||
}
|
||||
List<SarFileSplitMenuEO> sarFileSplitMenuEOList = new java.util.ArrayList<>();
|
||||
// 根目录
|
||||
SarFileSplitMenuEO rootEO = new SarFileSplitMenuEO();
|
||||
String rootId = UUIDUtils.randomUUID20();
|
||||
rootEO.setId(rootId);
|
||||
rootEO.setInfoId(infoId);
|
||||
rootEO.setName("总目录");
|
||||
rootEO.setDisplaySeq(1L);
|
||||
rootEO.setValidFlag(0);
|
||||
sarFileSplitMenuEOMapper.insertSelective(rootEO);
|
||||
|
||||
Map<String, String> idMap = new HashMap<>();
|
||||
lawsDocumentSplitList.forEach(lawsDocumentSplit -> {
|
||||
SarFileSplitMenuEO sarFileSplitMenuEO = new SarFileSplitMenuEO();
|
||||
String itemNum = lawsDocumentSplit.getItemNum();
|
||||
String id = UUIDUtils.randomUUID20();
|
||||
sarFileSplitMenuEO.setId(id);
|
||||
sarFileSplitMenuEO.setInfoId(infoId);
|
||||
sarFileSplitMenuEO.setName(itemNum);
|
||||
sarFileSplitMenuEO.setDisplaySeq(sortMap.get(itemNum));
|
||||
sarFileSplitMenuEO.setValidFlag(0);
|
||||
String itemTitle = lawsDocumentSplit.getItemTitle();
|
||||
sarFileSplitMenuEO.setItemName(itemTitle.substring(0, Math.min(10, itemTitle.length())));
|
||||
sarFileSplitMenuEOList.add(sarFileSplitMenuEO);
|
||||
idMap.put(itemNum, id);
|
||||
|
||||
lawsDocumentSplit.setMenuId(id);
|
||||
lawsDocumentSplitMapper.updateById(lawsDocumentSplit);
|
||||
});
|
||||
|
||||
// 设置父id
|
||||
sarFileSplitMenuEOList.forEach(sarFileSplitMenuEO -> {
|
||||
String itemNum = sarFileSplitMenuEO.getName();
|
||||
String[] split = itemNum.split("\\.");
|
||||
if (split.length == 1) {
|
||||
sarFileSplitMenuEO.setPId(rootId);
|
||||
} else {
|
||||
// 去除数组中的最后一个元素
|
||||
split = Arrays.copyOf(split, split.length - 1);
|
||||
String pid = idMap.get(StringUtils.join(split, "."));
|
||||
if (StringUtils.isBlank(pid)) {
|
||||
pid = rootId;
|
||||
}
|
||||
sarFileSplitMenuEO.setPId(pid);
|
||||
}
|
||||
});
|
||||
sarFileSplitMenuEOMapper.insertForeach(sarFileSplitMenuEOList);
|
||||
});
|
||||
long time3 = System.currentTimeMillis();
|
||||
log.info("=====================生成拆分详情左侧目录耗时:{}毫秒=====================", time3 - time2);
|
||||
|
||||
insertSplitList.forEach(sarFileSplitInfoEO -> {
|
||||
String infoId = sarFileSplitInfoEO.getId();
|
||||
List<LawsDocumentSplit> lawsDocumentSplitList = infoMap.get(infoId);
|
||||
lawsDocumentSplitList.forEach(lawsDocumentSplit -> {
|
||||
String itemContent = lawsDocumentSplit.getItemContent();
|
||||
// 使用 jsoup 解析 HTML
|
||||
Document doc = Jsoup.parse(itemContent);
|
||||
|
||||
// 选择所有的 <p> 元素
|
||||
Elements paragraphs = doc.select("p");
|
||||
|
||||
// 存储提取的文本内容
|
||||
List<String> textContents = new java.util.ArrayList<>();
|
||||
|
||||
for (Element paragraph : paragraphs) {
|
||||
// 获取每个 <p> 元素的文本内容并添加到集合中
|
||||
String textContent = paragraph.text();
|
||||
textContents.add(textContent);
|
||||
}
|
||||
|
||||
for (int i = 0; i < textContents.size(); i++) {
|
||||
SarFileSplitItemsValEO sarFileSplitItemsValEO = new SarFileSplitItemsValEO();
|
||||
sarFileSplitItemsValEO.setId(UUIDUtils.randomUUID20());
|
||||
sarFileSplitItemsValEO.setType("TEXT");
|
||||
sarFileSplitItemsValEO.setItemId(lawsDocumentSplit.getId());
|
||||
sarFileSplitItemsValEO.setItemContent(textContents.get(i));
|
||||
sarFileSplitItemsValEO.setDisplaySeq(i+1);
|
||||
sarFileSplitItemsValEO.setValidFlag(0);
|
||||
sarFileSplitItemsValEOService.insertSelective(sarFileSplitItemsValEO);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
for (SarFileSplitInfoEO sarFileSplitInfoEO : insertSplitList) {
|
||||
HashMap<String, Object> parameter = new HashMap<>();
|
||||
parameter.put("id", sarFileSplitInfoEO.getId());
|
||||
documentSplitService.publish(parameter);
|
||||
}
|
||||
long time4 = System.currentTimeMillis();
|
||||
log.info("=====================生成条文详情耗时:{}毫秒=====================", time4 - time3);
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
log.info("=====================全部同步完成,耗时:{} 毫秒=====================", end - start);
|
||||
log.info("=====================定时任务同步结束=====================");
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void upload(String url, String fileName, String fileType, String id, String code) {
|
||||
InputStream inputStream = asmsPostUtil.getFileByteArray(url);
|
||||
try {
|
||||
MinioUtil.upload(inputStream, filePath + url);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new JeroBootException("文件上传错误");
|
||||
}
|
||||
OSSFile ossFile = new OSSFile();
|
||||
ossFile.setFileName(fileName + "." + fileType);
|
||||
ossFile.setUrl(filePath + url);
|
||||
ossFile.setStandardId(id);
|
||||
ossFile.setStandardNo(code);
|
||||
ossFile.setStandardFileType("publish_of_original");
|
||||
ossFileService.save(ossFile);
|
||||
}
|
||||
|
||||
private Date getSimpleDate(String dateStr) {
|
||||
if (StringUtils.isBlank(dateStr)) return null;
|
||||
try {
|
||||
return simpleDateFormat.parse(dateStr);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new JeroBootException("时间格式转换错误");
|
||||
}
|
||||
}
|
||||
|
||||
private Date getSimpleDate2(String dateStr) {
|
||||
if (StringUtils.isBlank(dateStr)) return null;
|
||||
try {
|
||||
return dateFormat.parse(dateStr);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new JeroBootException("时间格式转换错误");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/23 15:57
|
||||
* @Description: 获取多日期字符串
|
||||
**/
|
||||
private String getManyDateString(String oldManyDateString) {
|
||||
if (StringUtils.isBlank(oldManyDateString)) return "";
|
||||
List<String> oldValueList = Arrays.asList(oldManyDateString.split("、"));
|
||||
// 使用正则表达式提取日期部分
|
||||
Pattern pattern = Pattern.compile("\\d{4}年\\d{2}月\\d{2}日");
|
||||
|
||||
List<String> valueList = new java.util.ArrayList<>();
|
||||
oldValueList.forEach(value -> {
|
||||
Matcher matcher = pattern.matcher(value);
|
||||
String dateStr;
|
||||
if (matcher.find()) {
|
||||
dateStr = matcher.group(0);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Date parse = oldDateFormat.parse(dateStr);
|
||||
String format = simpleDateFormat.format(parse);
|
||||
valueList.add(format);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
throw new JeroBootException("时间格式转换错误");
|
||||
}
|
||||
});
|
||||
if (valueList.size() == 1) {
|
||||
// 如果只有一个日期值,则复制成两个,用于查询和排序
|
||||
return valueList.get(0) + "," + valueList.get(0);
|
||||
}
|
||||
List<LocalDate> dateList = valueList.stream()
|
||||
.map(LocalDate::parse) // 解析日期字符串为 LocalDate 对象
|
||||
.sorted() // 按照日期大小进行排序
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 将排序后的 LocalDate 对象转换为字符串
|
||||
List<String> sortedDateStrList = dateList.stream()
|
||||
.map(LocalDate::toString)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return String.join(",", sortedDateStrList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/23 15:09
|
||||
* @Description: 获取字典值
|
||||
**/
|
||||
private String getItemValues(String itemTexts, String dictId, List<SysDictItem> sysDictItemList) {
|
||||
if (StringUtils.isBlank(itemTexts)) return "";
|
||||
List<String> itemTextList = Arrays.asList(itemTexts.split(";"));
|
||||
List<String> itemValues = sysDictItemList.stream()
|
||||
.filter(sysDictItem -> itemTextList.contains(sysDictItem.getItemText()) && dictId.equals(sysDictItem.getDictId()))
|
||||
.map(SysDictItem::getItemValue).collect(Collectors.toList());
|
||||
return StringUtils.join(itemValues, ",");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
package com.jero.modules.docking.asms.util;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/25 9:33
|
||||
* @Description: 目录顺序排序
|
||||
*/
|
||||
public class AlphanumericComparator implements Comparator<String> {
|
||||
private Pattern pattern = Pattern.compile("(\\d+|\\D+)");
|
||||
|
||||
@Override
|
||||
public int compare(String s1, String s2) {
|
||||
Matcher matcher1 = pattern.matcher(s1);
|
||||
Matcher matcher2 = pattern.matcher(s2);
|
||||
|
||||
while (matcher1.find() && matcher2.find()) {
|
||||
String group1 = matcher1.group();
|
||||
String group2 = matcher2.group();
|
||||
|
||||
int result;
|
||||
if (isInteger(group1) && isInteger(group2)) {
|
||||
result = Integer.compare(Integer.parseInt(group1), Integer.parseInt(group2));
|
||||
} else {
|
||||
result = group1.compareTo(group2);
|
||||
}
|
||||
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private boolean isInteger(String s) {
|
||||
try {
|
||||
Integer.parseInt(s);
|
||||
return true;
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
-149
@@ -1,149 +0,0 @@
|
||||
package com.jero.modules.docking.asms.util;
|
||||
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.util.RedisUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/17 15:12
|
||||
* @Description: 远程调用
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class AsmsPostUtil {
|
||||
|
||||
@Autowired
|
||||
private RestTemplate restTemplate;
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
@Value("${asms.host}")
|
||||
private String host;
|
||||
@Value("${asms.username}")
|
||||
private String username;
|
||||
@Value("${asms.password}")
|
||||
private String password;
|
||||
@Value("${asms.expire}")
|
||||
private Long expire;
|
||||
// 汽车标准数字化平台ASMS权限验证token
|
||||
private final static String ASMS_SYSTEM_AUTH_TOKEN = "ASMS_SYSTEM_AUTH_TOKEN";
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/17 15:43
|
||||
* @Description: 获取token字符串
|
||||
**/
|
||||
private String getToken() {
|
||||
// 从redis中获取token
|
||||
String token = (String) redisUtil.get(ASMS_SYSTEM_AUTH_TOKEN);
|
||||
// 如果token为空则重新获取
|
||||
if (StringUtils.isBlank(token)) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("username", username);
|
||||
map.put("password", password);
|
||||
ResponseEntity<Result> responseEntity = restTemplate.postForEntity(host + "xiaobodata/openApi/login", map, Result.class);
|
||||
if (!responseEntity.getBody().isSuccess()) {
|
||||
System.out.println("汽车标准数字化平台:token获取失败" + responseEntity.getBody().toString());
|
||||
throw new JeroBootException("汽车标准数字化平台:token获取失败" + responseEntity.getBody().toString());
|
||||
}
|
||||
Map<String, String> resultMap = (Map<String, String>) responseEntity.getBody().getResult();
|
||||
token = resultMap.get("token");
|
||||
// 将新获取的token存入redis
|
||||
redisUtil.set(ASMS_SYSTEM_AUTH_TOKEN, token, expire * 60 * 60);
|
||||
log.info("new token is creating: {}", token);
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/17 16:33
|
||||
* @Description: 发送get请求
|
||||
* uri:接口地址
|
||||
* map:参数map
|
||||
**/
|
||||
public List<Map<String, String>> sendGetReq(String uri, Map<String, String> map) {
|
||||
ResponseEntity<Result> responseEntity = getSendGetReq(uri, map);
|
||||
Map<String, Object> resultMap = (Map<String, Object>) responseEntity.getBody().getResult();
|
||||
if (Objects.isNull(resultMap)) {
|
||||
throw new JeroBootException("返回数据为空");
|
||||
}
|
||||
List<Map<String, String>> mapList = (List<Map<String, String>>) resultMap.get("records");
|
||||
if (CollectionUtils.isEmpty(mapList)) {
|
||||
mapList = new ArrayList<>();
|
||||
Map<String, String> result = (Map<String, String>) responseEntity.getBody().getResult();
|
||||
if (result.containsKey("records")) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
mapList.add(result);
|
||||
}
|
||||
log.info("返回{}条数据", mapList.size());
|
||||
return mapList;
|
||||
}
|
||||
|
||||
public Map<String, Object> sendGetReq2(String uri, Map<String, String> map) {
|
||||
ResponseEntity<Result> responseEntity = getSendGetReq(uri, map);
|
||||
return (Map<String, Object>) responseEntity.getBody().getResult();
|
||||
}
|
||||
|
||||
private ResponseEntity<Result> getSendGetReq(String uri, Map<String, String> map) {
|
||||
// 准备请求头
|
||||
String token = getToken();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Content-Type", "application/x-www-form-urlencoded");
|
||||
headers.set("X-Access-Token", token);
|
||||
|
||||
if (StringUtils.isBlank(uri)) {
|
||||
throw new JeroBootException("url不能为空");
|
||||
}
|
||||
// 准备url
|
||||
String url = host + uri;
|
||||
if (!Objects.isNull(map)) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
map.forEach((k, v) -> sb.append("&" + k + "=" + v));
|
||||
String s = sb.toString();
|
||||
url += "?" + s.substring(1);
|
||||
}
|
||||
|
||||
ResponseEntity<Result> responseEntity;
|
||||
try {
|
||||
log.info("request url : {}", url);
|
||||
responseEntity = restTemplate.exchange(url.toString(),
|
||||
HttpMethod.GET, new HttpEntity<>(null, headers), Result.class);
|
||||
} catch (Exception e) {
|
||||
log.info("old token is deleting: {}", token);
|
||||
redisUtil.del(ASMS_SYSTEM_AUTH_TOKEN);
|
||||
e.printStackTrace();
|
||||
throw new JeroBootException("操作失败,请稍后重试");
|
||||
}
|
||||
|
||||
if (!responseEntity.getBody().isSuccess()) {
|
||||
System.out.println("汽车标准数字化平台:请求发送失败" + responseEntity.getBody().toString());
|
||||
throw new JeroBootException("汽车标准数字化平台:请求发送失败" + responseEntity.getBody().toString());
|
||||
}
|
||||
return responseEntity;
|
||||
}
|
||||
|
||||
public InputStream getFileByteArray(String fileUrl) {
|
||||
// 执行GET请求
|
||||
ResponseEntity<byte[]> response = restTemplate.getForEntity(host + fileUrl, byte[].class);
|
||||
byte[] bytes = response.getBody();
|
||||
return new ByteArrayInputStream(bytes);
|
||||
}
|
||||
|
||||
}
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
package com.jero.modules.docking.download.config;
|
||||
|
||||
import com.jero.modules.docking.download.service.DownloadDecryptFileService;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author lqt
|
||||
* @version 1.0
|
||||
* @date 2023/11/23 18:20
|
||||
*/
|
||||
@Component
|
||||
public class DownloadInterceptor implements HandlerInterceptor{
|
||||
|
||||
@Resource
|
||||
private DownloadDecryptFileService downloadDecryptFileService;
|
||||
|
||||
public DownloadInterceptor(DownloadDecryptFileService downloadDecryptFileService) {
|
||||
this.downloadDecryptFileService = downloadDecryptFileService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 预处理回调方法,实现处理器的预处理(如检查登陆),第三个参数为响应的处理器
|
||||
* 返回值:true表示继续流程(如调用下一个拦截器或处理器);false表示流程中断(如登录检查失败),不会继续调用其他的拦截器或处理器,此时我们需要通过response来产生响应
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 后处理回调方法,实现处理器的后处理(但在渲染视图之前),此时我们可以通过modelAndView(模型和视图对象)对模型数据进行处理或对视图进行处理,modelAndView也可能为null
|
||||
*/
|
||||
@Override
|
||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable ModelAndView modelAndView) throws Exception {
|
||||
downloadDecryptFileService.downloadDecryptFile(request,response,handler,"1");
|
||||
}
|
||||
|
||||
/**
|
||||
*整个请求处理完毕回调方法,即在视图渲染完毕时回调,如性能监控中我们可以在此记录结束时间并输出消耗时间,还可以进行一些资源清理,类似于try-catch-finally中的finally,但仅调用处理器执行链中
|
||||
*/
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable Exception ex) throws Exception {
|
||||
downloadDecryptFileService.downloadDecryptFile(request,response,handler,null);
|
||||
}
|
||||
}
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
package com.jero.modules.docking.download.config;
|
||||
|
||||
import com.jero.modules.docking.download.service.DownloadDecryptFileService;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author lqt
|
||||
* @version 1.0
|
||||
* @date 2023/11/23 18:21
|
||||
*/
|
||||
@Configuration
|
||||
public class InterceptorConfig implements WebMvcConfigurer {
|
||||
@Resource
|
||||
private DownloadDecryptFileService downloadDecryptFileService;
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(new DownloadInterceptor(downloadDecryptFileService)).addPathPatterns("/**");
|
||||
}
|
||||
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
package com.jero.modules.docking.download.controller;
|
||||
|
||||
import com.jero.modules.docking.utils.IntekeyUtils;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* @author lqt
|
||||
* @version 1.0
|
||||
* @date 2023/11/27 17:41
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/home/search")
|
||||
public class SearchController {
|
||||
|
||||
|
||||
@PostMapping(value = "/download")
|
||||
public void downloadAndView(@RequestParam("file") MultipartFile file,
|
||||
@RequestParam("url") String url,
|
||||
@RequestParam("appCode") String appCode,
|
||||
@RequestParam("secretKey") String secretKey,
|
||||
@RequestParam("scope") Integer scope,
|
||||
HttpServletResponse response) {
|
||||
try (InputStream inputStream = IntekeyUtils.DecryptFile(url, appCode, secretKey, scope, file);
|
||||
OutputStream outputStream = response.getOutputStream()
|
||||
) {
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
while ((len = inputStream.read(buf)) > 0) {
|
||||
outputStream.write(buf, 0, len);
|
||||
}
|
||||
response.flushBuffer();
|
||||
} catch (Exception e) {
|
||||
response.setStatus(404);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
package com.jero.modules.docking.download.service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author lqt
|
||||
* @version 1.0
|
||||
* @date 2023/11/24 9:04
|
||||
*/
|
||||
public interface DownloadDecryptFileService {
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LQT
|
||||
* @date 2023/11/24 9:06
|
||||
* @param request
|
||||
* @param response
|
||||
* @param handler
|
||||
* @param type 1 为直接返回文件流,其他为modelandview
|
||||
* @return void
|
||||
*/
|
||||
void downloadDecryptFile(HttpServletRequest request, HttpServletResponse response, Object handler,String type);
|
||||
}
|
||||
-237
@@ -1,237 +0,0 @@
|
||||
package com.jero.modules.docking.download.service.impl;
|
||||
|
||||
import com.jero.common.api.vo.ResultCommon;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.modules.docking.download.service.DownloadDecryptFileService;
|
||||
import com.jero.modules.docking.utils.IntekeyUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.util.ContentCachingResponseWrapper;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author lqt
|
||||
* @version 1.0
|
||||
* @date 2023/11/24 9:04
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DownloadDecryptFileServiceImpl implements DownloadDecryptFileService {
|
||||
|
||||
@Value("#{'${download.download_url}'.split(',')}")
|
||||
private List<String> downloadUrl;
|
||||
|
||||
@Value("#{'${download.view_url}'.split(',')}")
|
||||
private List<String> viewUrl;
|
||||
|
||||
@Value("#{'${download.enable}'}")
|
||||
private boolean enable;
|
||||
|
||||
/**
|
||||
* 管理员角色
|
||||
*/
|
||||
@Value("#{'${download.admin_role_code}'.split(',')}")
|
||||
private List<String> adminRoleCode;
|
||||
|
||||
/**
|
||||
* 加密
|
||||
*/
|
||||
@Value("#{'${download.encrypt.url}'}")
|
||||
private String encryptUrl;
|
||||
@Value("#{'${download.encrypt.app_code}'}")
|
||||
private String encryptAppCode;
|
||||
@Value("#{'${download.encrypt.secret_key}'}")
|
||||
private String encryptSecretKey;
|
||||
|
||||
/**
|
||||
* 解密
|
||||
*/
|
||||
@Value("#{'${download.decrypt.url}'}")
|
||||
private String decryptUrl;
|
||||
@Value("#{'${download.decrypt.app_code}'}")
|
||||
private String decryptAppCode;
|
||||
@Value("#{'${download.decrypt.secret_key}'}")
|
||||
private String decryptSecretKey;
|
||||
|
||||
/**
|
||||
* 研发域
|
||||
*/
|
||||
@Value("#{'${download.scope_dev}'}")
|
||||
private int scopeDev;
|
||||
/**
|
||||
* 办公域
|
||||
*/
|
||||
@Value("#{'${download.scope_work}'}")
|
||||
private int scopeWork;
|
||||
|
||||
|
||||
@Override
|
||||
public void downloadDecryptFile(HttpServletRequest request, HttpServletResponse response, Object handler,String type) {
|
||||
if(!enable){
|
||||
return;
|
||||
}
|
||||
// 判断返回值是否为文件流,否则其他接口返回值会变更成字符串,导致前端无法解析
|
||||
HandlerMethod handlerMethod = (HandlerMethod) handler;
|
||||
InputStream responseBody = null;
|
||||
try {
|
||||
String returnType = handlerMethod.getMethod().getReturnType().getName();
|
||||
if(!Objects.equals(returnType,"void") && !Objects.equals(returnType,"org.springframework.web.servlet.ModelAndView")){
|
||||
return;
|
||||
}
|
||||
if(Objects.equals(returnType,"void") && !Objects.equals(type,"1")){
|
||||
return;
|
||||
}
|
||||
ContentCachingResponseWrapper wrapper = WebUtils.getNativeResponse(response, ContentCachingResponseWrapper.class);
|
||||
if (wrapper != null) {
|
||||
responseBody = wrapper.getContentInputStream();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
response.setStatus(404);
|
||||
}
|
||||
|
||||
String contentType = response.getContentType();
|
||||
String fileName = getFileName(response);
|
||||
|
||||
MultipartFile file = getMultipartFile(response,responseBody, contentType, fileName);
|
||||
// 访问路径
|
||||
String str = request.getRequestURI();
|
||||
|
||||
boolean b = isBoolean(str, viewUrl);
|
||||
|
||||
boolean b1 = isBoolean(str, downloadUrl);
|
||||
|
||||
if(b){
|
||||
// 预览,进行解密
|
||||
decryptFile(response, file, null);
|
||||
}else if(b1){
|
||||
// 下载文件 先解密,判断组织域,加密
|
||||
try (InputStream is = IntekeyUtils.DecryptFile(decryptUrl, decryptAppCode, decryptSecretKey, null, file)) {
|
||||
MultipartFile fileDecrypt = getMultipartFile(response,is, contentType, fileName);
|
||||
int scope = getScope();
|
||||
// 加密
|
||||
encryptFile(response, fileDecrypt, scope);
|
||||
} catch (Exception e) {
|
||||
response.setStatus(404);
|
||||
}
|
||||
|
||||
}else{
|
||||
// excel 判断组织域,加密
|
||||
int scope = getScope();
|
||||
// 加密
|
||||
encryptFile(response, file, scope);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getFileName(HttpServletResponse response) {
|
||||
String fileName = "";
|
||||
String headerField = response.getHeader("Content-Disposition");
|
||||
|
||||
if (!StringUtils.isBlank(headerField) || headerField.contains("fileName=") || headerField.contains("filename=")){
|
||||
String name = "";
|
||||
if(headerField.contains("fileName=")){
|
||||
name = "fileName";
|
||||
}else{
|
||||
name = "filename";
|
||||
}
|
||||
fileName = headerField.substring(headerField.lastIndexOf(name + "=") + 9);
|
||||
}else {
|
||||
fileName = UUID.randomUUID().toString();
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
|
||||
private void decryptFile(HttpServletResponse response, MultipartFile file, Integer scope) {
|
||||
try (InputStream is = IntekeyUtils.DecryptFile(decryptUrl, decryptAppCode, decryptSecretKey, scope, file)) {
|
||||
writeResponse(response, is);
|
||||
} catch (Exception e) {
|
||||
response.setStatus(404);
|
||||
}
|
||||
}
|
||||
|
||||
private void encryptFile(HttpServletResponse response, MultipartFile file, Integer scope) {
|
||||
try (InputStream is = IntekeyUtils.DecryptFile(encryptUrl, encryptAppCode, encryptSecretKey, scope, file)) {
|
||||
writeResponse(response, is);
|
||||
} catch (Exception e) {
|
||||
response.setStatus(404);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private MultipartFile getMultipartFile(HttpServletResponse response,InputStream responseBody,String contentType,String fileName) {
|
||||
MultipartFile file = null;
|
||||
try {
|
||||
file = new MockMultipartFile(ContentType.APPLICATION_OCTET_STREAM.toString(),fileName,contentType, responseBody);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
response.setStatus(404);
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
private boolean isBoolean(String str, List<String> viewUrl) {
|
||||
boolean b = false;
|
||||
for (String s : viewUrl) {
|
||||
if (str.contains(s)) {
|
||||
b = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
private int getScope() {
|
||||
// 角色信息中存在 【系统管理员】或者 【标准管理员】即加为研发密,其他情况都是OA密
|
||||
// 研发密比较高级(加密需要传参)
|
||||
// 研发域 scope = 51
|
||||
// 办公密 scope = 52
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
List<String> listRoleCode = Arrays.asList(sysUser.getRoleIds().split(","));
|
||||
if(CollectionUtils.isEmpty(listRoleCode)){
|
||||
throw new JeroBootException(ResultCommon.ERROR);
|
||||
}
|
||||
int scope = scopeWork;
|
||||
long l = listRoleCode.stream().filter(o->adminRoleCode.contains(o)).count();
|
||||
if(l > 0){
|
||||
scope = scopeDev;
|
||||
}
|
||||
return scope;
|
||||
}
|
||||
|
||||
private void writeResponse(HttpServletResponse response,InputStream is) {
|
||||
response.resetBuffer();
|
||||
try (OutputStream outputStream = response.getOutputStream()) {
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
while ((len = is.read(buf)) > 0) {
|
||||
outputStream.write(buf, 0, len);
|
||||
}
|
||||
response.flushBuffer();
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage());
|
||||
response.setStatus(404);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
package com.jero.modules.docking.hiwork.entity;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 17:49
|
||||
* @Description: 统一消息集成-钉钉消息
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="统一消息集成-钉钉消息", description="统一消息集成-钉钉消息")
|
||||
public class HiworkDingDingMsg {
|
||||
@ApiModelProperty(value = "异构系统标识")
|
||||
private String sysCode;
|
||||
@ApiModelProperty(value = "服务号")
|
||||
private String noticeServiceCode;
|
||||
@ApiModelProperty(value = "发送人员Id")
|
||||
private String useridList;
|
||||
@ApiModelProperty(value = "发送部门id")
|
||||
private String deptIdList;
|
||||
@ApiModelProperty(value = "agentId")
|
||||
private String agentId;
|
||||
@ApiModelProperty(value = "标题")
|
||||
private String title;
|
||||
@ApiModelProperty(value = "消息体")
|
||||
private JSONObject msg;
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
package com.jero.modules.docking.hiwork.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 14:39
|
||||
* @Description: 统一待办集成返回
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="统一待办集成返回", description="统一待办集成返回")
|
||||
public class HiworkResult {
|
||||
@ApiModelProperty(value = "成功true,失败false")
|
||||
private Boolean success;
|
||||
@ApiModelProperty(value = "成功1,失败0")
|
||||
private Integer code;
|
||||
@ApiModelProperty(value = "消息")
|
||||
private String msg;
|
||||
@ApiModelProperty(value = "成功null,失败null")
|
||||
private Object data;
|
||||
}
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
package com.jero.modules.docking.hiwork.entity;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 17:49
|
||||
* @Description: 统一消息集成-系统消息
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="统一消息集成-系统消息", description="统一消息集成-系统消息")
|
||||
public class HiworkSystemMsg {
|
||||
@ApiModelProperty(value = "异构系统标识")
|
||||
private String sysCode;
|
||||
@ApiModelProperty(value = "发送人员编号")
|
||||
private String sendCode;
|
||||
@ApiModelProperty(value = "发送人员姓名")
|
||||
private String sendName;
|
||||
@ApiModelProperty(value = "消息类型 字典")
|
||||
private String messageType;
|
||||
@ApiModelProperty(value = "消息标题")
|
||||
private String title;
|
||||
@ApiModelProperty(value = "消息接收人 集合")
|
||||
private JSONArray receiverList;
|
||||
@ApiModelProperty(value = "消息体")
|
||||
private JSONObject msg;
|
||||
}
|
||||
-76
@@ -1,76 +0,0 @@
|
||||
package com.jero.modules.docking.hiwork.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 14:22
|
||||
* @Description: 待办
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="统一待办集成", description="统一待办集成")
|
||||
public class HiworkTodo {
|
||||
@ApiModelProperty(value = "异构系统标识")
|
||||
private String sysCode;
|
||||
@ApiModelProperty(value = "标题")
|
||||
private String noticeTitle;
|
||||
@ApiModelProperty(value = "描述")
|
||||
private String noticeDescription;
|
||||
@ApiModelProperty(value = "流程编号")
|
||||
private String busiDefCode;
|
||||
@ApiModelProperty(value = "流程实例id")
|
||||
private String processId;
|
||||
@ApiModelProperty(value = "流程实例名称")
|
||||
private String processName;
|
||||
@ApiModelProperty(value = "流程类型,字典")
|
||||
private String processType;
|
||||
@ApiModelProperty(value = "任务id")
|
||||
private String taskId;
|
||||
@ApiModelProperty(value = "节点名称")
|
||||
private String taskName;
|
||||
@ApiModelProperty(value = "是否会签")
|
||||
private Integer multiInstance;
|
||||
@ApiModelProperty(value = "节点编号")
|
||||
private String nodeBusiCode;
|
||||
@ApiModelProperty(value = "跳转链接")
|
||||
private String businessLink;
|
||||
@ApiModelProperty(value = "APP跳转链接")
|
||||
private String appBusinessLink;
|
||||
@ApiModelProperty(value = "创建人code")
|
||||
private String createUserCode;
|
||||
@ApiModelProperty(value = "创建人姓名")
|
||||
private String createUserName;
|
||||
@ApiModelProperty(value = "接收人id")
|
||||
private String userId;
|
||||
@ApiModelProperty(value = "接收人code")
|
||||
private String userCode;
|
||||
@ApiModelProperty(value = "接收人姓名")
|
||||
private String userName;
|
||||
@ApiModelProperty(value = "参与者id")
|
||||
private String participantId;
|
||||
@ApiModelProperty(value = "参与者编号")
|
||||
private String participantCode;
|
||||
@ApiModelProperty(value = "接收时间")
|
||||
private Instant receiveTime;
|
||||
@ApiModelProperty(value = "截止时间")
|
||||
private Long dueTime;
|
||||
@ApiModelProperty(value = "业务主键")
|
||||
private String bid;
|
||||
@ApiModelProperty(value = "待办、已办")
|
||||
private String isTodo;
|
||||
@ApiModelProperty(value = "是否展示在列表中")
|
||||
private String isShow;
|
||||
@ApiModelProperty(value = "优先级")
|
||||
private String priority;
|
||||
@ApiModelProperty(value = "是否通知消息")
|
||||
private String notifyConfig;
|
||||
|
||||
}
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
package com.jero.modules.docking.hiwork.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/16 17:23
|
||||
* @Description: 统一待办集成-添加
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="统一待办集成-添加", description="统一待办集成-添加")
|
||||
public class HiworkTodoAdd {
|
||||
@ApiModelProperty(value = "标题")
|
||||
private String title;
|
||||
@ApiModelProperty(value = "任务id")
|
||||
private String taskId;
|
||||
@ApiModelProperty(value = "流程类型,字典")
|
||||
private String processType;
|
||||
@ApiModelProperty(value = "是否会签")
|
||||
private Integer isCounterSignature;
|
||||
@ApiModelProperty(value = "节点编号")
|
||||
private String nodeNumber;
|
||||
@ApiModelProperty(value = "跳转链接")
|
||||
private String jumpLink;
|
||||
@ApiModelProperty(value = "APP跳转链接")
|
||||
private String appJumpLink;
|
||||
@ApiModelProperty(value = "创建人id")
|
||||
private String creatorId;
|
||||
@ApiModelProperty(value = "接收人id")
|
||||
private String recipientId;
|
||||
@ApiModelProperty(value = "截止时间")
|
||||
private Long endTime;
|
||||
@ApiModelProperty(value = "业务主键")
|
||||
private String businessId;
|
||||
@ApiModelProperty(value = "待办、已办(1、待办 2已办 3结束 6 删除)")
|
||||
private String isTodo;
|
||||
}
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
package com.jero.modules.docking.hiwork.enums;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 15:05
|
||||
* @Description: 待办、已办
|
||||
*/
|
||||
public enum IsTodoEnum {
|
||||
TODO( "待办", "1"),
|
||||
DONE("已办", "2"),
|
||||
FINISH("结束", "3"),
|
||||
DEL("删除", "6")
|
||||
;
|
||||
|
||||
String name;
|
||||
String value;
|
||||
|
||||
IsTodoEnum(String name, String value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getName() {return name;}
|
||||
public String getValue() {return value;}
|
||||
}
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
package com.jero.modules.docking.hiwork.handle;
|
||||
|
||||
import com.jero.common.util.SpringContextUtils;
|
||||
import com.jero.modules.docking.hiwork.service.IHiworkMsgService;
|
||||
import com.jero.modules.message.handle.ISendMsgHandle;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/17 14:29
|
||||
* @Description: Hiwork钉钉消息
|
||||
**/
|
||||
@Slf4j
|
||||
public class DingDingSendMsgHandle implements ISendMsgHandle {
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/17 14:29
|
||||
* @Description: Hiwork钉钉消息
|
||||
**/
|
||||
@Override
|
||||
public void SendMsg(String esReceiver, String esTitle, String esContent) {
|
||||
IHiworkMsgService hiworkMsgService = SpringContextUtils.getBean(IHiworkMsgService.class);
|
||||
hiworkMsgService.sendDingDingMsg(Arrays.asList(esReceiver.split(",")), esTitle, esContent);
|
||||
}
|
||||
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
package com.jero.modules.docking.hiwork.handle;
|
||||
|
||||
import com.jero.common.util.SpringContextUtils;
|
||||
import com.jero.modules.docking.hiwork.service.IHiworkMsgService;
|
||||
import com.jero.modules.message.handle.ISendMsgHandle;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Slf4j
|
||||
public class SystemSendMsgHandle implements ISendMsgHandle {
|
||||
|
||||
@Override
|
||||
public void SendMsg(String esReceiver, String esTitle, String esContent) {
|
||||
IHiworkMsgService hiworkMsgService = SpringContextUtils.getBean(IHiworkMsgService.class);
|
||||
// TODO 先写死 01 消息类型(暂未确定)
|
||||
String messageType = "01";
|
||||
hiworkMsgService.sendSystemMsg(Arrays.asList(esReceiver.split(",")), messageType, esTitle, esContent);
|
||||
}
|
||||
|
||||
}
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
package com.jero.modules.docking.hiwork.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/16 15:18
|
||||
* @Description: 统一消息集成
|
||||
*/
|
||||
public interface IHiworkMsgService {
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/16 15:32
|
||||
* @Description: 发送钉钉消息
|
||||
* senderIdList:发送人员id集合
|
||||
* title:消息标题
|
||||
* content:文本内容
|
||||
**/
|
||||
void sendDingDingMsg(List<String> senderIdList, String title, String content);
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/16 16:11
|
||||
* @Description: 发送系统消息
|
||||
* senderId:发送人员id
|
||||
* receiverIdList:消息接收人id集合
|
||||
* messageType:消息类型 字典
|
||||
* title:消息标题
|
||||
* content:消息内容
|
||||
**/
|
||||
void sendSystemMsg(List<String> receiverIdList, String messageType, String title, String content);
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
package com.jero.modules.docking.hiwork.service;
|
||||
|
||||
import com.jero.modules.docking.hiwork.entity.HiworkTodoAdd;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 14:23
|
||||
* @Description: 待办
|
||||
*/
|
||||
public interface IHiworkTodoService {
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 15:12
|
||||
* @Description: 统一待办集成
|
||||
**/
|
||||
void sendTodoTask(List<HiworkTodoAdd> hiworkTodoAddList);
|
||||
|
||||
}
|
||||
-135
@@ -1,135 +0,0 @@
|
||||
package com.jero.modules.docking.hiwork.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.modules.docking.hiwork.entity.HiworkDingDingMsg;
|
||||
import com.jero.modules.docking.hiwork.entity.HiworkSystemMsg;
|
||||
import com.jero.modules.docking.hiwork.service.IHiworkMsgService;
|
||||
import com.jero.modules.docking.hiwork.util.HiworkPostUtil;
|
||||
import com.jero.common.api.vo.ResultCommon;
|
||||
import com.jero.modules.system.entity.SysUser;
|
||||
import com.jero.modules.system.service.ISysUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/16 15:18
|
||||
* @Description: 统一消息集成
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class HiworkMsgServiceImpl implements IHiworkMsgService {
|
||||
|
||||
@Autowired
|
||||
private HiworkPostUtil hiworkPostUtil;
|
||||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
private final static String TEXT = "text"; // 消息类型-文本
|
||||
private final static String MSG_TYPE = "msgtype"; // 消息类型
|
||||
private final static String CONTENT = "content"; // 消息内容
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/16 15:32
|
||||
* @Description: 发送钉钉消息
|
||||
* senderIdList:发送人员id集合
|
||||
* content:文本内容
|
||||
**/
|
||||
@Override
|
||||
public void sendDingDingMsg(List<String> senderIdList, String title, String content) {
|
||||
HiworkDingDingMsg hiworkDingDingMsg = new HiworkDingDingMsg();
|
||||
// 异步系统标识
|
||||
hiworkDingDingMsg.setSysCode(HiworkPostUtil.getSysCode());
|
||||
|
||||
if (CollectionUtils.isEmpty(senderIdList)) {
|
||||
throw new JeroBootException(ResultCommon.EMPTY_COMMON, "senderIdList");
|
||||
}
|
||||
List<SysUser> senderUserList = sysUserService.listByIds(senderIdList);
|
||||
List<String> usernameList = senderUserList.stream().map(SysUser::getUsername).collect(Collectors.toList());
|
||||
// 发送人员id(工号以英文逗号分隔)
|
||||
hiworkDingDingMsg.setUseridList(StringUtils.join(usernameList, ","));
|
||||
// 标题
|
||||
hiworkDingDingMsg.setTitle(title);
|
||||
|
||||
// 消息体
|
||||
JSONObject msgJsonObject = new JSONObject();
|
||||
msgJsonObject.put(MSG_TYPE, TEXT);
|
||||
JSONObject textJsonObject = new JSONObject();
|
||||
textJsonObject.put(CONTENT, content);
|
||||
msgJsonObject.put(TEXT, textJsonObject);
|
||||
hiworkDingDingMsg.setMsg(msgJsonObject);
|
||||
|
||||
log.info("发送Hiwork钉钉消息: {}", JSONObject.toJSONString(hiworkDingDingMsg));
|
||||
|
||||
hiworkPostUtil.postDingDingMsg(hiworkDingDingMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/16 16:12
|
||||
* @Description: 发送系统消息
|
||||
* senderId:发送人员id
|
||||
* receiverIdList:消息接收人id集合
|
||||
* messageType:消息类型 字典
|
||||
* title:消息标题
|
||||
* content:消息内容
|
||||
**/
|
||||
@Override
|
||||
public void sendSystemMsg(List<String> receiverIdList, String messageType, String title, String content) {
|
||||
HiworkSystemMsg hiworkSystemMsg = new HiworkSystemMsg();
|
||||
|
||||
// 异步系统标识
|
||||
hiworkSystemMsg.setSysCode(HiworkPostUtil.getSysCode());
|
||||
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
// 发送人员编号
|
||||
hiworkSystemMsg.setSendCode(loginUser.getUsername());
|
||||
// 发送人员姓名
|
||||
hiworkSystemMsg.setSendName(loginUser.getRealname());
|
||||
// 消息类型
|
||||
hiworkSystemMsg.setMessageType(messageType);
|
||||
// 消息标题
|
||||
hiworkSystemMsg.setTitle(title);
|
||||
|
||||
if (CollectionUtils.isEmpty(receiverIdList)) {
|
||||
throw new JeroBootException(ResultCommon.EMPTY_COMMON, "receiverIdList");
|
||||
}
|
||||
List<SysUser> receiverUserList = sysUserService.listByIds(receiverIdList);
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
receiverUserList.forEach(receiverUser -> {
|
||||
Map<String, String> receiverMap = new HashMap<>();
|
||||
// 人员编号
|
||||
receiverMap.put("employeeNo", receiverUser.getUsername());
|
||||
// 人员名称
|
||||
receiverMap.put("userName", receiverUser.getRealname());
|
||||
jsonArray.add(receiverMap);
|
||||
});
|
||||
// 消息接收人 集合
|
||||
hiworkSystemMsg.setReceiverList(jsonArray);
|
||||
|
||||
// 消息体
|
||||
JSONObject msgJsonObject = new JSONObject();
|
||||
msgJsonObject.put(MSG_TYPE, TEXT);
|
||||
JSONObject textJsonObject = new JSONObject();
|
||||
textJsonObject.put(CONTENT, content);
|
||||
msgJsonObject.put(TEXT, textJsonObject);
|
||||
hiworkSystemMsg.setMsg(msgJsonObject);
|
||||
|
||||
log.info("发送Hiwork系统消息: {}", JSONObject.toJSONString(hiworkSystemMsg));
|
||||
|
||||
hiworkPostUtil.postSystemMsg(hiworkSystemMsg);
|
||||
}
|
||||
}
|
||||
-118
@@ -1,118 +0,0 @@
|
||||
package com.jero.modules.docking.hiwork.service.impl;
|
||||
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.modules.docking.hiwork.entity.HiworkTodoAdd;
|
||||
import com.jero.modules.docking.hiwork.service.IHiworkTodoService;
|
||||
import com.jero.modules.docking.hiwork.util.HiworkPostUtil;
|
||||
import com.jero.modules.docking.hiwork.entity.HiworkTodo;
|
||||
import com.jero.common.api.vo.ResultCommon;
|
||||
import com.jero.modules.system.entity.SysUser;
|
||||
import com.jero.modules.system.service.ISysUserService;
|
||||
import org.activiti.engine.RuntimeService;
|
||||
import org.activiti.engine.TaskService;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 14:23
|
||||
* @Description: 待办
|
||||
*/
|
||||
@Service
|
||||
public class HiworkTodoServiceImpl implements IHiworkTodoService {
|
||||
|
||||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
@Autowired
|
||||
private RuntimeService runtimeService;
|
||||
@Autowired
|
||||
private HiworkPostUtil hiworkPostUtil;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 15:12
|
||||
* @Description: 统一待办集成
|
||||
**/
|
||||
@Override
|
||||
public void sendTodoTask(List<HiworkTodoAdd> hiworkTodoAddList) {
|
||||
if (CollectionUtils.isEmpty(hiworkTodoAddList)) {
|
||||
throw new JeroBootException(ResultCommon.EMPTY_COMMON, "hiworkTodoAddList");
|
||||
}
|
||||
|
||||
List<HiworkTodo> hiworkTodoList = new ArrayList<>();
|
||||
hiworkTodoAddList.forEach(hiworkTodoAdd -> {
|
||||
HiworkTodo hiworkTodo = new HiworkTodo();
|
||||
// 异步系统标识
|
||||
hiworkTodo.setSysCode(HiworkPostUtil.getSysCode());
|
||||
// 标题
|
||||
hiworkTodo.setNoticeTitle(hiworkTodoAdd.getTitle());
|
||||
|
||||
if (StringUtils.isBlank(hiworkTodoAdd.getTaskId())) {
|
||||
throw new JeroBootException(ResultCommon.EMPTY_COMMON, "taskId");
|
||||
}
|
||||
Task task = taskService.createTaskQuery().taskId(hiworkTodoAdd.getTaskId()).singleResult();
|
||||
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
|
||||
.processInstanceId(task.getProcessInstanceId()).singleResult();
|
||||
|
||||
// 流程实例id
|
||||
hiworkTodo.setProcessId(processInstance.getId());
|
||||
// 流程实例名称
|
||||
hiworkTodo.setProcessName(processInstance.getName());
|
||||
// 流程类型,字典
|
||||
hiworkTodo.setProcessType(hiworkTodoAdd.getProcessType());
|
||||
// 任务id
|
||||
hiworkTodo.setTaskId(hiworkTodoAdd.getTaskId());
|
||||
// 节点名称
|
||||
hiworkTodo.setTaskName(task.getName());
|
||||
// 是否会签
|
||||
hiworkTodo.setMultiInstance(hiworkTodoAdd.getIsCounterSignature());
|
||||
// 节点编号
|
||||
hiworkTodo.setNodeBusiCode(hiworkTodoAdd.getNodeNumber());
|
||||
// 跳转链接
|
||||
hiworkTodo.setBusinessLink(hiworkTodoAdd.getJumpLink());
|
||||
// APP跳转链接
|
||||
hiworkTodo.setAppBusinessLink(hiworkTodoAdd.getAppJumpLink());
|
||||
|
||||
if (StringUtils.isBlank(hiworkTodoAdd.getCreatorId())) {
|
||||
throw new JeroBootException(ResultCommon.EMPTY_COMMON, "creatorId");
|
||||
}
|
||||
SysUser creatorUser = sysUserService.getById(hiworkTodoAdd.getCreatorId());
|
||||
// 创建人code
|
||||
hiworkTodo.setCreateUserCode(creatorUser.getUsername());
|
||||
// 创建人姓名
|
||||
hiworkTodo.setCreateUserName(creatorUser.getRealname());
|
||||
|
||||
if (StringUtils.isBlank(hiworkTodoAdd.getRecipientId())) {
|
||||
throw new JeroBootException(ResultCommon.EMPTY_COMMON, "recipientId");
|
||||
}
|
||||
SysUser recipientUser = sysUserService.getById(hiworkTodoAdd.getRecipientId());
|
||||
// 接收人id
|
||||
hiworkTodo.setUserId(recipientUser.getId());
|
||||
// 接收人code
|
||||
hiworkTodo.setUserCode(recipientUser.getUsername());
|
||||
// 接收人姓名
|
||||
hiworkTodo.setUserName(recipientUser.getRealname());
|
||||
|
||||
// 截止时间
|
||||
hiworkTodo.setDueTime(hiworkTodoAdd.getEndTime());
|
||||
// 业务主键
|
||||
hiworkTodo.setBid(hiworkTodoAdd.getBusinessId());
|
||||
// 待办、已办
|
||||
hiworkTodo.setIsTodo(hiworkTodoAdd.getIsTodo());
|
||||
|
||||
hiworkTodoList.add(hiworkTodo);
|
||||
});
|
||||
|
||||
// 远程调用
|
||||
hiworkPostUtil.postTodo(hiworkTodoList);
|
||||
}
|
||||
}
|
||||
-98
@@ -1,98 +0,0 @@
|
||||
package com.jero.modules.docking.hiwork.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.common.api.dto.message.SendMessageDTO;
|
||||
import com.jero.common.api.vo.SendMessageAPI;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.modules.docking.hiwork.handle.DingDingSendMsgHandle;
|
||||
import com.jero.modules.docking.hiwork.handle.SystemSendMsgHandle;
|
||||
import com.jero.modules.message.entity.SysMessageTemplate;
|
||||
import com.jero.modules.message.handle.ISendMsgHandle;
|
||||
import com.jero.modules.message.handle.impl.SmsSendMsgHandle;
|
||||
import com.jero.modules.message.service.ISysMessageTemplateService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/17 11:23
|
||||
* @Description: 发送消息
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SendMessageServiceImpl implements SendMessageAPI {
|
||||
|
||||
@Resource
|
||||
private ISysMessageTemplateService sysMessageTemplateService;
|
||||
@Value("${hiwork.isSend}")
|
||||
private Boolean isSend;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/17 11:25
|
||||
* @Description: 根据模板发送消息
|
||||
**/
|
||||
@Override
|
||||
public void sendMessage(SendMessageDTO sendMessageDTO) {
|
||||
if(StringUtils.isEmpty(sendMessageDTO.getToUserId())){
|
||||
throw new JeroBootException("消息接收人id不能为空");
|
||||
}
|
||||
if(StringUtils.isEmpty(sendMessageDTO.getTemplateCode())){
|
||||
throw new JeroBootException("消息模板编码不能为空!");
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<SysMessageTemplate> query = new LambdaQueryWrapper<>();
|
||||
query.eq(SysMessageTemplate::getTemplateCode,sendMessageDTO.getTemplateCode());
|
||||
List<SysMessageTemplate> sysSmsTemplates = sysMessageTemplateService.list(query);
|
||||
if(CollectionUtils.isEmpty(sysSmsTemplates)){
|
||||
throw new JeroBootException("消息模板不存在");
|
||||
}
|
||||
SysMessageTemplate sysMessageTemplate = sysSmsTemplates.get(0);
|
||||
|
||||
try {
|
||||
// 替换模板内容
|
||||
if(!Objects.isNull(sendMessageDTO.getMap())){
|
||||
Map<String,String> map = sendMessageDTO.getMap();
|
||||
map.forEach((k,v)-> sysMessageTemplate.setTemplateContent(
|
||||
sysMessageTemplate.getTemplateContent().replace("${" + k + "}", v)));
|
||||
}
|
||||
|
||||
List<String> typeList = Arrays.asList(sysMessageTemplate.getTemplateType().split(","));
|
||||
typeList.forEach(type -> {
|
||||
log.info("消息标题:{},消息内容:{},消息类型:{}", sysMessageTemplate.getTemplateName(),sysMessageTemplate.getTemplateContent(), type);
|
||||
ISendMsgHandle sendMsgHandle;
|
||||
if ("5".equals(type)) {
|
||||
// Hiwork钉钉消息
|
||||
sendMsgHandle = new DingDingSendMsgHandle();
|
||||
} else if ("6".equals(type)) {
|
||||
// Hiwork系统消息
|
||||
sendMsgHandle = new SystemSendMsgHandle();
|
||||
} else if ("4".equals(type)) {
|
||||
// 普通系统消息
|
||||
sendMsgHandle = new SmsSendMsgHandle();
|
||||
if (!isSend) {
|
||||
sendMsgHandle.SendMsg(sendMessageDTO.getToUserId(), sysMessageTemplate.getTemplateName(), sysMessageTemplate.getTemplateContent());
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if (isSend) {
|
||||
sendMsgHandle.SendMsg(sendMessageDTO.getToUserId(), sysMessageTemplate.getTemplateName(), sysMessageTemplate.getTemplateContent());
|
||||
}
|
||||
});
|
||||
} catch (Exception e){
|
||||
log.error("发送消息异常",e);
|
||||
throw new JeroBootException("发送消息异常");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
-122
@@ -1,122 +0,0 @@
|
||||
package com.jero.modules.docking.hiwork.util;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.modules.docking.hiwork.entity.HiworkResult;
|
||||
import com.jero.modules.docking.hiwork.entity.HiworkTodo;
|
||||
import com.jero.modules.docking.hiwork.entity.HiworkDingDingMsg;
|
||||
import com.jero.modules.docking.hiwork.entity.HiworkSystemMsg;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 16:55
|
||||
* @Description: Hiwork集成
|
||||
*/
|
||||
@Component
|
||||
public class HiworkPostUtil {
|
||||
@Autowired
|
||||
private RestTemplate restTemplate;
|
||||
@Value("${hiwork.ip}")
|
||||
private String ip;
|
||||
@Value("${hiwork.todoUrl}")
|
||||
private String todoUrl;
|
||||
@Value("${hiwork.messageUrl}")
|
||||
private String messageUrl;
|
||||
|
||||
// 异构系统标识
|
||||
private static String sysCode;
|
||||
|
||||
@Value("${hiwork.sysCode}")
|
||||
public void setSysCode(String sysCode) {
|
||||
HiworkPostUtil.sysCode = sysCode;
|
||||
}
|
||||
|
||||
public static String getSysCode() {
|
||||
return sysCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 17:45
|
||||
* @Description: 远程调用Hiwork
|
||||
**/
|
||||
private void postHiwork(String jsonString, String url) {
|
||||
// 设置请求头
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
HttpEntity<String> requestEntity = new HttpEntity<>(jsonString, headers);
|
||||
|
||||
// 发送 POST 请求并获取响应
|
||||
ResponseEntity<HiworkResult> response = restTemplate.postForEntity(url, requestEntity, HiworkResult.class);
|
||||
|
||||
// 处理响应数据
|
||||
if (response.getStatusCode().is2xxSuccessful()) {
|
||||
HiworkResult hiworkResult = response.getBody();
|
||||
if (!hiworkResult.getSuccess()) {
|
||||
throw new JeroBootException("Hiwork:" + hiworkResult.getMsg());
|
||||
}
|
||||
} else {
|
||||
throw new JeroBootException("Hiwork: request failed with status code: " + response.getStatusCode());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 17:45
|
||||
* @Description: 统一待办集成远程调用
|
||||
**/
|
||||
public void postTodo(List<HiworkTodo> hiworkTodoList) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String jsonString;
|
||||
try {
|
||||
jsonString = objectMapper.writeValueAsString(hiworkTodoList);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new JeroBootException("JSON string format conversion error");
|
||||
}
|
||||
postHiwork(jsonString, ip + todoUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 17:45
|
||||
* @Description: 统一消息集成远程调用-钉钉消息
|
||||
**/
|
||||
public void postDingDingMsg(HiworkDingDingMsg hiworkDingDingMsg) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String jsonString;
|
||||
try {
|
||||
jsonString = objectMapper.writeValueAsString(hiworkDingDingMsg);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new JeroBootException("JSON string format conversion error");
|
||||
}
|
||||
postHiwork(jsonString, ip + messageUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author: liao
|
||||
* @Date: 2023/10/13 17:45
|
||||
* @Description: 统一消息集成远程调用-系统消息
|
||||
**/
|
||||
public void postSystemMsg(HiworkSystemMsg hiworkSystemMsg) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String jsonString;
|
||||
try {
|
||||
jsonString = objectMapper.writeValueAsString(hiworkSystemMsg);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new JeroBootException("JSON string format conversion error");
|
||||
}
|
||||
postHiwork(jsonString, ip + messageUrl);
|
||||
}
|
||||
}
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
package com.jero.modules.docking.iam.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Target({ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Inherited
|
||||
public @interface IamProperty {
|
||||
|
||||
// /**
|
||||
// * 字段属性名
|
||||
// * @return
|
||||
// */
|
||||
// String name() default "";
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// String type() default "";
|
||||
|
||||
/**
|
||||
* 定义对象的属性字段在创建时是否为必填字段
|
||||
* @return
|
||||
*/
|
||||
boolean required() default true;
|
||||
|
||||
/**
|
||||
* 定义对象的属性字段是否为多值
|
||||
* @return
|
||||
*/
|
||||
boolean multivalued() default false;
|
||||
|
||||
}
|
||||
-322
@@ -1,322 +0,0 @@
|
||||
package com.jero.modules.docking.iam.client;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.bamboocloud.codec.BamboocloudFacade;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.jero.common.util.DateUtils;
|
||||
import com.jero.common.util.UUIDGenerator;
|
||||
import com.jero.common.util.UUIDUtils;
|
||||
import com.jero.modules.docking.iam.dto.IamCommonAcceptDto;
|
||||
import com.jero.modules.docking.iam.dto.IamOrgAcceptDto;
|
||||
import com.jero.modules.docking.iam.dto.IamUserAcceptDto;
|
||||
import com.jero.modules.docking.iam.po.encrypt.AcceptEncryptPo;
|
||||
import com.jero.modules.docking.iam.po.MessageHeader;
|
||||
import com.jero.modules.docking.iam.po.encrypt.MessageEncryptTabels;
|
||||
import com.jero.modules.docking.iam.po.encrypt.MessageEncryptTabelsHeader;
|
||||
import com.jero.modules.docking.iam.po.encrypt.SendPoEncryptPo;
|
||||
import com.jero.modules.docking.utils.BamboocloudUtils;
|
||||
import com.jero.modules.docking.utils.DockingConstant;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 测试接口是否正确的客户端,mock IAM发送请求
|
||||
*/
|
||||
public class TestClient {
|
||||
|
||||
public static void main(String[] args) throws JsonProcessingException {
|
||||
TestClient testClient = new TestClient();
|
||||
// testClient.sendSchemaService(); // 字段映射接口测试
|
||||
// for (int i = 0; i < 1; i++) {
|
||||
// System.out.println(i);
|
||||
// testClient.sendUserCreate(i);
|
||||
// }
|
||||
// 创建用户接口测试
|
||||
// testClient.sendUserUpdate(); // 更新用户接口测试
|
||||
// testClient.sendOrgCreate(); // 组织创建接口测试
|
||||
// testClient.sendQueryAllUserIdsService(); // 查询所有用户ID接口测试
|
||||
// testClient.sendQueryAllOrgIdsService(); // 查询所有组织ID接口测试
|
||||
// testClient.sendQueryOrgByIdService(); // 查询指定id的组织数据测试
|
||||
// testClient.sendQueryUserByIdService(); // 查询指定id的用户数据测试
|
||||
testClient.decryptSting("8rAKWPUwkEZ3yYLy/1TuGGkIGCYtc+MD56pShLi97OmMttoFooo5GXZ/lY4NrQ5DiWmVUX23zqDwyQqufXLZNDU+KuJO/9UonpqUlZxM91w=");
|
||||
}
|
||||
|
||||
private void decryptSting(String encryptString) {
|
||||
String decrypt = BamboocloudUtils.getPlaintext(encryptString, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
System.out.println("解密后数据:" + decrypt);
|
||||
}
|
||||
|
||||
// 对数据解密
|
||||
private void decryptData(String encryptData) throws JsonProcessingException {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
SendPoEncryptPo sendPoEncryptPo = objectMapper.readValue(encryptData, SendPoEncryptPo.class);
|
||||
String decrypt = BamboocloudUtils.getPlaintext(sendPoEncryptPo.getReturns().getData(), DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
System.out.println("解密后数据:" + decrypt);
|
||||
}
|
||||
|
||||
/**
|
||||
* 封装统一发送的PO层
|
||||
* @param encryptData
|
||||
* @return
|
||||
*/
|
||||
private AcceptEncryptPo handlerPoPackage(String encryptData) {
|
||||
MessageHeader messageHeader = new MessageHeader();
|
||||
messageHeader.setInterfaceID("SRMSUSERCREATE");
|
||||
messageHeader.setUUID(UUIDGenerator.generate());
|
||||
messageHeader.setMessageId(UUIDGenerator.generate());
|
||||
messageHeader.setSender(DockingConstant.IAM_SYSTEM_NAME);
|
||||
messageHeader.setReceiver(DockingConstant.SYSTEM_NAME);
|
||||
|
||||
Date curDate = new Date();
|
||||
messageHeader.setSendDate(DateUtils.formatDate(curDate, "YYYYMMDD"));
|
||||
messageHeader.setSendTime(DateUtils.formatDate(curDate, "HHmmss"));
|
||||
|
||||
MessageEncryptTabelsHeader messageEncryptTabelsHeader = new MessageEncryptTabelsHeader();
|
||||
messageEncryptTabelsHeader.setData(encryptData);
|
||||
|
||||
MessageEncryptTabels messageEncryptTabels = new MessageEncryptTabels();
|
||||
messageEncryptTabels.setHeader(messageEncryptTabelsHeader);
|
||||
|
||||
AcceptEncryptPo acceptEncryptPo = new AcceptEncryptPo();
|
||||
acceptEncryptPo.setMessageHeader(messageHeader);
|
||||
acceptEncryptPo.setMessageEncryptTabels(messageEncryptTabels);
|
||||
|
||||
return acceptEncryptPo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schema映射获取
|
||||
*/
|
||||
private void sendSchemaService() throws JsonProcessingException {
|
||||
String url = "http://localhost:8184/laws-sinotruk/sync/iam/UserCreateService";
|
||||
|
||||
IamCommonAcceptDto iamCommonAcceptDto = new IamCommonAcceptDto();
|
||||
iamCommonAcceptDto.setBimRequestId(UUIDUtils.randomUUID20());
|
||||
iamCommonAcceptDto.setBimRemoteUser("srmsIam");
|
||||
iamCommonAcceptDto.setBimRemotePwd("srmsIam2023");
|
||||
|
||||
// 加密数据
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String sendData = objectMapper.writeValueAsString(iamCommonAcceptDto);
|
||||
String encryptData = BamboocloudFacade.encrypt(sendData, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
AcceptEncryptPo sendPoDataEntity = handlerPoPackage(encryptData);
|
||||
String sendPoDataJson = objectMapper.writeValueAsString(sendPoDataEntity);
|
||||
|
||||
String response = HttpUtil.post(url, sendPoDataJson);
|
||||
System.out.println("映射接口响应:" + response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户创建测试
|
||||
*/
|
||||
private void sendUserCreate(int i) throws JsonProcessingException {
|
||||
// 封装 IamUserAcceptDto 为用户数据层
|
||||
IamUserAcceptDto iamUserAcceptDto = new IamUserAcceptDto();
|
||||
iamUserAcceptDto.setSrmsCompanyCode("123");
|
||||
iamUserAcceptDto.setSrmsOrgCode("123/321");
|
||||
iamUserAcceptDto.setSrmsTypeId("001");
|
||||
iamUserAcceptDto.setSrmsUsername((108088 + i) +"");
|
||||
iamUserAcceptDto.setSrmsRealname("测试" + i);
|
||||
iamUserAcceptDto.setSrmsPassword("1qaz@WSX");
|
||||
iamUserAcceptDto.setSrmsSex("1"); // 男
|
||||
iamUserAcceptDto.setSrmsPost("主任");
|
||||
iamUserAcceptDto.setSrmsDutyLevelId("4"); // 主管级,srms不解析,直接存
|
||||
iamUserAcceptDto.setSrmsDirectLeadership("1706939999105900545"); // 直接上级,不清楚应该存什么,暂时存为id(fcc-test)
|
||||
iamUserAcceptDto.setSrmsPostStatus("1"); // 在岗,srms不解析,直接存
|
||||
iamUserAcceptDto.setSrmsStatus("1"); // 1在册,0离职
|
||||
iamUserAcceptDto.setSrmsOfficePhone("022-87648762");
|
||||
iamUserAcceptDto.setSrmsPhone("13811112232");
|
||||
iamUserAcceptDto.setSrmsEmail("test@sinotruk.com");
|
||||
iamUserAcceptDto.setSrmsCreateTime("2023-10-15 10:35:20");
|
||||
|
||||
iamUserAcceptDto.setBimRequestId(UUIDUtils.randomUUID20());
|
||||
iamUserAcceptDto.setBimRemoteUser("srmsIam");
|
||||
iamUserAcceptDto.setBimRemotePwd("srmsIam2023");
|
||||
|
||||
// 加密数据
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String sendData = objectMapper.writeValueAsString(iamUserAcceptDto);
|
||||
String encryptData = BamboocloudFacade.encrypt(sendData, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
// 封装 AcceptPoSystemPo 为PO层套壳
|
||||
AcceptEncryptPo sendPoDataEntity = handlerPoPackage(encryptData);
|
||||
String sendPoDataJson = objectMapper.writeValueAsString(sendPoDataEntity);
|
||||
|
||||
// 发送数据
|
||||
String url = "http://localhost:8184/laws-sinotruk/sync/iam/UserCreateService";
|
||||
// String url = "laws-test.sinotruk.com/laws-sinotruk/sync/iam/UserCreateService";
|
||||
String response = HttpUtil.post(url, sendPoDataJson);
|
||||
System.out.println("用户创建接口响应:" + response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户更新测试
|
||||
*/
|
||||
private void sendUserUpdate() throws JsonProcessingException {
|
||||
// 封装 IamUserAcceptDto 为用户数据层
|
||||
IamUserAcceptDto iamUserAcceptDto = new IamUserAcceptDto();
|
||||
iamUserAcceptDto.setBimUid("1709786346053017601"); // 数据库中取到的ID
|
||||
iamUserAcceptDto.setSrmsPost("科长");
|
||||
iamUserAcceptDto.setSrmsUpdateTime("2023-10-15 10:35:20"); // 测试不发送UpdateTime的情况
|
||||
|
||||
iamUserAcceptDto.setBimRequestId(UUIDUtils.randomUUID20());
|
||||
iamUserAcceptDto.setBimRemoteUser("srmsIam");
|
||||
iamUserAcceptDto.setBimRemotePwd("srmsIam2023");
|
||||
|
||||
// 加密数据
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String sendData = objectMapper.writeValueAsString(iamUserAcceptDto);
|
||||
String encryptData = BamboocloudFacade.encrypt(sendData, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
// 封装 AcceptPoSystemPo 为PO层套壳
|
||||
AcceptEncryptPo sendPoDataEntity = handlerPoPackage(encryptData);
|
||||
String sendPoDataJson = objectMapper.writeValueAsString(sendPoDataEntity);
|
||||
|
||||
// 发送数据
|
||||
String url = "http://localhost:8184/laws-sinotruk/sync/iam/UserUpdateService";
|
||||
String response = HttpUtil.post(url, sendPoDataJson);
|
||||
System.out.println("用户更新接口响应:" + response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户创建测试
|
||||
*/
|
||||
private void sendOrgCreate() throws JsonProcessingException {
|
||||
// 封装 IamUserAcceptDto 为用户数据层
|
||||
IamOrgAcceptDto iamOrgAcceptDto = new IamOrgAcceptDto();
|
||||
|
||||
iamOrgAcceptDto.setSrmsOrgCode("IA00102");
|
||||
iamOrgAcceptDto.setSrmsDepartName("测试IAM部门");
|
||||
iamOrgAcceptDto.setSrmsParentCode("");
|
||||
iamOrgAcceptDto.setSrmsCompany("测试公司");
|
||||
iamOrgAcceptDto.setSrmsStatus("1");
|
||||
iamOrgAcceptDto.setSrmsCreateTime("2023-10-12 10:35:20");
|
||||
iamOrgAcceptDto.setSrmsType("002");
|
||||
iamOrgAcceptDto.setSrmsOrgCategory("2");
|
||||
|
||||
iamOrgAcceptDto.setBimRequestId(UUIDUtils.randomUUID20());
|
||||
iamOrgAcceptDto.setBimRemoteUser("srmsIam");
|
||||
iamOrgAcceptDto.setBimRemotePwd("srmsIam2023");
|
||||
|
||||
// 加密数据
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String sendData = objectMapper.writeValueAsString(iamOrgAcceptDto);
|
||||
String encryptData = BamboocloudFacade.encrypt(sendData, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
// 封装 AcceptPoSystemPo 为PO层套壳
|
||||
AcceptEncryptPo sendPoDataEntity = handlerPoPackage(encryptData);
|
||||
String sendPoDataJson = objectMapper.writeValueAsString(sendPoDataEntity);
|
||||
|
||||
// 发送数据
|
||||
String url = "http://localhost:8184/laws-sinotruk/sync/iam/OrgCreateService";
|
||||
String response = HttpUtil.post(url, sendPoDataJson);
|
||||
System.out.println("组织创建接口响应:" + response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部用户id
|
||||
*/
|
||||
private void sendQueryAllUserIdsService() throws JsonProcessingException {
|
||||
String url = "http://localhost:8184/laws-sinotruk/sync/iam/QueryAllUserIdsService";
|
||||
|
||||
IamCommonAcceptDto iamCommonAcceptDto = new IamCommonAcceptDto();
|
||||
iamCommonAcceptDto.setBimRequestId(UUIDUtils.randomUUID20());
|
||||
iamCommonAcceptDto.setBimRemoteUser("srmsIam");
|
||||
iamCommonAcceptDto.setBimRemotePwd("srmsIam2023");
|
||||
|
||||
// 加密数据
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String sendData = objectMapper.writeValueAsString(iamCommonAcceptDto);
|
||||
String encryptData = BamboocloudFacade.encrypt(sendData, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
AcceptEncryptPo sendPoDataEntity = handlerPoPackage(encryptData);
|
||||
String sendPoDataJson = objectMapper.writeValueAsString(sendPoDataEntity);
|
||||
String response = HttpUtil.post(url, sendPoDataJson);
|
||||
System.out.println("查询全部用户id接口响应:" + response);
|
||||
|
||||
this.decryptData(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部组织id
|
||||
*/
|
||||
private void sendQueryAllOrgIdsService() throws JsonProcessingException {
|
||||
String url = "http://localhost:8184/laws-sinotruk/sync/iam/QueryAllOrgIdsService";
|
||||
|
||||
IamCommonAcceptDto iamCommonAcceptDto = new IamCommonAcceptDto();
|
||||
iamCommonAcceptDto.setBimRequestId(UUIDUtils.randomUUID20());
|
||||
iamCommonAcceptDto.setBimRemoteUser("srmsIam");
|
||||
iamCommonAcceptDto.setBimRemotePwd("srmsIam2023");
|
||||
|
||||
// 加密数据
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String sendData = objectMapper.writeValueAsString(iamCommonAcceptDto);
|
||||
String encryptData = BamboocloudFacade.encrypt(sendData, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
AcceptEncryptPo sendPoDataEntity = handlerPoPackage(encryptData);
|
||||
String sendPoDataJson = objectMapper.writeValueAsString(sendPoDataEntity);
|
||||
|
||||
String response = HttpUtil.post(url, sendPoDataJson);
|
||||
System.out.println("查询全部组织id接口响应:" + response);
|
||||
|
||||
this.decryptData(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户查询接口测试
|
||||
*/
|
||||
private void sendQueryUserByIdService() throws JsonProcessingException {
|
||||
// 封装 IamUserAcceptDto 为用户数据层
|
||||
IamUserAcceptDto iamUserAcceptDto = new IamUserAcceptDto();
|
||||
iamUserAcceptDto.setBimUid("1709786346053017601"); // 数据库中取到的ID
|
||||
iamUserAcceptDto.setBimRemoteUser("srmsIam");
|
||||
iamUserAcceptDto.setBimRemotePwd("srmsIam2023");
|
||||
|
||||
// 加密数据
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String sendData = objectMapper.writeValueAsString(iamUserAcceptDto);
|
||||
String encryptData = BamboocloudFacade.encrypt(sendData, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
// 封装 AcceptPoSystemPo 为PO层套壳
|
||||
AcceptEncryptPo sendPoDataEntity = handlerPoPackage(encryptData);
|
||||
String sendPoDataJson = objectMapper.writeValueAsString(sendPoDataEntity);
|
||||
|
||||
// 发送数据
|
||||
String url = "http://localhost:8184/laws-sinotruk/sync/iam/QueryUserByIdService";
|
||||
String response = HttpUtil.post(url, sendPoDataJson);
|
||||
System.out.println("用户查询接口响应:" + response);
|
||||
|
||||
this.decryptData(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 组织查询接口测试
|
||||
*/
|
||||
private void sendQueryOrgByIdService() throws JsonProcessingException {
|
||||
// 封装 IamUserAcceptDto 为用户数据层
|
||||
IamOrgAcceptDto iamOrgAcceptDto = new IamOrgAcceptDto();
|
||||
iamOrgAcceptDto.setBimOrgId("IA00102"); // 数据库中取到的ID
|
||||
iamOrgAcceptDto.setBimRemoteUser("srmsIam");
|
||||
iamOrgAcceptDto.setBimRemotePwd("srmsIam2023");
|
||||
|
||||
// 加密数据
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String sendData = objectMapper.writeValueAsString(iamOrgAcceptDto);
|
||||
String encryptData = BamboocloudFacade.encrypt(sendData, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
// 封装 AcceptPoSystemPo 为PO层套壳
|
||||
AcceptEncryptPo sendPoDataEntity = handlerPoPackage(encryptData);
|
||||
String sendPoDataJson = objectMapper.writeValueAsString(sendPoDataEntity);
|
||||
|
||||
// 发送数据
|
||||
String url = "http://localhost:8184/laws-sinotruk/sync/iam/QueryOrgByIdService";
|
||||
String response = HttpUtil.post(url, sendPoDataJson);
|
||||
System.out.println("组织查询接口响应:" + response);
|
||||
|
||||
this.decryptData(response);
|
||||
}
|
||||
|
||||
}
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
package com.jero.modules.docking.iam.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.modules.system.entity.Oauth;
|
||||
import com.jero.modules.system.service.ILoginService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @Author: yjz
|
||||
* @Date: 2023/10/17/10:09
|
||||
* @Description:
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/iam")
|
||||
@Slf4j
|
||||
public class IamLoginController {
|
||||
private final ILoginService loginService;
|
||||
|
||||
public IamLoginController(ILoginService loginService) {
|
||||
this.loginService = loginService;
|
||||
}
|
||||
|
||||
@ApiOperation("单点登录")
|
||||
@PostMapping("/loginByOauth2")
|
||||
public Result<JSONObject> loginByOauth2(@Validated @RequestBody Oauth oauth){
|
||||
return loginService.loginByOauth2(oauth);
|
||||
}
|
||||
}
|
||||
-598
@@ -1,598 +0,0 @@
|
||||
package com.jero.modules.docking.iam.controller;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.aliyun.oss.ServiceException;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.jero.common.constant.CacheConstant;
|
||||
import com.jero.modules.base.service.BaseCommonService;
|
||||
import com.jero.modules.docking.iam.dto.IamCommonAcceptDto;
|
||||
import com.jero.modules.docking.iam.dto.IamOrgAcceptDto;
|
||||
import com.jero.modules.docking.iam.dto.IamUserAcceptDto;
|
||||
import com.jero.modules.docking.iam.dto.bpmc.*;
|
||||
import com.jero.modules.docking.iam.dto.response.*;
|
||||
import com.jero.modules.docking.iam.exception.IamGlobalException;
|
||||
import com.jero.modules.docking.iam.po.MessageHeader;
|
||||
import com.jero.modules.docking.iam.po.decrypt.AcceptDecryptPo;
|
||||
import com.jero.modules.docking.iam.po.encrypt.AcceptEncryptPo;
|
||||
import com.jero.modules.docking.iam.po.encrypt.SendPoEncryptPo;
|
||||
import com.jero.modules.docking.iam.service.SyncIamService;
|
||||
import com.jero.modules.docking.utils.BamboocloudUtils;
|
||||
import com.jero.modules.docking.utils.DockingConstant;
|
||||
import com.jero.modules.docking.utils.SHA256Util;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* IAM同步的控制器,提供用户、组织、菜单和权限的同步
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sync/iam")
|
||||
@Slf4j
|
||||
public class SyncIamController {
|
||||
|
||||
@Value("${iam.bpmcAppkey}")
|
||||
private String bpmcAppkey;
|
||||
|
||||
@Resource
|
||||
private SyncIamService syncIamService;
|
||||
|
||||
public final String paramNotGetError = "参数传递错误,未收到参数";
|
||||
|
||||
@Resource
|
||||
private BaseCommonService baseCommonService;
|
||||
|
||||
@PostMapping({"/SchemaService"})
|
||||
public SendPoEncryptPo schemaService(@RequestBody AcceptEncryptPo iamCommon) throws JsonProcessingException {
|
||||
if (iamCommon == null
|
||||
|| iamCommon.getMessageEncryptTabels() == null
|
||||
|| iamCommon.getMessageEncryptTabels().getHeader() == null
|
||||
|| iamCommon.getMessageEncryptTabels().getHeader().getData() == null){
|
||||
throw new IamGlobalException(null, this.paramNotGetError);
|
||||
}
|
||||
|
||||
// 对核心数据解密
|
||||
String bodyParam = iamCommon.getMessageEncryptTabels().getHeader().getData();
|
||||
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
IamCommonAcceptDto commonAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamCommonAcceptDto.class);
|
||||
|
||||
// 校验身份认证,确保接口正确 必须调用!
|
||||
this.syncIamService.validateUserAndPwd(commonAcceptDto);
|
||||
|
||||
// 处理业务逻辑,封装字段
|
||||
IamSchemaResponse iamSchemaResponse = this.syncIamService.getSchemaInfo(commonAcceptDto);
|
||||
|
||||
// 处理统一响应PO层,并加密业务字段
|
||||
MessageHeader acceptMessageHeader = iamCommon.getMessageHeader();
|
||||
SendPoEncryptPo sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(acceptMessageHeader, iamSchemaResponse);
|
||||
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
@PostMapping({"/UserCreateService"})
|
||||
public SendPoEncryptPo userCreateService(@RequestBody AcceptEncryptPo iamUserInfo) throws JsonProcessingException {
|
||||
log.info("进入账号创建");
|
||||
IamUserAcceptDto userAcceptDto = null;
|
||||
IamUserCreateResponse iamUserCreateResponse = new IamUserCreateResponse();
|
||||
SendPoEncryptPo sendPoEncryptPo = new SendPoEncryptPo();
|
||||
try {
|
||||
if (iamUserInfo == null
|
||||
|| iamUserInfo.getMessageEncryptTabels() == null
|
||||
|| iamUserInfo.getMessageEncryptTabels().getHeader() == null
|
||||
|| iamUserInfo.getMessageEncryptTabels().getHeader().getData() == null){
|
||||
throw new IamGlobalException(null, "参数传递错误,未收到参数");
|
||||
}
|
||||
|
||||
// 对核心数据解密
|
||||
String bodyParam = iamUserInfo.getMessageEncryptTabels().getHeader().getData();
|
||||
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
userAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamUserAcceptDto.class);
|
||||
|
||||
// 校验身份认证,确保接口正确 必须调用!
|
||||
this.syncIamService.validateUserAndPwd(userAcceptDto);
|
||||
iamUserCreateResponse.setBimRequestId(userAcceptDto.getBimRequestId());
|
||||
// 处理业务逻辑,存储用户,返回用户id
|
||||
iamUserCreateResponse = this.syncIamService.userCreateService(userAcceptDto);
|
||||
} catch (ServiceException e) {
|
||||
iamUserCreateResponse.setResultCode(DockingConstant.IAM_ERROR_RESULT_CODE);
|
||||
String message = e.getErrorMessage();
|
||||
iamUserCreateResponse.setMessage(message);
|
||||
log.error(iamUserCreateResponse.getMessage());
|
||||
}catch (Exception e){
|
||||
iamUserCreateResponse.setResultCode(DockingConstant.IAM_ERROR_RESULT_CODE);
|
||||
iamUserCreateResponse.setMessage("操作失败" + e.getMessage());
|
||||
log.error(iamUserCreateResponse.getMessage());
|
||||
}
|
||||
// 处理统一响应PO层,并加密业务字段
|
||||
MessageHeader acceptMessageHeader = iamUserInfo.getMessageHeader();
|
||||
sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(acceptMessageHeader, iamUserCreateResponse);
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
@PostMapping({"/UserUpdateService"})
|
||||
public SendPoEncryptPo userUpdateService(@RequestBody AcceptEncryptPo iamUserInfo) throws JsonProcessingException {
|
||||
IamCommonResponseDto iamCommonResponseDto = new IamCommonResponseDto();
|
||||
try {
|
||||
if (iamUserInfo == null
|
||||
|| iamUserInfo.getMessageEncryptTabels() == null
|
||||
|| iamUserInfo.getMessageEncryptTabels().getHeader() == null
|
||||
|| iamUserInfo.getMessageEncryptTabels().getHeader().getData() == null){
|
||||
throw new IamGlobalException(null, "参数传递错误,未收到参数");
|
||||
}
|
||||
|
||||
// 对核心数据解密
|
||||
String bodyParam = iamUserInfo.getMessageEncryptTabels().getHeader().getData();
|
||||
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
IamUserAcceptDto userAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamUserAcceptDto.class);
|
||||
|
||||
// 校验身份认证,确保接口正确 必须调用!
|
||||
this.syncIamService.validateUserAndPwd(userAcceptDto);
|
||||
|
||||
// 处理业务逻辑,存储用户,返回用户id
|
||||
iamCommonResponseDto = this.syncIamService.userUpdateService(userAcceptDto);
|
||||
iamCommonResponseDto.setBimRequestId(userAcceptDto.getBimRequestId());
|
||||
}catch (IamGlobalException e){
|
||||
iamCommonResponseDto.setResultCode(DockingConstant.IAM_ERROR_RESULT_CODE);
|
||||
String message = e.getMessage();
|
||||
iamCommonResponseDto.setMessage(message);
|
||||
log.error(iamCommonResponseDto.getMessage());
|
||||
}catch (Exception e){
|
||||
iamCommonResponseDto.setResultCode(DockingConstant.IAM_ERROR_RESULT_CODE);
|
||||
iamCommonResponseDto.setMessage("操作失败" + e.getMessage());
|
||||
log.error(iamCommonResponseDto.getMessage());
|
||||
}
|
||||
// 处理统一响应PO层,并加密业务字段
|
||||
MessageHeader acceptMessageHeader = iamUserInfo.getMessageHeader();
|
||||
SendPoEncryptPo sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(acceptMessageHeader, iamCommonResponseDto);
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
@PostMapping({"/UserDeleteService"})
|
||||
public SendPoEncryptPo userDeleteService(@RequestBody AcceptEncryptPo iamUserInfo) throws JsonProcessingException {
|
||||
IamCommonResponseDto iamCommonResponseDto = new IamCommonResponseDto();
|
||||
try {
|
||||
if (iamUserInfo == null
|
||||
|| iamUserInfo.getMessageEncryptTabels() == null
|
||||
|| iamUserInfo.getMessageEncryptTabels().getHeader() == null
|
||||
|| iamUserInfo.getMessageEncryptTabels().getHeader().getData() == null){
|
||||
throw new IamGlobalException(null, "参数传递错误,未收到参数");
|
||||
}
|
||||
|
||||
// 对核心数据解密
|
||||
String bodyParam = iamUserInfo.getMessageEncryptTabels().getHeader().getData();
|
||||
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
IamUserAcceptDto userAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamUserAcceptDto.class);
|
||||
|
||||
// 校验身份认证,确保接口正确 必须调用!
|
||||
this.syncIamService.validateUserAndPwd(userAcceptDto);
|
||||
|
||||
// 处理业务逻辑,存储用户,返回用户id
|
||||
iamCommonResponseDto = this.syncIamService.userDeleteService(userAcceptDto);
|
||||
iamCommonResponseDto.setBimRequestId(userAcceptDto.getBimRequestId());
|
||||
}catch (IamGlobalException e){
|
||||
iamCommonResponseDto.setResultCode(DockingConstant.IAM_ERROR_RESULT_CODE);
|
||||
String message = e.getMessage();
|
||||
iamCommonResponseDto.setMessage(message);
|
||||
log.error(iamCommonResponseDto.getMessage());
|
||||
}catch (Exception e){
|
||||
iamCommonResponseDto.setResultCode(DockingConstant.IAM_ERROR_RESULT_CODE);
|
||||
iamCommonResponseDto.setMessage("操作失败" + e.getMessage());
|
||||
log.error(iamCommonResponseDto.getMessage());
|
||||
}
|
||||
// 处理统一响应PO层,并加密业务字段
|
||||
MessageHeader acceptMessageHeader = iamUserInfo.getMessageHeader();
|
||||
SendPoEncryptPo sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(acceptMessageHeader, iamCommonResponseDto);
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组织创建和更新移除缓存
|
||||
* @param iamOrgInfo
|
||||
* @return
|
||||
* @throws JsonProcessingException
|
||||
*/
|
||||
@PostMapping({"/OrgCreateService"})
|
||||
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
|
||||
public SendPoEncryptPo orgCreateService(@RequestBody AcceptEncryptPo iamOrgInfo) throws JsonProcessingException {
|
||||
IamOrgAcceptDto orgAcceptDto = null;
|
||||
try {
|
||||
if (iamOrgInfo == null
|
||||
|| iamOrgInfo.getMessageEncryptTabels() == null
|
||||
|| iamOrgInfo.getMessageEncryptTabels().getHeader() == null
|
||||
|| iamOrgInfo.getMessageEncryptTabels().getHeader().getData() == null){
|
||||
throw new IamGlobalException(null, "参数传递错误,未收到参数");
|
||||
}
|
||||
|
||||
// 对核心数据解密
|
||||
String bodyParam = iamOrgInfo.getMessageEncryptTabels().getHeader().getData();
|
||||
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
orgAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamOrgAcceptDto.class);
|
||||
|
||||
// 校验身份认证,确保接口正确 必须调用!
|
||||
this.syncIamService.validateUserAndPwd(orgAcceptDto);
|
||||
|
||||
// 处理业务逻辑,存储组织,返回组织id
|
||||
IamOrgCreateResponse iamOrgCreateResponse = this.syncIamService.orgCreateService(orgAcceptDto);
|
||||
|
||||
// 处理统一响应PO层,并加密业务字段
|
||||
MessageHeader acceptMessageHeader = iamOrgInfo.getMessageHeader();
|
||||
SendPoEncryptPo sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(acceptMessageHeader, iamOrgCreateResponse);
|
||||
return sendPoEncryptPo;
|
||||
} catch (DuplicateKeyException duplicateKeyException) {
|
||||
log.error("数据库值重复:{}", duplicateKeyException.getMessage());
|
||||
if (orgAcceptDto != null) {
|
||||
throw new IamGlobalException(orgAcceptDto.getBimRequestId(), "数据库值重复,请检查组织编号【" + orgAcceptDto.getSrmsOrgCode() + "】是否异常");
|
||||
} else {
|
||||
throw new IamGlobalException(null, "未知异常,请联系管理员");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 组织创建和更新移除缓存
|
||||
* @param iamOrgInfo
|
||||
* @return
|
||||
* @throws JsonProcessingException
|
||||
*/
|
||||
@PostMapping({"/OrgUpdateService"})
|
||||
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
|
||||
public SendPoEncryptPo orgUpdateService(@RequestBody AcceptEncryptPo iamOrgInfo) throws JsonProcessingException {
|
||||
if (iamOrgInfo == null
|
||||
|| iamOrgInfo.getMessageEncryptTabels() == null
|
||||
|| iamOrgInfo.getMessageEncryptTabels().getHeader() == null
|
||||
|| iamOrgInfo.getMessageEncryptTabels().getHeader().getData() == null){
|
||||
throw new IamGlobalException(null, "参数传递错误,未收到参数");
|
||||
}
|
||||
|
||||
// 对核心数据解密
|
||||
String bodyParam = iamOrgInfo.getMessageEncryptTabels().getHeader().getData();
|
||||
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
IamOrgAcceptDto orgAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamOrgAcceptDto.class);
|
||||
|
||||
// 校验身份认证,确保接口正确 必须调用!
|
||||
this.syncIamService.validateUserAndPwd(orgAcceptDto);
|
||||
|
||||
// 处理业务逻辑,更新组织
|
||||
IamCommonResponseDto iamCommonResponseDto = this.syncIamService.orgUpdateService(orgAcceptDto);
|
||||
|
||||
// 处理统一响应PO层,并加密业务字段
|
||||
MessageHeader acceptMessageHeader = iamOrgInfo.getMessageHeader();
|
||||
SendPoEncryptPo sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(acceptMessageHeader, iamCommonResponseDto);
|
||||
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
@PostMapping({"/OrgDeleteService"})
|
||||
public SendPoEncryptPo orgDeleteService(@RequestBody AcceptEncryptPo iamOrgInfo) throws JsonProcessingException {
|
||||
if (iamOrgInfo == null
|
||||
|| iamOrgInfo.getMessageEncryptTabels() == null
|
||||
|| iamOrgInfo.getMessageEncryptTabels().getHeader() == null
|
||||
|| iamOrgInfo.getMessageEncryptTabels().getHeader().getData() == null){
|
||||
throw new IamGlobalException(null, "参数传递错误,未收到参数");
|
||||
}
|
||||
|
||||
// 对核心数据解密
|
||||
String bodyParam = iamOrgInfo.getMessageEncryptTabels().getHeader().getData();
|
||||
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
IamOrgAcceptDto orgAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamOrgAcceptDto.class);
|
||||
|
||||
// 校验身份认证,确保接口正确 必须调用!
|
||||
this.syncIamService.validateUserAndPwd(orgAcceptDto);
|
||||
|
||||
// 处理业务逻辑,更新组织
|
||||
IamCommonResponseDto iamCommonResponseDto = this.syncIamService.orgDeleteService(orgAcceptDto);
|
||||
|
||||
// 处理统一响应PO层,并加密业务字段
|
||||
MessageHeader acceptMessageHeader = iamOrgInfo.getMessageHeader();
|
||||
SendPoEncryptPo sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(acceptMessageHeader, iamCommonResponseDto);
|
||||
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对接统一权限服务平台。
|
||||
* 该接口包含角色创建、菜单创建、角色菜单关联、用户角色关联等4个接口
|
||||
* 通过type字段来区分
|
||||
*/
|
||||
@PostMapping({"/bpmcCreate"})
|
||||
public SendPoEncryptPo bpmcCreate(@RequestBody AcceptDecryptPo acceptDecryptPo) throws JsonProcessingException {
|
||||
if (acceptDecryptPo == null
|
||||
|| acceptDecryptPo.getMessageDecryptTabels() == null
|
||||
|| acceptDecryptPo.getMessageDecryptTabels().getHeader() == null){
|
||||
throw new IamGlobalException(null, "参数传递错误,未收到参数");
|
||||
}
|
||||
|
||||
log.info("统一权限服务平台请求数据:{}", acceptDecryptPo.toString());
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
BpmcAcceptDto bpmcAcceptDto = objectMapper.readValue(acceptDecryptPo.getMessageDecryptTabels().getHeader().getData(), BpmcAcceptDto.class);
|
||||
|
||||
MessageHeader messageHeader = acceptDecryptPo.getMessageHeader();
|
||||
BpmcResponseDto bpmcResponseDto = BpmcResponseDto.success();
|
||||
SendPoEncryptPo sendPoEncryptPo = new SendPoEncryptPo();
|
||||
|
||||
if (CharSequenceUtil.isEmpty(bpmcAcceptDto.getType())){
|
||||
bpmcResponseDto.setReturnCode(DockingConstant.IAM_ERROR_RESULT_CODE);
|
||||
bpmcResponseDto.setMessage("接口类型(type)未传参,请检查");
|
||||
log.error(bpmcResponseDto.getMessage());
|
||||
sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(messageHeader, bpmcResponseDto);
|
||||
sendPoEncryptPo.getReturns().setData(JSON.toJSONString(bpmcResponseDto));
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
if (CharSequenceUtil.isEmpty(bpmcAcceptDto.getEntity())){
|
||||
bpmcResponseDto.setReturnCode(DockingConstant.IAM_ERROR_RESULT_CODE);
|
||||
bpmcResponseDto.setMessage("数据实体(entity)未传参,请检查");
|
||||
log.error(bpmcResponseDto.getMessage());
|
||||
sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(messageHeader, bpmcResponseDto);
|
||||
sendPoEncryptPo.getReturns().setData(JSON.toJSONString(bpmcResponseDto));
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
if (CharSequenceUtil.isEmpty(bpmcAcceptDto.getAction())){
|
||||
bpmcResponseDto.setReturnCode(DockingConstant.IAM_ERROR_RESULT_CODE);
|
||||
bpmcResponseDto.setMessage("操作方式(action)未传参,请检查");
|
||||
log.error(bpmcResponseDto.getMessage());
|
||||
sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(messageHeader, bpmcResponseDto);
|
||||
sendPoEncryptPo.getReturns().setData(JSON.toJSONString(bpmcResponseDto));
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
if (CharSequenceUtil.isEmpty(bpmcAcceptDto.getSignature())){
|
||||
bpmcResponseDto.setReturnCode(DockingConstant.IAM_ERROR_RESULT_CODE);
|
||||
bpmcResponseDto.setMessage("签名(signature)未传参,请检查");
|
||||
log.error(bpmcResponseDto.getMessage());
|
||||
sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(messageHeader, bpmcResponseDto);
|
||||
sendPoEncryptPo.getReturns().setData(JSON.toJSONString(bpmcResponseDto));
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
// 验证签名
|
||||
String validateSign = SHA256Util.getSHA256StrJava(bpmcAcceptDto.getEntity() + bpmcAppkey + bpmcAcceptDto.getTimestamp());
|
||||
if (!bpmcAcceptDto.getSignature().equals(validateSign)){
|
||||
bpmcResponseDto.setReturnCode(DockingConstant.IAM_ERROR_RESULT_CODE);
|
||||
bpmcResponseDto.setMessage("签名校验不通过,请检查");
|
||||
log.error(bpmcResponseDto.getMessage());
|
||||
sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(messageHeader, bpmcResponseDto);
|
||||
sendPoEncryptPo.getReturns().setData(JSON.toJSONString(bpmcResponseDto));
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
try {
|
||||
switch (bpmcAcceptDto.getType()){
|
||||
// 角色
|
||||
case DockingConstant.BPMC_TYPE_ROLE:
|
||||
bpmcResponseDto = bpmcTypeRole(objectMapper, bpmcAcceptDto, bpmcResponseDto);
|
||||
break;
|
||||
|
||||
// 菜单
|
||||
case DockingConstant.BPMC_TYPE_RESOURCE:
|
||||
bpmcResponseDto = bpmcTypeResource(objectMapper, bpmcAcceptDto, bpmcResponseDto);
|
||||
break;
|
||||
|
||||
// 用户角色关联
|
||||
case DockingConstant.BPMC_TYPE_USER_ROLE:
|
||||
bpmcResponseDto = bpmcTypeUserRole(objectMapper, bpmcAcceptDto, bpmcResponseDto);
|
||||
break;
|
||||
|
||||
// 角色菜单关联
|
||||
case DockingConstant.BPMC_TYPE_ROLE_RESOURCE:
|
||||
bpmcResponseDto = bpmcTypeRoleResource(objectMapper, bpmcAcceptDto, bpmcResponseDto);
|
||||
break;
|
||||
|
||||
default:
|
||||
bpmcResponseDto = BpmcResponseDto.error("接口类型(type)未找到,请检查");
|
||||
break;
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
bpmcResponseDto = BpmcResponseDto.error(e.getMessage());
|
||||
}
|
||||
log.info(bpmcResponseDto.getMessage());
|
||||
sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(messageHeader, bpmcResponseDto);
|
||||
sendPoEncryptPo.getReturns().setData(JSON.toJSONString(bpmcResponseDto));
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
private BpmcResponseDto bpmcTypeRoleResource(ObjectMapper objectMapper, BpmcAcceptDto bpmcAcceptDto, BpmcResponseDto bpmcResponseDto) throws JsonProcessingException {
|
||||
List<RoleResourceDto> roleResourceDtoList = objectMapper.readValue(bpmcAcceptDto.getEntity(), new TypeReference<List<RoleResourceDto>>() {});
|
||||
// 根据新增/删除调用不同的业务处理代码
|
||||
if (bpmcAcceptDto.getAction().equals(DockingConstant.BPMC_ACTION_ADD)){
|
||||
bpmcResponseDto = this.syncIamService.roleResourceCreateService(roleResourceDtoList);
|
||||
} else if (bpmcAcceptDto.getAction().equals(DockingConstant.BPMC_ACTION_DELETE)) {
|
||||
bpmcResponseDto = this.syncIamService.roleResourceDeleteService(roleResourceDtoList);
|
||||
}
|
||||
return bpmcResponseDto;
|
||||
}
|
||||
|
||||
private BpmcResponseDto bpmcTypeUserRole(ObjectMapper objectMapper, BpmcAcceptDto bpmcAcceptDto, BpmcResponseDto bpmcResponseDto) throws JsonProcessingException {
|
||||
List<UserRoleDto> userRoleDtoList = objectMapper.readValue(bpmcAcceptDto.getEntity(), new TypeReference<List<UserRoleDto>>() {});
|
||||
// 根据新增/删除调用不同的业务处理代码
|
||||
if (bpmcAcceptDto.getAction().equals(DockingConstant.BPMC_ACTION_ADD)){
|
||||
bpmcResponseDto = this.syncIamService.userRoleCreateService(userRoleDtoList);
|
||||
} else if (bpmcAcceptDto.getAction().equals(DockingConstant.BPMC_ACTION_DELETE)) {
|
||||
bpmcResponseDto = this.syncIamService.userRoleDeleteService(userRoleDtoList);
|
||||
}
|
||||
return bpmcResponseDto;
|
||||
}
|
||||
|
||||
private BpmcResponseDto bpmcTypeResource(ObjectMapper objectMapper, BpmcAcceptDto bpmcAcceptDto, BpmcResponseDto bpmcResponseDto) throws JsonProcessingException {
|
||||
ResourceDto resourceDto = objectMapper.readValue(bpmcAcceptDto.getEntity(), ResourceDto.class);
|
||||
// 根据新增/编辑/删除调用不同的业务处理代码
|
||||
if (bpmcAcceptDto.getAction().equals(DockingConstant.BPMC_ACTION_ADD)){
|
||||
bpmcResponseDto = this.syncIamService.resourceCreateService(resourceDto);
|
||||
} else if (bpmcAcceptDto.getAction().equals(DockingConstant.BPMC_ACTION_UPDATE)) {
|
||||
bpmcResponseDto = this.syncIamService.resourceUpdateService(resourceDto);
|
||||
} else if (bpmcAcceptDto.getAction().equals(DockingConstant.BPMC_ACTION_DELETE)) {
|
||||
bpmcResponseDto = this.syncIamService.resourceDeleteService(resourceDto);
|
||||
}
|
||||
return bpmcResponseDto;
|
||||
}
|
||||
|
||||
private BpmcResponseDto bpmcTypeRole(ObjectMapper objectMapper, BpmcAcceptDto bpmcAcceptDto, BpmcResponseDto bpmcResponseDto) throws JsonProcessingException {
|
||||
RoleDto roleDto = objectMapper.readValue(bpmcAcceptDto.getEntity(), RoleDto.class);
|
||||
// 根据新增/编辑/删除调用不同的业务处理代码
|
||||
if (bpmcAcceptDto.getAction().equals(DockingConstant.BPMC_ACTION_ADD)){
|
||||
bpmcResponseDto = this.syncIamService.roleCreateService(roleDto);
|
||||
} else if (bpmcAcceptDto.getAction().equals(DockingConstant.BPMC_ACTION_UPDATE)) {
|
||||
bpmcResponseDto = this.syncIamService.roleUpdateService(roleDto);
|
||||
} else if (bpmcAcceptDto.getAction().equals(DockingConstant.BPMC_ACTION_DELETE)) {
|
||||
bpmcResponseDto = this.syncIamService.roleDeleteService(roleDto);
|
||||
}
|
||||
return bpmcResponseDto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部用户id
|
||||
* @param iamCommon
|
||||
* @return
|
||||
* @throws JsonProcessingException
|
||||
*/
|
||||
@PostMapping({"/QueryAllUserIdsService"})
|
||||
public SendPoEncryptPo QueryAllUserIdsService(@RequestBody AcceptEncryptPo iamCommon) throws JsonProcessingException {
|
||||
if (iamCommon == null
|
||||
|| iamCommon.getMessageEncryptTabels() == null
|
||||
|| iamCommon.getMessageEncryptTabels().getHeader() == null
|
||||
|| iamCommon.getMessageEncryptTabels().getHeader().getData() == null){
|
||||
throw new IamGlobalException(null, this.paramNotGetError);
|
||||
}
|
||||
|
||||
// 对核心数据解密
|
||||
String bodyParam = iamCommon.getMessageEncryptTabels().getHeader().getData();
|
||||
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
IamCommonAcceptDto commonAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamCommonAcceptDto.class);
|
||||
|
||||
// 校验身份认证,确保接口正确 必须调用!
|
||||
this.syncIamService.validateUserAndPwd(commonAcceptDto);
|
||||
|
||||
// 处理业务逻辑,封装字段
|
||||
IamUserIdListResponse userIdListResponse = this.syncIamService.getAllUserIds(commonAcceptDto);
|
||||
|
||||
// 处理统一响应PO层,并加密业务字段
|
||||
MessageHeader acceptMessageHeader = iamCommon.getMessageHeader();
|
||||
SendPoEncryptPo sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(acceptMessageHeader, userIdListResponse);
|
||||
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部组织id
|
||||
* @param iamCommon
|
||||
* @return
|
||||
* @throws JsonProcessingException
|
||||
*/
|
||||
@PostMapping({"/QueryAllOrgIdsService"})
|
||||
public SendPoEncryptPo QueryAllOrgIdsService(@RequestBody AcceptEncryptPo iamCommon) throws JsonProcessingException {
|
||||
if (iamCommon == null
|
||||
|| iamCommon.getMessageEncryptTabels() == null
|
||||
|| iamCommon.getMessageEncryptTabels().getHeader() == null
|
||||
|| iamCommon.getMessageEncryptTabels().getHeader().getData() == null){
|
||||
throw new IamGlobalException(null, this.paramNotGetError);
|
||||
}
|
||||
|
||||
// 对核心数据解密
|
||||
String bodyParam = iamCommon.getMessageEncryptTabels().getHeader().getData();
|
||||
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
IamCommonAcceptDto commonAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamCommonAcceptDto.class);
|
||||
|
||||
// 校验身份认证,确保接口正确 必须调用!
|
||||
this.syncIamService.validateUserAndPwd(commonAcceptDto);
|
||||
|
||||
// 处理业务逻辑,封装字段
|
||||
IamOrgIdListResponse orgIdListResponse = this.syncIamService.getAllOrgIds(commonAcceptDto);
|
||||
|
||||
// 处理统一响应PO层,并加密业务字段
|
||||
MessageHeader acceptMessageHeader = iamCommon.getMessageHeader();
|
||||
SendPoEncryptPo sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(acceptMessageHeader, orgIdListResponse);
|
||||
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
@PostMapping({"/QueryUserByIdService"})
|
||||
public SendPoEncryptPo QueryUserByIdService(@RequestBody AcceptEncryptPo iamUserInfo) throws JsonProcessingException {
|
||||
if (iamUserInfo == null
|
||||
|| iamUserInfo.getMessageEncryptTabels() == null
|
||||
|| iamUserInfo.getMessageEncryptTabels().getHeader() == null
|
||||
|| iamUserInfo.getMessageEncryptTabels().getHeader().getData() == null){
|
||||
throw new IamGlobalException(null, "参数传递错误,未收到参数");
|
||||
}
|
||||
|
||||
// 对核心数据解密
|
||||
String bodyParam = iamUserInfo.getMessageEncryptTabels().getHeader().getData();
|
||||
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
IamUserAcceptDto userAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamUserAcceptDto.class);
|
||||
|
||||
// 校验身份认证,确保接口正确 必须调用!
|
||||
this.syncIamService.validateUserAndPwd(userAcceptDto);
|
||||
|
||||
// 处理业务逻辑,存储用户,返回用户id
|
||||
IamUserInfoResponse iamUserInfoResponse = this.syncIamService.getUserInfoById(userAcceptDto);
|
||||
|
||||
// 处理统一响应PO层,并加密业务字段
|
||||
MessageHeader acceptMessageHeader = iamUserInfo.getMessageHeader();
|
||||
SendPoEncryptPo sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(acceptMessageHeader, iamUserInfoResponse);
|
||||
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
@PostMapping({"/QueryOrgByIdService"})
|
||||
public SendPoEncryptPo QueryOrgByIdService(@RequestBody AcceptEncryptPo iamUserInfo) throws JsonProcessingException {
|
||||
if (iamUserInfo == null
|
||||
|| iamUserInfo.getMessageEncryptTabels() == null
|
||||
|| iamUserInfo.getMessageEncryptTabels().getHeader() == null
|
||||
|| iamUserInfo.getMessageEncryptTabels().getHeader().getData() == null){
|
||||
throw new IamGlobalException(null, "参数传递错误,未收到参数");
|
||||
}
|
||||
|
||||
// 对核心数据解密
|
||||
String bodyParam = iamUserInfo.getMessageEncryptTabels().getHeader().getData();
|
||||
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
IamOrgAcceptDto orgAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamOrgAcceptDto.class);
|
||||
|
||||
// 校验身份认证,确保接口正确 必须调用!
|
||||
this.syncIamService.validateUserAndPwd(orgAcceptDto);
|
||||
|
||||
// 处理业务逻辑,存储用户,返回用户id
|
||||
IamOrgInfoResponse iamOrgInfoResponse = this.syncIamService.getOrgInfoById(orgAcceptDto);
|
||||
|
||||
// 处理统一响应PO层,并加密业务字段
|
||||
MessageHeader acceptMessageHeader = iamUserInfo.getMessageHeader();
|
||||
SendPoEncryptPo sendPoEncryptPo = this.syncIamService.handlerGloablEncryptResponse(acceptMessageHeader, iamOrgInfoResponse);
|
||||
|
||||
return sendPoEncryptPo;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
package com.jero.modules.docking.iam.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* IAM的通用Dto,存放IAM接口的非业务通用属性。接口呗请求时会带着该参数
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class IamCommonAcceptDto {
|
||||
|
||||
/**
|
||||
* BIM每次调用生成的随机ID,应用系统每次响应返回此ID
|
||||
*/
|
||||
private String bimRequestId;
|
||||
|
||||
/**
|
||||
*BIM调用三方应用接口的授权账号,由应用分配给BIM系统
|
||||
*/
|
||||
private String bimRemoteUser ;
|
||||
|
||||
|
||||
/**
|
||||
* BIM调用三方应用接口的密码,由应用分配给BIM系统
|
||||
*/
|
||||
private String bimRemotePwd;
|
||||
|
||||
}
|
||||
-91
@@ -1,91 +0,0 @@
|
||||
package com.jero.modules.docking.iam.dto;
|
||||
|
||||
import com.jero.modules.docking.iam.annotation.IamProperty;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* IAM的组织实体,接收IAM传递的组织数据
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
public class IamOrgAcceptDto extends IamCommonAcceptDto {
|
||||
|
||||
/**
|
||||
* 组织的id,在删除或编辑的接口会传递
|
||||
*/
|
||||
private String bimOrgId;
|
||||
|
||||
/**
|
||||
* 机构编码.全集团唯一,不可重复,撤销后不可重新启用
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsOrgCode;
|
||||
|
||||
/**
|
||||
* 组织名称
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsDepartName;
|
||||
|
||||
/**
|
||||
* 父级机构编码.当前组织所属的父节点code
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsParentCode;
|
||||
|
||||
/**
|
||||
* 所属单位,10位HR机构编号
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsCompany;
|
||||
|
||||
/**
|
||||
* 机构状态
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsStatus;
|
||||
|
||||
/**
|
||||
* 机构类型。001内部机构 002 外部机构 003 虚拟机构
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsType;
|
||||
|
||||
/**
|
||||
* 组织类型。1.单位 2.部门。单位下可以有单位,但是部门下不能有单位
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsOrgCategory;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsCreateTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsUpdateTime;
|
||||
|
||||
/**
|
||||
* 部门负责人
|
||||
*/
|
||||
@IamProperty(required = false, multivalued = false)
|
||||
private String srmsHeadOfDepartment;
|
||||
|
||||
/**
|
||||
* 分管领导
|
||||
*/
|
||||
@IamProperty(required = false, multivalued = false)
|
||||
private String srmsLeadersInCharge;
|
||||
|
||||
/**
|
||||
* 副职领导
|
||||
*/
|
||||
@IamProperty(required = false, multivalued = false)
|
||||
private String srmsDeputyLeader;
|
||||
|
||||
}
|
||||
-121
@@ -1,121 +0,0 @@
|
||||
package com.jero.modules.docking.iam.dto;
|
||||
|
||||
import com.jero.modules.docking.iam.annotation.IamProperty;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* IAM的用户实体,接收IAM传递的用户数据
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
public class IamUserAcceptDto extends IamCommonAcceptDto {
|
||||
|
||||
/**
|
||||
* 用户的id,在删除或编辑的接口会传递
|
||||
*/
|
||||
private String bimUid;
|
||||
|
||||
/**
|
||||
* 单位编码
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsCompanyCode;
|
||||
|
||||
/**
|
||||
* 部门编码,用于做人员和组织的关联
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsOrgCode;
|
||||
|
||||
/**
|
||||
* 人员类型
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsTypeId;
|
||||
|
||||
/**
|
||||
* 工号
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsUsername;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsRealname;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@IamProperty(required = false, multivalued = false)
|
||||
private String srmsPassword;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsSex;
|
||||
|
||||
/**
|
||||
* 岗位
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsPost;
|
||||
|
||||
/**
|
||||
* 职务级别
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsDutyLevelId;
|
||||
|
||||
/**
|
||||
* 直接上级
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsDirectLeadership;
|
||||
|
||||
/**
|
||||
* 岗位状态
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsPostStatus;
|
||||
|
||||
/**
|
||||
* 是否在册
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsStatus;
|
||||
|
||||
/**
|
||||
* 办公电话
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsOfficePhone;
|
||||
|
||||
/**
|
||||
* 移动电话
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsPhone;
|
||||
|
||||
/**
|
||||
* 电子邮件
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsEmail;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsCreateTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@IamProperty(required = true, multivalued = false)
|
||||
private String srmsUpdateTime;
|
||||
|
||||
}
|
||||
-50
@@ -1,50 +0,0 @@
|
||||
package com.jero.modules.docking.iam.dto.bpmc;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* 和竹云统一权限服务平台对接的实体
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
public class BpmcAcceptDto {
|
||||
|
||||
/**
|
||||
* 角色:D_AR (本系统对接)
|
||||
* 功能权限:D_AM (本系统对接)
|
||||
* 账号与应用角色关系: R_USER_AR (本系统对接)
|
||||
* 应用角色与应用功能权限关系:R_AR_AM (本系统对接)
|
||||
* 账号与功能权限关系:R_USER_AM
|
||||
* 群组与应用角色关系:R_ACCSET_AR
|
||||
* 群组与功能权限关系:R_ACCSET_AM
|
||||
* 机构/岗位与应用角色关系:R_USERSET_AR
|
||||
* 机构/岗位与功能权限关系:R_USERSET_AM
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 后续基础数据接口、权限关系接口章节中对应操作的entity JSON格式数据字符串
|
||||
*/
|
||||
private String entity;
|
||||
|
||||
/**
|
||||
* 操作方式
|
||||
* 基础数据接口:(add:新增;delete:删除;update:更新)
|
||||
* 关系数据接口:
|
||||
* (add:新增;delete:删除;)
|
||||
*/
|
||||
private String action;
|
||||
|
||||
/**
|
||||
* 请求签名,计算方式
|
||||
* SHA256 (entity+appKey+timestamp)
|
||||
*/
|
||||
private String signature;
|
||||
|
||||
/**
|
||||
* 时间戳
|
||||
*/
|
||||
private long timestamp;
|
||||
|
||||
}
|
||||
-112
@@ -1,112 +0,0 @@
|
||||
package com.jero.modules.docking.iam.dto.bpmc;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 统一权限服务平台的菜单实体
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ResourceDto {
|
||||
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 功能编码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 父级id
|
||||
*/
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 功能名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 对应前端组件
|
||||
*/
|
||||
private String component;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 一级菜单跳转地址
|
||||
*/
|
||||
private String redirect;
|
||||
|
||||
/**
|
||||
* 路径
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 类型(0:一级菜单; 1:子菜单:2:按钮权限)
|
||||
*/
|
||||
private int menu_type;
|
||||
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 菜单英文
|
||||
*/
|
||||
private String menu_en;
|
||||
|
||||
/**
|
||||
* 菜单是否为路径菜单(默认值为1)
|
||||
*/
|
||||
private Integer is_route;
|
||||
|
||||
/**
|
||||
* 打开外部链接菜单的方式(默认值为0)
|
||||
*/
|
||||
private Integer internal_or_external;
|
||||
|
||||
/**
|
||||
* 菜单是否隐藏(默认值为0)
|
||||
*/
|
||||
private Integer hidden;
|
||||
|
||||
/**
|
||||
* 菜单是否需要缓存(默认值为0)
|
||||
*/
|
||||
private Integer keep_alive;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date modifyTime;
|
||||
|
||||
/**
|
||||
* 最近修改人
|
||||
*/
|
||||
private String modifyBy;
|
||||
|
||||
/**
|
||||
* 应用id
|
||||
*/
|
||||
private String appId;
|
||||
|
||||
}
|
||||
-62
@@ -1,62 +0,0 @@
|
||||
package com.jero.modules.docking.iam.dto.bpmc;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 统一权限服务平台的角色实体
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class RoleDto {
|
||||
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
private int sort;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date modifyTime;
|
||||
|
||||
/**
|
||||
* 最近修改人
|
||||
*/
|
||||
private String modifyBy;
|
||||
|
||||
/**
|
||||
* 应用id
|
||||
*/
|
||||
private String appId;
|
||||
|
||||
}
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
package com.jero.modules.docking.iam.dto.bpmc;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 统一权限服务平台的 角色-菜单关联 实体
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class RoleResourceDto {
|
||||
|
||||
/**
|
||||
* 角色id
|
||||
*/
|
||||
private String arId;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
private String arName;
|
||||
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
private String arCode;
|
||||
|
||||
/**
|
||||
* 菜单id
|
||||
*/
|
||||
private String amId;
|
||||
|
||||
/**
|
||||
* 菜单名称
|
||||
*/
|
||||
private String amName;
|
||||
|
||||
/**
|
||||
* 菜单编码
|
||||
*/
|
||||
private String amCode;
|
||||
|
||||
/**
|
||||
* 菜单类型(0 菜单 、1行为)
|
||||
*/
|
||||
private int amType;
|
||||
|
||||
/**
|
||||
* 菜单code绝对路径
|
||||
*/
|
||||
private String codePath;
|
||||
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
package com.jero.modules.docking.iam.dto.bpmc;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 统一权限服务平台的 用户-角色关联 实体
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class UserRoleDto {
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 账号名
|
||||
*/
|
||||
private String accountCode;
|
||||
|
||||
/**
|
||||
* 账号id
|
||||
*/
|
||||
private String accountId;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String fullName;
|
||||
|
||||
/**
|
||||
* 角色id
|
||||
*/
|
||||
private String arId;
|
||||
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
private String arCode;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
private String arName;
|
||||
|
||||
}
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
package com.jero.modules.docking.iam.dto.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BpmcResponseDto {
|
||||
|
||||
private String returnCode;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{" +
|
||||
"returnCode:'" + returnCode + '\'' +
|
||||
", message:'" + message + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
private String message;
|
||||
public static BpmcResponseDto success(){
|
||||
BpmcResponseDto bpmcResponseDto = new BpmcResponseDto();
|
||||
bpmcResponseDto.returnCode = "200"; // 成功时固定为200
|
||||
bpmcResponseDto.message = "操作成功";
|
||||
|
||||
return bpmcResponseDto;
|
||||
}
|
||||
|
||||
public static BpmcResponseDto error(String message){
|
||||
BpmcResponseDto bpmcResponseDto = new BpmcResponseDto();
|
||||
bpmcResponseDto.returnCode = "500"; // 失败时固定为500
|
||||
bpmcResponseDto.message = message;
|
||||
|
||||
return bpmcResponseDto;
|
||||
}
|
||||
|
||||
}
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
package com.jero.modules.docking.iam.dto.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* IAM出SchemaService外的成功响应 或 失败响应 通用报文
|
||||
*/
|
||||
@Data
|
||||
public class IamCommonResponseDto {
|
||||
|
||||
/**
|
||||
* 请求id,收到什么就返回什么
|
||||
*/
|
||||
private String bimRequestId;
|
||||
|
||||
/**
|
||||
* 相应码,0位正常
|
||||
*/
|
||||
private String resultCode;
|
||||
|
||||
/**
|
||||
* 消息
|
||||
*/
|
||||
private String message;
|
||||
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
package com.jero.modules.docking.iam.dto.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 组织机构创建的响应体
|
||||
*/
|
||||
@Data
|
||||
public class IamOrgCreateResponse extends IamCommonResponseDto{
|
||||
|
||||
/**
|
||||
* 用户创建后生成的id
|
||||
*/
|
||||
private String orgId;
|
||||
|
||||
}
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
package com.jero.modules.docking.iam.dto.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 组织机构创建的响应体
|
||||
*/
|
||||
@Data
|
||||
public class IamOrgIdListResponse extends IamCommonResponseDto{
|
||||
|
||||
/**
|
||||
* 用户创建后生成的id
|
||||
*/
|
||||
private List<String> orgIdList;
|
||||
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
package com.jero.modules.docking.iam.dto.response;
|
||||
|
||||
import com.jero.modules.docking.iam.dto.IamOrgAcceptDto;
|
||||
import com.jero.modules.docking.iam.dto.IamUserAcceptDto;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 组织机构创建的响应体
|
||||
*/
|
||||
@Data
|
||||
public class IamOrgInfoResponse extends IamCommonResponseDto{
|
||||
|
||||
private IamOrgAcceptDto organization;
|
||||
|
||||
}
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
package com.jero.modules.docking.iam.dto.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Schema映射的响应体
|
||||
*/
|
||||
@Data
|
||||
public class IamSchemaResponse {
|
||||
|
||||
/**
|
||||
* 请求id,收到什么就返回什么
|
||||
*/
|
||||
private String bimRequestId;
|
||||
|
||||
/**
|
||||
* 用户账号的具体内容响应实体
|
||||
*/
|
||||
private List<SchemaResponseInner> account;
|
||||
|
||||
/**
|
||||
* 组织机构的具体内容响应实体
|
||||
*/
|
||||
private List<SchemaResponseInner> organization;
|
||||
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
package com.jero.modules.docking.iam.dto.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户创建的响应体
|
||||
*/
|
||||
@Data
|
||||
public class IamUserCreateResponse extends IamCommonResponseDto{
|
||||
|
||||
/**
|
||||
* 用户创建后生成的id
|
||||
*/
|
||||
private String uid;
|
||||
|
||||
}
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
package com.jero.modules.docking.iam.dto.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 组织机构创建的响应体
|
||||
*/
|
||||
@Data
|
||||
public class IamUserIdListResponse extends IamCommonResponseDto{
|
||||
|
||||
/**
|
||||
* 用户创建后生成的id
|
||||
*/
|
||||
private List<String> userIdList;
|
||||
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
package com.jero.modules.docking.iam.dto.response;
|
||||
|
||||
import com.jero.modules.docking.iam.dto.IamUserAcceptDto;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 组织机构创建的响应体
|
||||
*/
|
||||
@Data
|
||||
public class IamUserInfoResponse extends IamCommonResponseDto{
|
||||
|
||||
private IamUserAcceptDto account;
|
||||
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
package com.jero.modules.docking.iam.dto.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Schema的核心内容
|
||||
*/
|
||||
@Data
|
||||
public class SchemaResponseInner {
|
||||
|
||||
/**
|
||||
* 定义对象的属性字段名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 定义对象的属性字段类型,可选值为String、int、double、float、long、byte、boolean
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 定义对象的属性字段在创建时是否为必填字段。可选值true或者false
|
||||
*/
|
||||
private boolean required;
|
||||
|
||||
/**
|
||||
* 定义对象的属性字段是否为多值。可选值true或者false。字段为boolean类型
|
||||
*/
|
||||
private boolean multivalued;
|
||||
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
package com.jero.modules.docking.iam.exception;
|
||||
|
||||
import com.jero.common.util.MessageUtils;
|
||||
|
||||
public class IamGlobalException extends RuntimeException {
|
||||
|
||||
private String bimRequestId;
|
||||
private String message;
|
||||
|
||||
private static final long serialVersionUID = 3634632351214L;
|
||||
|
||||
public IamGlobalException(String bimRequestId, String message){
|
||||
super(message);
|
||||
this.bimRequestId = bimRequestId;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getBimRequestId() {
|
||||
return bimRequestId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
||||
-39
@@ -1,39 +0,0 @@
|
||||
package com.jero.modules.docking.iam.exception;
|
||||
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.modules.docking.iam.dto.response.IamCommonResponseDto;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.apache.shiro.authz.AuthorizationException;
|
||||
import org.apache.shiro.authz.UnauthorizedException;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.data.redis.connection.PoolException;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.multipart.MaxUploadSizeExceededException;
|
||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||
|
||||
/**
|
||||
* IAM对接全局异常处理器
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
@Slf4j
|
||||
public class IamGlobalExceptionHandler {
|
||||
|
||||
/**
|
||||
* 处理自定义异常
|
||||
*/
|
||||
@ExceptionHandler(IamGlobalException.class)
|
||||
public IamCommonResponseDto handleJeroBootException(IamGlobalException e){
|
||||
IamCommonResponseDto iamCommonResponseDto = new IamCommonResponseDto();
|
||||
iamCommonResponseDto.setBimRequestId(e.getBimRequestId());
|
||||
iamCommonResponseDto.setResultCode("-1"); // 错误码统一为-1
|
||||
iamCommonResponseDto.setMessage(e.getMessage());
|
||||
|
||||
return iamCommonResponseDto;
|
||||
}
|
||||
|
||||
}
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
package com.jero.modules.docking.iam.po;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* PO系统交互必须的实体,包含接口传递的基本信息头
|
||||
*/
|
||||
@Data
|
||||
public class MessageHeader {
|
||||
|
||||
/**
|
||||
* 接口ID
|
||||
*/
|
||||
@JsonProperty("Interface_ID")
|
||||
private String interfaceID;
|
||||
|
||||
/**
|
||||
* UUID
|
||||
*/
|
||||
@JsonProperty("UUID")
|
||||
private String UUID;
|
||||
|
||||
/**
|
||||
* 消息Id
|
||||
*/
|
||||
@JsonProperty("MessageId")
|
||||
private String messageId;
|
||||
|
||||
/**
|
||||
* 发送系统
|
||||
*/
|
||||
@JsonProperty("Sender")
|
||||
private String sender;
|
||||
|
||||
/**
|
||||
* 接收系统
|
||||
*/
|
||||
@JsonProperty("Receiver")
|
||||
private String receiver;
|
||||
|
||||
/**
|
||||
* 发送日期
|
||||
*/
|
||||
@JsonProperty("SendDate")
|
||||
private String sendDate;
|
||||
|
||||
/**
|
||||
* 发送时间
|
||||
*/
|
||||
@JsonProperty("SendTime")
|
||||
private String sendTime;
|
||||
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
package com.jero.modules.docking.iam.po.decrypt;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.jero.modules.docking.iam.po.MessageHeader;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 和PO系统做数据交互的最外层壳,做数据接收用
|
||||
*/
|
||||
@Data
|
||||
public class AcceptDecryptPo {
|
||||
|
||||
@JsonProperty("MessageHeader")
|
||||
private MessageHeader messageHeader;
|
||||
|
||||
@JsonProperty("Tables")
|
||||
private MessageDecryptTabels messageDecryptTabels;
|
||||
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
package com.jero.modules.docking.iam.po.decrypt;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* PO系统交互必须的实体,包含接口传递的正式数据(仅为套的一层壳)
|
||||
*/
|
||||
@Data
|
||||
public class MessageDecryptTabels {
|
||||
|
||||
@JsonProperty("Header")
|
||||
private MessageTablesData header;
|
||||
}
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
package com.jero.modules.docking.iam.po.decrypt;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @ClassName: MessageTablesData
|
||||
* @Description:
|
||||
* @Author: yjz
|
||||
* @Date: 2023-11-07 14:21
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Data
|
||||
public class MessageTablesData {
|
||||
@JsonProperty("data")
|
||||
private String data;
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
package com.jero.modules.docking.iam.po.decrypt;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.jero.modules.docking.iam.po.MessageHeader;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 和PO系统做数据交互的最外层壳,做数据发送用
|
||||
*/
|
||||
@Data
|
||||
public class SendPoDecryptPo<T> {
|
||||
|
||||
@JsonProperty("MessageHeader")
|
||||
private MessageHeader messageHeader;
|
||||
|
||||
@JsonProperty("Returns")
|
||||
private T returns;
|
||||
|
||||
public SendPoDecryptPo<T> response(MessageHeader messageHeader, T t){
|
||||
SendPoDecryptPo<T> sendPoDecryptPo = new SendPoDecryptPo<>();
|
||||
sendPoDecryptPo.setMessageHeader(messageHeader);
|
||||
sendPoDecryptPo.setReturns(t);
|
||||
|
||||
return sendPoDecryptPo;
|
||||
}
|
||||
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
package com.jero.modules.docking.iam.po.encrypt;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.jero.modules.docking.iam.po.MessageHeader;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 和PO系统做数据交互的最外层壳,做数据接收用
|
||||
*/
|
||||
@Data
|
||||
public class AcceptEncryptPo {
|
||||
|
||||
@JsonProperty("MessageHeader")
|
||||
private MessageHeader messageHeader;
|
||||
|
||||
@JsonProperty("Tables")
|
||||
private MessageEncryptTabels messageEncryptTabels;
|
||||
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
package com.jero.modules.docking.iam.po.encrypt;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* PO系统交互必须的实体,包含接口传递的正式数据(仅为套的一层壳)
|
||||
*/
|
||||
@Data
|
||||
public class MessageEncryptTabels {
|
||||
|
||||
@JsonProperty("Header")
|
||||
private MessageEncryptTabelsHeader header;
|
||||
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
package com.jero.modules.docking.iam.po.encrypt;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 接受数据的tables中的header层
|
||||
*/
|
||||
@Data
|
||||
public class MessageEncryptTabelsHeader {
|
||||
|
||||
@JsonProperty("data")
|
||||
private String data;
|
||||
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
package com.jero.modules.docking.iam.po.encrypt;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 返回数据的Return层
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class SendEncryptReturnsPo {
|
||||
|
||||
@JsonProperty("data")
|
||||
private String data;
|
||||
|
||||
public SendEncryptReturnsPo(String data){
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
package com.jero.modules.docking.iam.po.encrypt;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.jero.modules.docking.iam.po.MessageHeader;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 和PO系统做数据交互的最外层壳,做数据发送用
|
||||
*/
|
||||
@Data
|
||||
public class SendPoEncryptPo {
|
||||
|
||||
@JsonProperty("MessageHeader")
|
||||
private MessageHeader messageHeader;
|
||||
|
||||
@JsonProperty("Returns")
|
||||
private SendEncryptReturnsPo returns;
|
||||
|
||||
}
|
||||
-1037
File diff suppressed because it is too large
Load Diff
-85
@@ -1,85 +0,0 @@
|
||||
package com.jero.modules.docking.utils;//package com.jero.modules.iam;
|
||||
|
||||
import com.bamboocloud.codec.BamboocloudFacade;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
@Slf4j
|
||||
public class BamboocloudUtils {
|
||||
public static void main(String[] args) {
|
||||
String aes = BamboocloudFacade.encrypt("{\"uid\":\"104\",\"bimRequestId\":\"95d73fe7aa7a4930a3edea779708a46c\",\"resultCode\":\"0\",\"message\":\"success\"}", "123456", "AES");
|
||||
System.out.println(aes);
|
||||
String aes1 = getPlaintext("RCDFN8z1xhTVuDL8jCNwwYLlH9OqZZhZy+ExtFaM7ppAzIgcaf6MxVq/1hRmm8o7JWmro9Q8yMF7Jnb+Sw0JYOIxXcxgDvOb8E4OIHPXPMgMeuZokKANWQa7aZvGfQA7s+ncR1st9NyjSgo9MtUC7cL4zG+eGcDTb55b/TBBp2G/wqiXM2iNZs0mNMUgyAt7KpeCkvcxkugSbbR0uEteMiFjHTb11xdX/d2ySnJQe7eJ2OCuqC43ugnUr898BLZ+xuPQ1jBUb+OAo9yqvXcYD4nwrC7gKS1qlzTy09U4rymymC9olFpMA9TyP12M+My0XoFJ0gq5kJZnUpax9Xi1aghB0iSGXxUmJzL9kWm18KnMaVFtRYGhwYBv5doUa5bzTGExdokx2YMEzUjkY1MfCcBCGk6VfoiF56a5zfh2w13Okwke19jmFvwp8p4s04n6xrgK8ejg96kiMXjmu2R/HffRieNLK9wtXaEdsTCWwqdgyrm4I3mpmmrLIKnpe/cnYuzZw5wvDwVL0se/j9jVAhnLFyklxwb+x9iJK+EnUzbk9S/OOI8XxGIIgMC6SeNVNjuonzb3xN01IPCOteEAA43vYkRkcIWZnCFRVHez8fBVs4PlsGIN3GK+PpqZfcIKozrbBMD08YAvFGA9KL/wnp2pggpiixuXD+oG18WT3FsO1XD3yX7d7Gu/jONE2SDTNdtGQCXhYJ1ul9/Hp4uNAs6TCR7X2OYW/CnynizTifrGuArx6OD3qSIxeOa7ZH8d99GJ40sr3C1doR2xMJbCp0AmXDbpb/M9qYpLapBu2+BVs4PlsGIN3GK+PpqZfcIKsr9QrVNVIpgXmi+Af40P6qSJjek9yzYXDgzCWx9ry4IEEnyb2ZF42lVhmwOg6dIZ8qiG305NE9wxdW08KjWFDE23TbwkxdmWAAZy4nYp4LEX7nUIzGLsfmtq2h4D0CtioawcrJqNr67/BWlqwfkzl1NHoSnZozOqXE3eSCz3uKsuHJK4bMLTvoPAjhMA4ukMs+ncR1st9NyjSgo9MtUC7cL4zG+eGcDTb55b/TBBp2G/wqiXM2iNZs0mNMUgyAt7fw66deHvwplBeSRYdqWH0V5dH1+B1lYwX3nd1kAlHwez6dxHWy303KNKCj0y1QLtwvjMb54ZwNNvnlv9MEGnYb/CqJczaI1mzSY0xSDIC3uTr7zmnwMR5bQNIDP5s3/LhMSi3nNM2ZTAQfqZM8k0Ql6BSdIKuZCWZ1KWsfV4tWoIQdIkhl8VJicy/ZFptfCpzGlRbUWBocGAb+XaFGuW8w/VpjlYjjcDMh/x6yH1DpUKw9Uhgi5ypiFigrGuTGKSVbOD5bBiDdxivj6amX3CCrK/UK1TVSKYF5ovgH+ND+qkiY3pPcs2Fw4Mwlsfa8uCBBJ8m9mReNpVYZsDoOnSGe1TfeqA4g863/uHzY7iDjpawoNzZmGRL8j2nNhSxQ5F2EPL2VBKQ6qz8T+KD5pVlRpG513hlJIJTqU76qPYiwEWh+cZhAmZIcgN4t/Ao7kOGxvHtVBv24aHAzGnW1PMqM6TCR7X2OYW/CnynizTifrGuArx6OD3qSIxeOa7ZH8d99GJ40sr3C1doR2xMJbCp9/nxHeoEq7BrXIZOamG7dLDxrCHZj8jLTmGvMJREDNJs+ncR1st9NyjSgo9MtUC7cL4zG+eGcDTb55b/TBBp2G/wqiXM2iNZs0mNMUgyAt7R2Ly5850yACGSmx2687YmlWzg+WwYg3cYr4+mpl9wgqyv1CtU1UimBeaL4B/jQ/qpImN6T3LNhcODMJbH2vLggQSfJvZkXjaVWGbA6Dp0hmQ5+XEJykk0ygA1dEpxVSKaFtk5Pymwmv9bXqZrzj7E2dFOiF3Qw02R5xTY3kdeCt3tjzQwAjIZk1xu8aSyA51a9HH7ORSHbLC2odaKM7+R3eSzc73yprSM4ahKLw9g5ObDsl2fxBIcSBc2DEPANMC0rsHuVKLxkKyGGhc79bvlutQBAql+ZS57Yiob6qLIV+FSH7Bsk8dz1dcZM1Qcu9bEMkzY+INICBiJOB1wsVHsInY4K6oLje6CdSvz3wEtn7G49DWMFRv44Cj3Kq9dxgPifCsLuApLWqXNPLT1TivKbKe5XfgQH7+tPPbZM5dzR6155+FR9TbKL/SFDsDn4UFWsKDc2ZhkS/I9pzYUsUORVXCS7dZ54M/8vwQJPk2cgKhrBysmo2vrv8FaWrB+TOXU0ehKdmjM6pcTd5ILPe4qzLLUuVRkEKlSLrpFkFLHplEnNyMgh4SGTZBVyDVO4ED8FSM3DsdwQf8EAslOI+TvqFvMY04IdDTKol6Ggr0b6g/LVkdGi/5zyRKTtlG7ywQP7fw7wOatjZdSiAyHd4GcV2FOYWnylVtqOXfcZa+DjOhBpf77N8yqeClz4u7r/F2Bfl2xnKy0msdf5HSTSMg4sILp/BzbvOlSNy+95pkt/Rbun0JgKlC8vtOk0nsvQ++VbOD5bBiDdxivj6amX3CCqM62wTA9PGALxRgPSi/8J6dqYIKYosblw/qBtfFk9xbDtVw98l+3exrv4zjRNkg099i7AsRJvPp8ujh3VuQM9YQoFCbAFXyVALX3AtSXTWR1v6z2zY/O9ZE/cY5GJFIZ85FAC4u/cWWNknHIYkhiSm/wqiXM2iNZs0mNMUgyAt74NZpySRsMW4myzkMhW0vGgYuiY9YBQ7E16IM66swANIszSUdPD7DTYb1nn+X4nQHGcsXKSXHBv7H2Ikr4SdTNnIoqKznnUBlzkEvjF7jItLrUAQKpfmUue2IqG+qiyFfKFRbZ653kyAJFYEDsjxhnLFVjLloIPTtscY665JQsV8nDRf+NIbBDKQbxtCtCeT5JhmbYGRP3n2nWWUM3Y/m1QX5dsZystJrHX+R0k0jIOI91/XOz0G4csX/lV0/zwLLm6Ld99I8bawwp7DMZzPRpM6TCR7X2OYW/CnynizTifrGuArx6OD3qSIxeOa7ZH8dG+u+zS090O6PFigACG8Rp4VcWYgiVQguIzGdziVJQ38FJz9ez8lXw7E9M10CU7+qoGIhtWEGqmfThhOAWSlvuRnLFyklxwb+x9iJK+EnUzbk9S/OOI8XxGIIgMC6SeNVNjuonzb3xN01IPCOteEAA5HYDZVP7dy9JrGpLpwhqakhYx029dcXV/3dskpyUHu3idjgrqguN7oJ1K/PfAS2fsbj0NYwVG/jgKPcqr13GA+J8Kwu4Cktapc08tPVOK8pJtXmClh9/Wo2gLBFYWle51Wzg+WwYg3cYr4+mpl9wgqyv1CtU1UimBeaL4B/jQ/qpImN6T3LNhcODMJbH2vLggQSfJvZkXjaVWGbA6Dp0hkEHR7bpFZ3pOJLVZd33bnAXYU5hafKVW2o5d9xlr4OM6EGl/vs3zKp4KXPi7uv8XYF+XbGcrLSax1/kdJNIyDiODeK2/B0McXnO+NqhcB2zgmimMlDMmb/mMFMlg8xR3KbDsl2fxBIcSBc2DEPANMC0rsHuVKLxkKyGGhc79bvlutQBAql+ZS57Yiob6qLIV/o4VAE10DqfJcBhDDOYyk2RJzcjIIeEhk2QVcg1TuBA/BUjNw7HcEH/BALJTiPk76hbzGNOCHQ0yqJehoK9G+oPy1ZHRov+c8kSk7ZRu8sEE2BY3DKU8KxY4dvK6cI3oVegUnSCrmQlmdSlrH1eLVqCEHSJIZfFSYnMv2RabXwqcxpUW1FgaHBgG/l2hRrlvNOatmPEXzmtphZe1WoU220zTHBa0Wr6Bv4wNekbjQW6CcNF/40hsEMpBvG0K0J5PnGByStQR+czDTw/PskpqL8d4gWfAWqQwC4piREXJqCMlSg4nL5rkic6Ui/FO2pfAgFcb9RvDP4uwvljSOejSsIzpMJHtfY5hb8KfKeLNOJ+sa4CvHo4PepIjF45rtkfx330YnjSyvcLV2hHbEwlsKnBR34jI1sFr3w6u9HrzxxAM1agTZoUkEViFdIGlSQzodegUnSCrmQlmdSlrH1eLVqZa6wd8Guwj8sumb7Iwx/gKFvMY04IdDTKol6Ggr0b6g/LVkdGi/5zyRKTtlG7ywQEof2S70odz+MTkcK/h3ftVWzg+WwYg3cYr4+mpl9wgqjOtsEwPTxgC8UYD0ov/CenamCCmKLG5cP6gbXxZPcWw7VcPfJft3sa7+M40TZINMsQ17srKPL7v9frPXvm9E+ocn5y5dsGfPDW51szMq7r5IuO1T166XswzGk4T7A47CXW2Y/Gc5D42pKEXx8tu2i9Ew/UgT8eGfprJx0k4DWHQ==", "123456", "AES");
|
||||
System.out.println(aes1);
|
||||
}
|
||||
public static boolean checkUsernamePassword(String username, String password) {
|
||||
log.info("username --->" + username + " password --- >" + password + " ----ok");
|
||||
if("bbcadmin".equals(username)&&"P@ssw0rd".equals(password)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPlaintext(String ciphertext, String key, String type) {
|
||||
return BamboocloudFacade.decrypt(ciphertext, key, type);
|
||||
}
|
||||
|
||||
public static Boolean verify(Map<String, Object> reqmap, String type) {
|
||||
Map<String, Object> verifymap = new TreeMap<String, Object>();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
Iterator<String> it = reqmap.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
String key = (String) it.next();
|
||||
verifymap.put(key, reqmap.get(key));
|
||||
}
|
||||
Iterator<String> ittree = verifymap.keySet().iterator();
|
||||
while (ittree.hasNext()) {
|
||||
String key = (String) ittree.next();
|
||||
if (!"signature".equals(key)) {
|
||||
sb.append(key).append("=").append(verifymap.get(key)).append("&");
|
||||
}
|
||||
}
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
System.out.println(reqmap.get("signature") + " now " + sb.toString());
|
||||
return BamboocloudFacade.verify(reqmap.get("signature").toString(), sb.toString(), type);
|
||||
}
|
||||
|
||||
public static String getRequestBody(HttpServletRequest request) {
|
||||
BufferedReader br = null;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String str = "";
|
||||
try {
|
||||
br = request.getReader();
|
||||
while ((str = br.readLine()) != null) {
|
||||
sb.append(str);
|
||||
}
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException eo) {
|
||||
eo.printStackTrace();
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
-92
@@ -1,92 +0,0 @@
|
||||
package com.jero.modules.docking.utils;
|
||||
|
||||
/**
|
||||
* 常量类
|
||||
*/
|
||||
public class DockingConstant {
|
||||
|
||||
/**
|
||||
* 本系统名称
|
||||
*/
|
||||
public static String SYSTEM_NAME = "SRMS";
|
||||
|
||||
/**
|
||||
* IAM系统名称
|
||||
*/
|
||||
public static String IAM_SYSTEM_NAME = "IAM";
|
||||
|
||||
/**
|
||||
* IAM对称加密算法
|
||||
*/
|
||||
public static String IAM_ENCRYPT_TYPE = "AES";
|
||||
|
||||
/**
|
||||
* IAM对称加密密钥
|
||||
*/
|
||||
public static String IAM_ENCRYPT_SECRET = "123456";
|
||||
|
||||
/**
|
||||
* IAM正确时的返回码
|
||||
*/
|
||||
public static String IAM_SUCCESS_RESULT_CODE = "0";
|
||||
|
||||
/**
|
||||
* IAM正确时的返回消息
|
||||
*/
|
||||
public static String IAM_SUCCESS_MESSAGE = "success";
|
||||
|
||||
/**
|
||||
* IAM错误时的返回码
|
||||
*/
|
||||
public static String IAM_ERROR_RESULT_CODE = "500";
|
||||
|
||||
/**
|
||||
* 竹云统一认证平台,接口类型:角色
|
||||
*/
|
||||
public static final String BPMC_TYPE_ROLE = "D_AR";
|
||||
|
||||
/**
|
||||
* 竹云统一认证平台,接口类型:功能权限
|
||||
*/
|
||||
public static final String BPMC_TYPE_RESOURCE = "D_AM";
|
||||
|
||||
/**
|
||||
* 竹云统一认证平台,接口类型:账号与应用角色关系
|
||||
*/
|
||||
public static final String BPMC_TYPE_USER_ROLE = "R_USER_AR";
|
||||
|
||||
/**
|
||||
* 竹云统一认证平台,接口类型:应用角色与应用功能权限关系
|
||||
*/
|
||||
public static final String BPMC_TYPE_ROLE_RESOURCE = "R_AR_AM";
|
||||
|
||||
/**
|
||||
* 竹云统一认证平台,操作类型:新增
|
||||
*/
|
||||
public static String BPMC_ACTION_ADD = "add";
|
||||
/**
|
||||
* 竹云统一认证平台,操作类型:更新
|
||||
*/
|
||||
public static String BPMC_ACTION_UPDATE = "update";
|
||||
|
||||
/**
|
||||
* 竹云统一认证平台,操作类型:删除
|
||||
*/
|
||||
public static String BPMC_ACTION_DELETE = "delete";
|
||||
|
||||
/**
|
||||
* 竹云统一认证平台,功能权限(资源类型):菜单
|
||||
*/
|
||||
public static int BPMC_RESOURCE_TYPE_MENU = 0;
|
||||
|
||||
/**
|
||||
* 竹云统一认证平台,功能权限(资源类型):子菜单
|
||||
*/
|
||||
public static int BPMC_RESOURCE_TYPE_CHILD_MENU = 1;
|
||||
|
||||
/**
|
||||
* 竹云统一认证平台,功能权限(资源类型):按钮
|
||||
*/
|
||||
public static int BPMC_RESOURCE_TYPE_BUTTON = 2;
|
||||
|
||||
}
|
||||
-90
@@ -1,90 +0,0 @@
|
||||
package com.jero.modules.docking.utils;
|
||||
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.util.DigestUtils;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* intekey解密文件相关
|
||||
*/
|
||||
public class IntekeyUtils {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(IntekeyUtils.class);
|
||||
|
||||
/**
|
||||
* 解密文件,返回InputStream,供excel使用
|
||||
*
|
||||
*
|
||||
* @param url
|
||||
* @param multipartFile
|
||||
* @return
|
||||
*/
|
||||
//todo 这个方法需要写在laws-modules-docking 里面 可以新建一个文件夹是encrypt
|
||||
public static InputStream DecryptFile(String url, String appCode, String secretKey, Integer scope, MultipartFile multipartFile) {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
||||
logger.info("解密时间:" + format.format(new Date()));
|
||||
//设置校验
|
||||
Long time = System.currentTimeMillis();
|
||||
|
||||
String sign = DigestUtils.md5DigestAsHex((secretKey + time).getBytes());
|
||||
url = url + "?appCode=" + appCode + "&time=" + time + "&sign=" + sign + (Objects.isNull(scope) ? "" : "&scope=" + scope);
|
||||
File file = transferToFile(multipartFile);
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
//设置请求头
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
MediaType type = MediaType.parseMediaType("multipart/form-data");
|
||||
headers.setContentType(type);
|
||||
|
||||
//设置请求体,注意是LinkedMultiValueMap
|
||||
FileSystemResource fileSystemResource = new FileSystemResource(file);
|
||||
MultiValueMap<String, Object> form = new LinkedMultiValueMap<>();
|
||||
form.add("file", fileSystemResource);
|
||||
form.add("filename", multipartFile.getOriginalFilename());
|
||||
//用HttpEntity封装整个请求报文
|
||||
HttpEntity<MultiValueMap<String, Object>> files = new HttpEntity<>(form, headers);
|
||||
System.out.println(url);
|
||||
ResponseEntity<byte[]> entity = restTemplate.exchange(url, HttpMethod.POST, files, byte[].class);
|
||||
System.out.println(entity.getStatusCode().value() + ","+ entity.getStatusCode().getReasonPhrase() + "," + Objects.requireNonNull(entity.getBody()).length);
|
||||
byte[] body = entity.getBody();
|
||||
InputStream sbs = new ByteArrayInputStream(body);
|
||||
return sbs;
|
||||
}
|
||||
|
||||
private static File transferToFile(MultipartFile multipartFile) {
|
||||
// 选择用缓冲区来实现这个转换即使用java 创建的临时文件 使用 MultipartFile.transferto()方法 。
|
||||
File file = null;
|
||||
try {
|
||||
String originalFilename = multipartFile.getOriginalFilename();
|
||||
int index = originalFilename.lastIndexOf(".");
|
||||
//String[] filename = originalFilename.split("\\.");
|
||||
file = File.createTempFile(originalFilename.substring(0, index), originalFilename.substring(index + 1));
|
||||
file.delete();
|
||||
multipartFile.transferTo(file);
|
||||
file.deleteOnExit();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String args[]) {
|
||||
String originalFilename = "C:\\Users\\LQT\\Desktop\\参考代码 - 副本.txt";
|
||||
int index = originalFilename.lastIndexOf(".");
|
||||
//String[] filename = originalFilename.split("\\.");
|
||||
System.out.println(originalFilename.substring(0, index) + "||||||||||||" + originalFilename.substring(index + 1));
|
||||
}
|
||||
}
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
package com.jero.modules.docking.utils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class SHA256Util {
|
||||
public static void main(String[] args) {
|
||||
String sha256StrJava = getSHA256StrJava("123456");
|
||||
System.out.println(sha256StrJava);
|
||||
}
|
||||
/**
|
||||
* 利用java原生的摘要实现SHA256加密密后的报文
|
||||
*/
|
||||
public static String getSHA256StrJava(String str) {
|
||||
MessageDigest messageDigest;
|
||||
String encodeStr = "";
|
||||
try {
|
||||
messageDigest = MessageDigest.getInstance("SHA-256");
|
||||
messageDigest.update(str.getBytes(StandardCharsets.UTF_8));
|
||||
encodeStr = byte2Hex(messageDigest.digest());
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return encodeStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将byte转为16进制
|
||||
*/
|
||||
private static String byte2Hex(byte[] bytes) {
|
||||
StringBuilder stringBuffer = new StringBuilder();
|
||||
String temp;
|
||||
for (byte aByte : bytes) {
|
||||
temp = Integer.toHexString(aByte & 0xFF);
|
||||
if (temp.length() == 1) {
|
||||
//1得到一位的进行补0操作
|
||||
stringBuffer.append("0");
|
||||
}
|
||||
stringBuffer.append(temp);
|
||||
}
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user