package cn.huge.module.client.api.impl;
|
|
import cn.huge.base.common.bo.ReturnBO;
|
import cn.huge.base.common.constant.ReturnConsts;
|
import cn.huge.base.common.utils.DateUtils;
|
import cn.huge.base.common.utils.ObjectUtils;
|
import cn.huge.module.cases.domain.dto.FileRelateDTO;
|
import cn.huge.module.client.api.SysClient;
|
import cn.huge.module.sys.constant.TimeUnitConsts;
|
import cn.huge.module.sys.dto.*;
|
import com.alibaba.fastjson.JSON;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
|
import java.util.*;
|
|
/**
|
* @title: 系统公共服务微服务调用接口
|
* @description: 系统公共服务微服务调用接口
|
* @company: hugeinfo
|
* @author: liyj
|
* @time: 2021-11-05 16:51:48
|
* @version: 1.0.0
|
*/
|
@Slf4j
|
@Component
|
public class SysClientImpl {
|
|
private SysClient sysClient;
|
|
@Autowired
|
public SysClientImpl(SysClient sysClient) {
|
this.sysClient = sysClient;
|
}
|
|
/**
|
* ObjectMapper工具类
|
*/
|
private ObjectMapper objectMapper = new ObjectMapper();
|
|
/**
|
* 附件中心-根据多个所属编号查询附件并根据先根据ownerId再根据附件类型分组
|
* @param term 所属业务编号
|
* @return List
|
*/
|
public List<FileIdTypeInfoBaseDTO> listIdTypeInfoByOwnerIdList(Map<String, Object> term){
|
List<FileIdTypeInfoBaseDTO> fileIdTypeInfoBaseDTOList = new ArrayList<>();
|
try{
|
ReturnBO returnBo = sysClient.listTypeInfoByOwnerIdList(term);
|
if (ReturnConsts.OK == returnBo.getCode()){
|
if (ObjectUtils.isNotEmpty(returnBo.getData())){
|
List<LinkedHashMap> list = (List<LinkedHashMap>) returnBo.getData();
|
for (LinkedHashMap map : list) {
|
FileIdTypeInfoBaseDTO fileIdTypeInfoBaseDTO = JSON.parseObject(JSON.toJSONString(map), FileIdTypeInfoBaseDTO.class);
|
fileIdTypeInfoBaseDTOList.add(fileIdTypeInfoBaseDTO);
|
}
|
}
|
}
|
}catch (Exception e){
|
log.error("service方法[SysClientImpl.listIdTypeInfoByOwnerIdList]调用异常:"+e, e);
|
}
|
return fileIdTypeInfoBaseDTOList;
|
}
|
|
/**
|
* 附件中心-根据业务编号查询固定格式所有附件
|
* @param term 所属业务编号
|
* @return List
|
*/
|
public List<FileIdInfoBaseDTO> listIdInfoByOwnerIdList(Map<String, Object> term){
|
List<FileIdInfoBaseDTO> fileIdInfoBaseDTOList = new ArrayList<>();
|
try{
|
ReturnBO returnBo = sysClient.listInfoByOwnerIdList(term);
|
if (ReturnConsts.OK == returnBo.getCode()){
|
if (ObjectUtils.isNotEmpty(returnBo.getData())){
|
List<LinkedHashMap> list = (List<LinkedHashMap>) returnBo.getData();
|
for (LinkedHashMap map : list) {
|
FileIdInfoBaseDTO fileIdInfoBaseDTO = JSON.parseObject(JSON.toJSONString(map), FileIdInfoBaseDTO.class);
|
fileIdInfoBaseDTOList.add(fileIdInfoBaseDTO);
|
}
|
}
|
}
|
}catch (Exception e){
|
log.error("service方法[SysClientImpl.listIdInfoByOwnerIdList]调用异常:"+e, e);
|
}
|
return fileIdInfoBaseDTOList;
|
}
|
|
/**
|
* 获取时限
|
* @param limitType 时限类型
|
* @return List
|
*/
|
public Integer getTimeLimitHour(String limitType){
|
int timeTerm = 0;
|
try{
|
ReturnBO returnBo = sysClient.getExpireTime(limitType);
|
if (ReturnConsts.OK == returnBo.getCode()){
|
if (ObjectUtils.isNotEmpty(returnBo.getData())){
|
SyTimeLimitDTO syTimeLimitDTO = objectMapper.convertValue(returnBo.getData(), SyTimeLimitDTO.class);
|
if (ObjectUtils.isNotEmpty(syTimeLimitDTO)){
|
if (ObjectUtils.isNotEmpty(syTimeLimitDTO)){
|
if (TimeUnitConsts.TIME_UNIT_1.equals(syTimeLimitDTO.getTermUnit())){
|
timeTerm = syTimeLimitDTO.getTimeTerm()*24*365;
|
}
|
if (TimeUnitConsts.TIME_UNIT_2.equals(syTimeLimitDTO.getTermUnit())){
|
timeTerm = syTimeLimitDTO.getTimeTerm()*24*30;
|
}
|
if (TimeUnitConsts.TIME_UNIT_3.equals(syTimeLimitDTO.getTermUnit())){
|
timeTerm = syTimeLimitDTO.getTimeTerm()*24;
|
}
|
if (TimeUnitConsts.TIME_UNIT_4.equals(syTimeLimitDTO.getTermUnit())){
|
timeTerm = syTimeLimitDTO.getTimeTerm();
|
}
|
if (TimeUnitConsts.TIME_UNIT_5.equals(syTimeLimitDTO.getTermUnit())){
|
timeTerm = syTimeLimitDTO.getTimeTerm()/60;
|
}
|
}
|
}
|
}
|
}
|
}catch (Exception e){
|
log.error("service方法[SysClientImpl.listIdInfoByOwnerIdList]调用异常:"+e, e);
|
}
|
return timeTerm;
|
}
|
|
/**
|
* 获取时限
|
* @url {ctx}/api/web/syTimeLimit/getExpireTime
|
* @param computeTime
|
* @param limitType
|
* @return
|
*/
|
public Date getExpireTime(Date computeTime, String limitType){
|
Date expireTime = null;
|
try{
|
ReturnBO returnBo = sysClient.getExpireTime(limitType);
|
if (ReturnConsts.OK == returnBo.getCode()){
|
if (ObjectUtils.isNotEmpty(returnBo.getData())){
|
SyTimeLimitDTO syTimeLimitDTO = objectMapper.convertValue(returnBo.getData(), SyTimeLimitDTO.class);
|
if (ObjectUtils.isNotEmpty(syTimeLimitDTO)){
|
if (ObjectUtils.isNotEmpty(syTimeLimitDTO)){
|
if (TimeUnitConsts.TIME_UNIT_1.equals(syTimeLimitDTO.getTermUnit())){
|
expireTime = DateUtils.addYear(computeTime, syTimeLimitDTO.getTimeTerm());
|
}
|
if (TimeUnitConsts.TIME_UNIT_2.equals(syTimeLimitDTO.getTermUnit())){
|
expireTime = DateUtils.addMonth(computeTime, syTimeLimitDTO.getTimeTerm());
|
}
|
if (TimeUnitConsts.TIME_UNIT_3.equals(syTimeLimitDTO.getTermUnit())){
|
expireTime = DateUtils.addDay(computeTime, syTimeLimitDTO.getTimeTerm());
|
}
|
if (TimeUnitConsts.TIME_UNIT_4.equals(syTimeLimitDTO.getTermUnit())){
|
expireTime = DateUtils.addHour(computeTime, syTimeLimitDTO.getTimeTerm());
|
}
|
if (TimeUnitConsts.TIME_UNIT_5.equals(syTimeLimitDTO.getTermUnit())){
|
expireTime = DateUtils.addMonth(computeTime, syTimeLimitDTO.getTimeTerm());
|
}
|
}
|
}
|
}
|
}
|
}catch (Exception e){
|
log.error("service方法[SysClientImpl.getExpireTime]调用异常:"+e, e);
|
}
|
return expireTime;
|
}
|
|
/**
|
* 根据条件删除附件关系
|
* @param fileTypeTermsDTO 条件
|
* @return Object
|
*/
|
public void removeFileRelate(FileTypeTermsDTO fileTypeTermsDTO) {
|
try {
|
ReturnBO returnBo = sysClient.removeFileRelate(fileTypeTermsDTO);
|
if (ReturnConsts.OK != returnBo.getCode()){
|
log.error("Client外服务接口[SysClientImpl.removeFileRelate]请求异常:" + returnBo.getMsg(), returnBo.getMsg());
|
}
|
} catch (Exception e) {
|
log.error("service方法[SysClientImpl.removeFileRelate]请求异常:"+e, e);
|
}
|
}
|
|
/**
|
* 根据百度地图经纬度获取街道
|
* @url {ctx}/api/client/syRegion/getTownByBaiduiLngLat
|
* @param lng 经度
|
* @param lat 维度
|
* @return
|
*/
|
public QueAddrBaseDTO getQueAddrByBaiduiLngLat(String lng, String lat){
|
QueAddrBaseDTO queAddrBaseDTO = new QueAddrBaseDTO();
|
try{
|
ReturnBO returnBo = sysClient.getQueAddrByBaiduiLngLat(lng, lat);
|
if (ReturnConsts.OK == returnBo.getCode()){
|
if (ObjectUtils.isNotEmpty(returnBo.getData())){
|
queAddrBaseDTO = objectMapper.convertValue(returnBo.getData(), QueAddrBaseDTO.class);
|
}
|
}
|
}catch (Exception e){
|
log.error("service方法[SysClientImpl.getQueAddrByBaiduiLngLat]调用异常:"+e, e);
|
}
|
return queAddrBaseDTO;
|
}
|
|
/**
|
* 根据关系编号查询附件关系信息
|
* @param ownerId 附件关系编号
|
* @return List
|
*/
|
public List<FileRelateDTO> listFileRelateByOwnerId(String ownerId){
|
List<FileRelateDTO> fileRelateDTOList = new ArrayList<>();
|
try{
|
ReturnBO returnBo = sysClient.listFileRelateByOwnerId(ownerId);
|
if (ReturnConsts.OK == returnBo.getCode()){
|
if (ObjectUtils.isNotEmpty(returnBo.getData())){
|
List<LinkedHashMap> list = (List<LinkedHashMap>) returnBo.getData();
|
for (LinkedHashMap map : list) {
|
FileRelateDTO fileRelateDTO = JSON.parseObject(JSON.toJSONString(map), FileRelateDTO.class);
|
fileRelateDTOList.add(fileRelateDTO);
|
}
|
}
|
}
|
}catch (Exception e){
|
log.error("service方法[SysClientImpl.listFileRelateByOwnerId]调用异常:"+e, e);
|
}
|
return fileRelateDTOList;
|
}
|
|
/**
|
* 插入多条附件关系记录
|
* @param fileRelateList 附件关系
|
* @return Object
|
*/
|
public void saveFileRelateList(List<FileRelateDTO> fileRelateList) {
|
try {
|
ReturnBO returnBo = sysClient.saveFileRelateList(fileRelateList);
|
if (ReturnConsts.OK != returnBo.getCode()){
|
log.error("Client外服务接口[SysClientImpl.saveFileRelateList]请求异常:" + returnBo.getMsg(), returnBo.getMsg());
|
}
|
} catch (Exception e) {
|
log.error("service方法[SysClientImpl.saveFileRelateList]请求异常:"+e, e);
|
}
|
}
|
|
public List<QueAreaDTO> listByParentId(String parentId){
|
List<QueAreaDTO> queAreaDTOList = new ArrayList<>();
|
try{
|
ReturnBO returnBo = sysClient.listByParentId(parentId);
|
if (ReturnConsts.OK == returnBo.getCode()){
|
if (ObjectUtils.isNotEmpty(returnBo.getData())){
|
List<LinkedHashMap> list = (List<LinkedHashMap>) returnBo.getData();
|
for (LinkedHashMap map : list) {
|
QueAreaDTO queAreaDTO = JSON.parseObject(JSON.toJSONString(map), QueAreaDTO.class);
|
queAreaDTOList.add(queAreaDTO);
|
}
|
}
|
}
|
}catch (Exception e){
|
log.error("service方法[SysClientImpl.listFileRelateByOwnerId]调用异常:"+e, e);
|
}
|
return queAreaDTOList;
|
}
|
|
/**
|
* 根据id查询附件信息
|
* @url {ctx}/api/client/fileInfo/getFileInfoById
|
* @param id 条件
|
* @return
|
*/
|
public FileInfoBaseDTO getFileInfoById(String id){
|
FileInfoBaseDTO fileInfoBaseDTO = null;
|
try{
|
ReturnBO returnBo = sysClient.getFileInfoById(id);
|
if (ReturnConsts.OK == returnBo.getCode()){
|
if (ObjectUtils.isNotEmpty(returnBo.getData())){
|
fileInfoBaseDTO = new FileInfoBaseDTO();
|
fileInfoBaseDTO = objectMapper.convertValue(returnBo.getData(), FileInfoBaseDTO.class);
|
}
|
}
|
}catch (Exception e){
|
log.error("service方法[SysClientImpl.getFileInfoById]调用异常:"+e, e);
|
}
|
return fileInfoBaseDTO;
|
}
|
|
}
|