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.exception.ClientException; import cn.huge.base.common.exception.ServiceException; import cn.huge.base.common.utils.ObjectUtils; import cn.huge.module.client.api.SysClient; import cn.huge.module.sys.dto.FileIdInfoBaseDTO; import cn.huge.module.sys.dto.FileIdTypeInfoBaseDTO; import cn.huge.module.sys.dto.FileInfoBaseDTO; import cn.huge.module.sys.dto.FileTypeInfoBaseDTO; 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 org.springframework.web.bind.annotation.RequestBody; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; /** * @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 ownerIdList 所属业务编号 * @return List */ public List listIdTypeInfoByOwnerIdList(List ownerIdList){ List fileIdTypeInfoBaseDTOList = new ArrayList<>(); try{ ReturnBO returnBo = sysClient.listTypeInfoByOwnerIdList(ownerIdList); if (ReturnConsts.OK == returnBo.getCode()){ if (ObjectUtils.isNotEmpty(returnBo.getData())){ List list = (List) 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 ownerIdList 所属业务编号 * @return List */ public List listIdInfoByOwnerIdList(List ownerIdList){ List fileIdInfoBaseDTOList = new ArrayList<>(); try{ ReturnBO returnBo = sysClient.listInfoByOwnerIdList(ownerIdList); if (ReturnConsts.OK == returnBo.getCode()){ if (ObjectUtils.isNotEmpty(returnBo.getData())){ List list = (List) 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; } }