# Conflicts: # pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.javatags/24080901
@@ -128,7 +128,6 @@ | |||
<dependency> | |||
<groupId>org.springframework.boot</groupId> | |||
<artifactId>spring-boot-starter-test</artifactId> | |||
<!-- <scope>test</scope>--> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.mapstruct</groupId> | |||
@@ -141,7 +140,6 @@ | |||
<artifactId>java-jwt</artifactId> | |||
<version>3.10.3</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.mapstruct</groupId> | |||
<artifactId>mapstruct-processor</artifactId> | |||
@@ -203,10 +201,6 @@ | |||
</dependency> | |||
<dependency> | |||
<groupId>com.ningdatech</groupId> | |||
<artifactId>nd-basic</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>com.ningdatech</groupId> | |||
<artifactId>nd-irs-starter</artifactId> | |||
</dependency> | |||
<dependency> | |||
@@ -226,11 +220,6 @@ | |||
<groupId>com.ningdatech</groupId> | |||
<artifactId>nd-flowable-starter</artifactId> | |||
</dependency> | |||
<!-- <dependency>--> | |||
<!-- <groupId>com.ningdatech</groupId>--> | |||
<!-- <artifactId>nd-yxt-starter</artifactId>--> | |||
<!-- <version>1.0.0</version>--> | |||
<!-- </dependency>--> | |||
<!--浙政钉--> | |||
<dependency> | |||
<groupId>com.alibaba.xxpt</groupId> | |||
@@ -240,11 +229,6 @@ | |||
<systemPath>${basedir}/src/lib/zwdd-sdk-java-1.2.0.jar</systemPath> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.httpcomponents</groupId> | |||
<artifactId>httpclient</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>joda-time</groupId> | |||
<artifactId>joda-time</artifactId> | |||
</dependency> | |||
@@ -2,13 +2,13 @@ package com.ningdatech.pmapi.common.helper.basic; | |||
import com.github.benmanes.caffeine.cache.Caffeine; | |||
import com.github.benmanes.caffeine.cache.LoadingCache; | |||
import com.google.common.collect.Lists; | |||
import com.ningdatech.pmapi.common.model.RegionMapKey; | |||
import com.ningdatech.pmapi.sys.convert.RegionConverter; | |||
import com.ningdatech.pmapi.sys.model.dto.RegionDTO; | |||
import com.ningdatech.pmapi.sys.model.entity.Region; | |||
import com.ningdatech.pmapi.sys.service.IRegionService; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.assertj.core.util.Lists; | |||
import org.springframework.beans.factory.InitializingBean; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
@@ -61,8 +61,7 @@ public abstract class AbstractRegionCacheHelper implements InitializingBean { | |||
.maximumSize(512) | |||
.build(key -> { | |||
Region region = regionService.getOne(key.getRegionCode(), key.getRegionLevel()); | |||
// Assert.notNull(region, "区域不存在:%s", key); | |||
if(Objects.isNull(region)){ | |||
if (Objects.isNull(region)) { | |||
//查不到直接返回null | |||
return null; | |||
} | |||
@@ -129,79 +129,72 @@ public class UserInfoHelperImpl implements UserInfoHelper { | |||
/** | |||
* 批量查询 这里 会没有角色 | |||
* @param userInfos | |||
* @return | |||
* | |||
* @param userInfos \ | |||
* @return \ | |||
*/ | |||
@Override | |||
public List<UserFullInfoDTO> getUserFullInfos(List<UserInfo> userInfos) { | |||
List<UserFullInfoDTO> res = Lists.newArrayList(); | |||
if(CollUtil.isEmpty(userInfos)){ | |||
return res; | |||
if (CollUtil.isEmpty(userInfos)) { | |||
return Collections.emptyList(); | |||
} | |||
Map<String,UserInfo> userMap = userInfos.stream().collect(Collectors.toMap(UserInfo::getEmployeeCode,e->e)); | |||
Map<String, UserInfo> userMap = userInfos.stream().collect(Collectors.toMap(UserInfo::getEmployeeCode, e -> e)); | |||
// 获取浙政钉雇员信息 组织信息 | |||
List<String> employeeCodes = userInfos.stream().map(UserInfo::getEmployeeCode).collect(Collectors.toList()); | |||
if (CollUtil.isNotEmpty(employeeCodes)) { | |||
List<DingEmployeeInfo> dingEmployeeInfoList = iDingEmployeeInfoService | |||
.list(Wrappers.lambdaQuery(DingEmployeeInfo.class) | |||
.in(DingEmployeeInfo::getEmployeeCode, employeeCodes) | |||
.eq(DingEmployeeInfo::getMainJob, "true")); | |||
List<DingEmployeeInfo> dingEmployeeInfoList = iDingEmployeeInfoService | |||
.list(Wrappers.lambdaQuery(DingEmployeeInfo.class) | |||
.in(DingEmployeeInfo::getEmployeeCode, employeeCodes) | |||
.eq(DingEmployeeInfo::getMainJob, "true")); | |||
if(CollUtil.isEmpty(dingEmployeeInfoList)){ | |||
return res; | |||
} | |||
if (CollUtil.isEmpty(dingEmployeeInfoList)) { | |||
return Collections.emptyList(); | |||
} | |||
// 装配用户任职所在单位 | |||
List<String> empPosUnitCodes = dingEmployeeInfoList.stream().map(DingEmployeeInfo::getEmpPosUnitCode).collect(Collectors.toList()); | |||
List<String> orgCodes = dingEmployeeInfoList.stream().map(DingEmployeeInfo::getOrganizationCode).collect(Collectors.toList()); | |||
List<String> allOrgCodes = Stream.concat(empPosUnitCodes.stream(),orgCodes.stream()).collect(Collectors.toList()); | |||
if (CollUtil.isEmpty(allOrgCodes)) { | |||
return res; | |||
// 装配用户任职所在单位 | |||
List<String> empPosUnitCodes = dingEmployeeInfoList.stream().map(DingEmployeeInfo::getEmpPosUnitCode).collect(Collectors.toList()); | |||
List<String> orgCodes = dingEmployeeInfoList.stream().map(DingEmployeeInfo::getOrganizationCode).collect(Collectors.toList()); | |||
List<String> allOrgCodes = Stream.concat(empPosUnitCodes.stream(), orgCodes.stream()).collect(Collectors.toList()); | |||
if (CollUtil.isEmpty(allOrgCodes)) { | |||
return Collections.emptyList(); | |||
} | |||
List<DingOrganization> dingOrganizations = iDingOrganizationService.listByCodes(allOrgCodes); | |||
if (CollUtil.isEmpty(dingOrganizations)) { | |||
return Collections.emptyList(); | |||
} | |||
Map<String, DingOrganization> orgMap = dingOrganizations.stream().collect(Collectors.toMap(DingOrganization::getOrganizationCode, d -> d)); | |||
return dingEmployeeInfoList.stream().map(e -> { | |||
UserFullInfoDTO userFullInfo = new UserFullInfoDTO(); | |||
if (orgMap.containsKey(e.getEmpPosUnitCode())) { | |||
DingOrganization organization = orgMap.get(e.getEmpPosUnitCode()); | |||
userFullInfo.setEmpPosUnitCode(e.getEmpPosUnitCode()); | |||
userFullInfo.setEmpPosUnitName(organization.getOrganizationName()); | |||
userFullInfo.setRegionCode(organization.getDivisionCode()); | |||
} | |||
List<DingOrganization> dingOrganizations = iDingOrganizationService.listByCodes(allOrgCodes); | |||
if (CollUtil.isEmpty(dingOrganizations)) { | |||
return res; | |||
if (orgMap.containsKey(e.getOrganizationCode())) { | |||
DingOrganization organization = orgMap.get(e.getOrganizationCode()); | |||
userFullInfo.setOrganizationCode(organization.getOrganizationCode()); | |||
userFullInfo.setOrganizationName(organization.getOrganizationName()); | |||
// 测试使用 | |||
userFullInfo.setRegionLevel(3); | |||
} | |||
Map<String,DingOrganization> orgMap = dingOrganizations.stream().collect(Collectors.toMap(DingOrganization::getOrganizationCode,d -> d)); | |||
res = dingEmployeeInfoList.stream().map(e -> { | |||
UserFullInfoDTO userFullInfo = new UserFullInfoDTO(); | |||
if(orgMap.containsKey(e.getEmpPosUnitCode())){ | |||
DingOrganization organization = orgMap.get(e.getEmpPosUnitCode()); | |||
userFullInfo.setEmpPosUnitCode(e.getEmpPosUnitCode()); | |||
userFullInfo.setEmpPosUnitName(organization.getOrganizationName()); | |||
userFullInfo.setRegionCode(organization.getDivisionCode()); | |||
} | |||
if(orgMap.containsKey(e.getOrganizationCode())){ | |||
DingOrganization organization = orgMap.get(e.getOrganizationCode()); | |||
userFullInfo.setOrganizationCode(organization.getOrganizationCode()); | |||
userFullInfo.setOrganizationName(organization.getOrganizationName()); | |||
// 测试使用 | |||
userFullInfo.setRegionLevel(3); | |||
if (userMap.containsKey(e.getEmployeeCode())) { | |||
UserInfo userInfo = userMap.get(e.getEmployeeCode()); | |||
// 装配返回 | |||
userFullInfo.setUserId(userInfo.getId()); | |||
userFullInfo.setIdentifier(userInfo.getRealName()); | |||
userFullInfo.setRealName(userInfo.getRealName()); | |||
userFullInfo.setEmployeeCode(e.getEmployeeCode()); | |||
userFullInfo.setUsername(userInfo.getRealName()); | |||
userFullInfo.setMobile(userInfo.getMobile()); | |||
userFullInfo.setAccountId(userInfo.getAccountId()); | |||
String available = userInfo.getAvailable(); | |||
if (StringUtils.isNotBlank(available)) { | |||
userFullInfo.setAvailable(UserAvailableEnum.valueOf(available)); | |||
} | |||
if(userMap.containsKey(e.getEmployeeCode())){ | |||
UserInfo userInfo = userMap.get(e.getEmployeeCode()); | |||
// 装配返回 | |||
userFullInfo.setUserId(userInfo.getId()); | |||
userFullInfo.setIdentifier(userInfo.getRealName()); | |||
userFullInfo.setRealName(userInfo.getRealName()); | |||
userFullInfo.setEmployeeCode(e.getEmployeeCode()); | |||
userFullInfo.setUsername(userInfo.getRealName()); | |||
userFullInfo.setMobile(userInfo.getMobile()); | |||
userFullInfo.setAccountId(userInfo.getAccountId()); | |||
String available = userInfo.getAvailable(); | |||
if (StringUtils.isNotBlank(available)) { | |||
userFullInfo.setAvailable(UserAvailableEnum.valueOf(available)); | |||
} | |||
} | |||
return userFullInfo; | |||
}).collect(Collectors.toList()); | |||
} | |||
return res; | |||
} | |||
return userFullInfo; | |||
}).collect(Collectors.toList()); | |||
} | |||
@Override | |||
@@ -1,39 +1,33 @@ | |||
package com.ningdatech.pmapi.common.util; | |||
import java.io.UnsupportedEncodingException; | |||
import java.net.URLEncoder; | |||
import java.util.*; | |||
import java.util.function.BiConsumer; | |||
import java.util.stream.Collectors; | |||
import javax.servlet.http.HttpServletResponse; | |||
import cn.hutool.json.JSONUtil; | |||
import cn.hutool.poi.excel.ExcelUtil; | |||
import com.alibaba.excel.EasyExcel; | |||
import com.alibaba.excel.ExcelWriter; | |||
import com.alibaba.excel.write.metadata.WriteSheet; | |||
import com.alibaba.fastjson.JSON; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.google.common.collect.Lists; | |||
import com.ningdatech.basic.exception.BizException; | |||
import com.ningdatech.basic.model.ApiResponse; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import com.ningdatech.basic.util.NdDateUtils; | |||
import com.ningdatech.basic.util.StrPool; | |||
import com.ningdatech.pmapi.common.constant.CommonConst; | |||
import com.ningdatech.pmapi.common.enumeration.ExportOptionEnum; | |||
import com.ningdatech.pmapi.common.model.entity.ExcelExportWriter; | |||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||
import com.ningdatech.pmapi.scheduler.contants.TaskContant; | |||
import com.wflow.workflow.bean.vo.ProcessInstanceVo; | |||
import com.wflow.workflow.bean.vo.ProcessTaskVo; | |||
import lombok.SneakyThrows; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.apache.commons.collections4.CollectionUtils; | |||
import org.apache.http.HttpStatus; | |||
import com.alibaba.fastjson.JSON; | |||
import com.ningdatech.basic.model.ApiResponse; | |||
import com.ningdatech.basic.util.StrPool; | |||
import cn.hutool.poi.excel.ExcelUtil; | |||
import lombok.SneakyThrows; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.assertj.core.util.Lists; | |||
import javax.servlet.http.HttpServletResponse; | |||
import java.io.UnsupportedEncodingException; | |||
import java.net.URLEncoder; | |||
import java.util.*; | |||
import java.util.function.BiConsumer; | |||
/** | |||
* <p> | |||
@@ -93,75 +87,75 @@ public class ExcelDownUtil { | |||
} | |||
setExportResponseHeader(excelExport.getFileName(), response); | |||
ExcelWriter writer = null; | |||
ExcelWriter writer; | |||
//是否启用头部属性、头部属性类不能为空 | |||
if (Objects.nonNull(excelExport.getHeadPropertyFlag()) && excelExport.getHeadPropertyFlag() && Objects.nonNull(excelExport.getHeadPropertyClass())) { | |||
writer = EasyExcel.write(response.getOutputStream(), excelExport.getHeadPropertyClass()).build(); | |||
}else { | |||
} else { | |||
writer = EasyExcel.write(response.getOutputStream()).build(); | |||
} | |||
int sheetNum = 0; | |||
if (CollectionUtils.isNotEmpty(excelExport.getSheets())){ | |||
if (CollectionUtils.isNotEmpty(excelExport.getSheets())) { | |||
sheetNum = excelExport.getSheets().size(); | |||
}else if (CollectionUtils.isNotEmpty(excelExport.getHeads())) { | |||
} else if (CollectionUtils.isNotEmpty(excelExport.getHeads())) { | |||
sheetNum = excelExport.getHeads().size(); | |||
}else if (CollectionUtils.isNotEmpty(excelExport.getDatas())) { | |||
} else if (CollectionUtils.isNotEmpty(excelExport.getDatas())) { | |||
sheetNum = excelExport.getDatas().size(); | |||
} | |||
if (sheetNum == 0){ | |||
if (sheetNum == 0) { | |||
sheetNum = 1; | |||
} | |||
for (int i = 0; i < sheetNum; i++) { | |||
WriteSheet sheet = EasyExcel.writerSheet(i).automaticMergeHead(false).build(); | |||
if (CollectionUtils.isNotEmpty(excelExport.getSheets())){ | |||
if (CollectionUtils.isNotEmpty(excelExport.getSheets())) { | |||
sheet.setSheetName(excelExport.getSheets().get(i)); | |||
} | |||
if (CollectionUtils.isNotEmpty(excelExport.getHeads())){ | |||
if (CollectionUtils.isNotEmpty(excelExport.getHeads())) { | |||
sheet.setHead(excelExport.getHeads().get(i)); | |||
} | |||
if (CollectionUtils.isNotEmpty(excelExport.getDatas())) { | |||
writer.write((Collection<?>) ((List)excelExport.getDatas()).get(i), sheet); | |||
}else { | |||
writer.write((Collection<?>) ((List) excelExport.getDatas()).get(i), sheet); | |||
} else { | |||
writer.write((Collection<?>) null, sheet); | |||
} | |||
} | |||
// 最后 finish | |||
if (null != writer) { | |||
writer.finish(); | |||
} | |||
}catch (Exception e){ | |||
writer.finish(); | |||
writer.close(); | |||
} catch (Exception e) { | |||
log.error("export file error!", e); | |||
throw new BizException("导出失败!"); | |||
} | |||
} | |||
public static void setExportResponseHeader(String fileName, HttpServletResponse response) throws UnsupportedEncodingException { | |||
// 设置响应头和保存文件名 | |||
response.setContentType(ExcelUtil.XLS_CONTENT_TYPE); | |||
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + encodeName(fileName) + ".xls"); | |||
} | |||
public static List<List<String>> getTaskExportDatas(List<ExportOptionEnum> columnList,List<ProcessTaskVo> taskVoList, Map<String, Project> projectInfoMap) { | |||
public static List<List<String>> getTaskExportDatas(List<ExportOptionEnum> columnList, List<ProcessTaskVo> taskVoList, Map<String, Project> projectInfoMap) { | |||
// 表体行数据集合 | |||
List<List<String>> rowList = Lists.newArrayList(); | |||
for (ExportOptionEnum column : columnList) { | |||
List<String> columnValues = Lists.newArrayList(); | |||
columnValues.add(column.getDesc()); | |||
taskVoList.stream().forEach(taskVo -> { | |||
taskVoList.forEach(taskVo -> { | |||
Project project = projectInfoMap.get(taskVo.getInstanceId()); | |||
String s = JSON.toJSONString(project); | |||
JSONObject jsonObject = JSON.parseObject(s); | |||
String columnValue = null; | |||
if (column.name().equals(ExportOptionEnum.processStatusName.name())){ | |||
String columnValue; | |||
if (column.name().equals(ExportOptionEnum.processStatusName.name())) { | |||
columnValue = taskVo.getStatus(); | |||
}else if (column.name().equals(ExportOptionEnum.processLaunchTime.name())){ | |||
} else if (column.name().equals(ExportOptionEnum.processLaunchTime.name())) { | |||
columnValue = NdDateUtils.format(taskVo.getCreateTime(), "yyyy-MM-dd HH:mm"); | |||
}else if (column.name().equals(ExportOptionEnum.processHandleTime.name())){ | |||
} else if (column.name().equals(ExportOptionEnum.processHandleTime.name())) { | |||
columnValue = NdDateUtils.format(taskVo.getTaskEndTime(), "yyyy-MM-dd HH:mm"); | |||
}else { | |||
} else { | |||
columnValue = String.valueOf(jsonObject.get(column.toString())); | |||
} | |||
columnValues.add(columnValue); | |||
@@ -172,23 +166,23 @@ public class ExcelDownUtil { | |||
} | |||
public static List<List<String>> getInstExportDatas(List<ExportOptionEnum> columnList,List<ProcessInstanceVo> instanceVoList, Map<String, Project> projectInfoMap) { | |||
public static List<List<String>> getInstExportDatas(List<ExportOptionEnum> columnList, List<ProcessInstanceVo> instanceVoList, Map<String, Project> projectInfoMap) { | |||
// 表体行数据集合 | |||
List<List<String>> rowList = Lists.newArrayList(); | |||
for (ExportOptionEnum column : columnList) { | |||
List<String> columnValues = Lists.newArrayList(); | |||
columnValues.add(column.getDesc()); | |||
instanceVoList.stream().forEach(instanceVo -> { | |||
instanceVoList.forEach(instanceVo -> { | |||
Project project = projectInfoMap.get(instanceVo.getInstanceId()); | |||
String s = JSON.toJSONString(project); | |||
JSONObject jsonObject = JSON.parseObject(s); | |||
String columnValue = null; | |||
if (column.name().equals(ExportOptionEnum.processStatusName.name())){ | |||
String columnValue; | |||
if (column.name().equals(ExportOptionEnum.processStatusName.name())) { | |||
columnValue = instanceVo.getStatus(); | |||
}else if (column.name().equals(ExportOptionEnum.processLaunchTime.name())){ | |||
} else if (column.name().equals(ExportOptionEnum.processLaunchTime.name())) { | |||
columnValue = NdDateUtils.format(instanceVo.getStartTime(), "yyyy-MM-dd HH:mm"); | |||
}else { | |||
} else { | |||
columnValue = String.valueOf(jsonObject.get(column.toString())); | |||
} | |||
columnValues.add(columnValue); | |||
@@ -199,14 +193,14 @@ public class ExcelDownUtil { | |||
} | |||
public static List<List<String>> getProjectExportDatas(List<ExportOptionEnum> columnList,List<Project> projects) { | |||
public static List<List<String>> getProjectExportDatas(List<ExportOptionEnum> columnList, List<Project> projects) { | |||
// 表体行数据集合 | |||
List<List<String>> rowList = Lists.newArrayList(); | |||
for (ExportOptionEnum column : columnList) { | |||
List<String> columnValues = Lists.newArrayList(); | |||
String desc = column.getDesc(); | |||
if (Objects.nonNull(desc)){ | |||
if (Objects.nonNull(desc)) { | |||
columnValues.add(desc); | |||
} | |||
projects.forEach(project -> { | |||
@@ -214,18 +208,18 @@ public class ExcelDownUtil { | |||
JSONObject jsonObject = JSON.parseObject(s); | |||
String columnValue; | |||
if (ExportOptionEnum.preliminaryPlanFile.equals(column) | |||
|| ExportOptionEnum.supportingMaterialsFile.equals(column)){ | |||
|| ExportOptionEnum.supportingMaterialsFile.equals(column)) { | |||
String fileStr = jsonObject.getString(column.toString()); | |||
if (Objects.isNull(fileStr) || CommonConst.NULL.equals(fileStr)){ | |||
if (Objects.isNull(fileStr) || CommonConst.NULL.equals(fileStr)) { | |||
return; | |||
} | |||
List<JSONObject> fileArray = JSON.parseArray(fileStr, JSONObject.class); | |||
List<String> nameList = CollUtils.fieldList(fileArray, w -> w.getString(CommonConst.FILE_NAME)); | |||
columnValue = nameList.stream().collect(Collectors.joining(StrPool.COMMA)); | |||
}else { | |||
columnValue = String.join(StrPool.COMMA, nameList); | |||
} else { | |||
columnValue = String.valueOf(jsonObject.get(column.toString())); | |||
} | |||
if (CommonConst.NULL.equals(columnValue)){ | |||
if (CommonConst.NULL.equals(columnValue)) { | |||
columnValue = ""; | |||
} | |||
columnValues.add(columnValue); | |||
@@ -3,28 +3,30 @@ package com.ningdatech.pmapi.common.util; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import java.nio.charset.StandardCharsets; | |||
import java.security.MessageDigest; | |||
public class Md5Utils { | |||
private static final Logger LOGGER = LoggerFactory.getLogger(Md5Utils.class); | |||
public static byte[] md5(String s) { | |||
MessageDigest algorithm; | |||
try { | |||
algorithm = MessageDigest.getInstance("MD5"); | |||
algorithm.reset(); | |||
algorithm.update(s.getBytes("UTF-8")); | |||
byte[] messageDigest = algorithm.digest(); | |||
return messageDigest; | |||
algorithm.update(s.getBytes(StandardCharsets.UTF_8)); | |||
return algorithm.digest(); | |||
} catch (Exception e) { | |||
LOGGER.error("MD5 Error...", e); | |||
} | |||
return null; | |||
} | |||
private static final String toHex(byte hash[]) { | |||
private static String toHex(byte[] hash) { | |||
if (hash == null) { | |||
return null; | |||
} | |||
StringBuffer buf = new StringBuffer(hash.length * 2); | |||
StringBuilder buf = new StringBuilder(hash.length * 2); | |||
int i; | |||
for (i = 0; i < hash.length; i++) { | |||
if ((hash[i] & 0xff) < 0x10) { | |||
@@ -37,9 +39,13 @@ public class Md5Utils { | |||
public static String hash(String s) { | |||
try { | |||
return new String(toHex(md5(s)).getBytes("UTF-8"), "UTF-8"); | |||
String hex = toHex(md5(s)); | |||
if (hex == null) { | |||
return s; | |||
} | |||
return new String(hex.getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8); | |||
} catch (Exception e) { | |||
LOGGER.error("not supported charset...{}", e); | |||
LOGGER.error("not supported charset:", e); | |||
return s; | |||
} | |||
} |
@@ -40,7 +40,7 @@ public class SendWorkNoticeUtil { | |||
GenericResult<Void> result = | |||
zwddClient.sendWorkNotice(workNoticeInfo.getReceiverUserId(), workNoticeInfo.getBizMsgId(), msg); | |||
String resultMsg = result.getMsg(); | |||
if (resultMsg.equals("success")) { | |||
if ("success".equals(resultMsg)) { | |||
log.info("异步任务执行完成, " + workNoticeInfo.getBizMsgId() + " 当前线程:" + Thread.currentThread().getName()); | |||
long endTime = System.currentTimeMillis(); | |||
log.info("方法执行完成返回,耗时:" + (endTime - startTime)); | |||
@@ -25,6 +25,7 @@ import java.io.*; | |||
import java.net.URI; | |||
import java.net.URL; | |||
import java.net.URLEncoder; | |||
import java.nio.charset.StandardCharsets; | |||
import java.security.Key; | |||
import java.text.DateFormat; | |||
import java.text.SimpleDateFormat; | |||
@@ -33,10 +34,6 @@ import java.util.stream.Collectors; | |||
public class IRSAPIRequest { | |||
public static void main(String[] args) throws Exception { | |||
} | |||
/** | |||
* pdf文件盖章 | |||
* 接口地址:/V1/accounts/outerAccounts/create | |||
@@ -51,8 +48,7 @@ public class IRSAPIRequest { | |||
String fileName = req.getFileName(); | |||
String posPage = req.getPosPage(); | |||
Integer signType = req.getSignType(); | |||
JSONObject obj = null; | |||
String resp = null; | |||
String resp; | |||
try { | |||
JSONObject ReqData = new JSONObject(); | |||
ReqData.put("fileBase64", pdfEncode64); | |||
@@ -71,15 +67,14 @@ public class IRSAPIRequest { | |||
//String signFileB64 = jsondata.getString("signFileB64"); | |||
//IRSAPIRequest.base64StringToPdf(signFileB64, "D:\\test21.pdf"); | |||
} catch (Exception e) { | |||
throw new BizException("调用IRS盖章接口失败,印章编号为:" + sealSn + StrPool.SEMICOLON + e.getMessage()); | |||
throw new BizException("调用IRS盖章接口失败,印章编号为:" + sealSn + StrPool.SEMICOLON + e.getMessage()); | |||
} | |||
// return obj; | |||
JSONObject jsonObject = JSON.parseObject(resp, JSONObject.class); | |||
String data = jsonObject.getString("data"); | |||
JSONObject object = JSON.parseObject(data, JSONObject.class); | |||
// 获取盖好章的PDF文件内容Base64字符串 | |||
String signFileB64 = object.getString("signFileB64"); | |||
return signFileB64; | |||
return object.getString("signFileB64"); | |||
} | |||
@@ -104,7 +99,7 @@ public class IRSAPIRequest { | |||
// 计算电子印章组件signature值 | |||
String myData = data.toString(); | |||
System.out.println(myData); | |||
byte[] stream = data.toString().getBytes("UTF-8"); | |||
byte[] stream = data.toString().getBytes(StandardCharsets.UTF_8); | |||
// 签名数据,根据签名算法,对请求数据进行签名 | |||
String signature = sign(stream); | |||
//System.out.println(signature); | |||
@@ -137,7 +132,7 @@ public class IRSAPIRequest { | |||
InputStream in = res.getEntity().getContent(); | |||
byte[] resp = readStream(in); | |||
String strRes = new String(resp, "UTF-8"); | |||
String strRes = new String(resp, StandardCharsets.UTF_8); | |||
System.out.println(strRes); | |||
cli.close(); | |||
return strRes; | |||
@@ -148,7 +143,7 @@ public class IRSAPIRequest { | |||
Mac mac = Mac.getInstance("HmacSHA256"); | |||
// 获取安全密钥 | |||
Key secKey = new SecretKeySpec(IrsSealPlatformProperties.projectSecret.getBytes("UTF-8"), mac.getAlgorithm()); | |||
Key secKey = new SecretKeySpec(IrsSealPlatformProperties.projectSecret.getBytes(StandardCharsets.UTF_8), mac.getAlgorithm()); | |||
// 初始化 | |||
mac.init(secKey); | |||
@@ -166,7 +161,7 @@ public class IRSAPIRequest { | |||
Mac mac = Mac.getInstance("HmacSHA256"); | |||
// 获取安全密钥 | |||
Key secKey = new SecretKeySpec(IrsSealPlatformProperties.secretKey.getBytes("UTF-8"), mac.getAlgorithm()); | |||
Key secKey = new SecretKeySpec(IrsSealPlatformProperties.secretKey.getBytes(StandardCharsets.UTF_8), mac.getAlgorithm()); | |||
// 初始化 | |||
mac.init(secKey); | |||
@@ -180,7 +175,7 @@ public class IRSAPIRequest { | |||
} | |||
public static String binaryEncode(byte[] data) { | |||
final char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; | |||
final char[] hexDigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; | |||
StringBuilder builder = new StringBuilder(); | |||
@@ -198,14 +193,11 @@ public class IRSAPIRequest { | |||
byte[] buffer = new byte[1024 * 10]; | |||
try { | |||
int n = 0; | |||
int n; | |||
while ((n = in.read(buffer)) != -1) { | |||
output.write(buffer, 0, n); | |||
} | |||
return output.toByteArray(); | |||
} finally { | |||
in.close(); | |||
output.close(); | |||
@@ -221,10 +213,9 @@ public class IRSAPIRequest { | |||
* Create Date: 2015年8月3日 下午9:52:30 | |||
*/ | |||
public static String PDFToBase64(File file) { | |||
BASE64Encoder encoder = new BASE64Encoder(); | |||
FileInputStream fin = null; | |||
BufferedInputStream bin = null; | |||
ByteArrayOutputStream baos = null; | |||
ByteArrayOutputStream baos; | |||
BufferedOutputStream bout = null; | |||
try { | |||
fin = new FileInputStream(file); | |||
@@ -267,9 +258,9 @@ public class IRSAPIRequest { | |||
*/ | |||
public static void base64StringToPdf(String base64Content, String filePath) { | |||
BASE64Decoder decoder = new BASE64Decoder(); | |||
BufferedInputStream bis = null; | |||
FileOutputStream fos = null; | |||
BufferedOutputStream bos = null; | |||
BufferedInputStream bis; | |||
FileOutputStream fos; | |||
BufferedOutputStream bos; | |||
try { | |||
// base64编码内容转换为字节数组 | |||
@@ -300,7 +291,7 @@ public class IRSAPIRequest { | |||
private static String getCanonicalQueryString(String query) { | |||
if (query == null || query.trim().length() == 0) { | |||
if (query == null || query.trim().isEmpty()) { | |||
return ""; | |||
} | |||
List<Pair<String, String>> queryParamList = new ArrayList<>(); | |||
@@ -315,7 +306,7 @@ public class IRSAPIRequest { | |||
List<Pair<String, String>> sortedParamList = queryParamList.stream().sorted(Comparator.comparing(param -> param.getKey() + "=" + Optional.ofNullable(param.getValue()).orElse(""))).collect(Collectors.toList()); | |||
List<Pair<String, String>> encodeParamList = new ArrayList<>(); | |||
sortedParamList.stream().forEach(param -> { | |||
sortedParamList.forEach(param -> { | |||
try { | |||
String key = URLEncoder.encode(param.getKey(), "utf-8"); | |||
String value = URLEncoder.encode(Optional.ofNullable(param.getValue()).orElse(""), "utf-8").replaceAll("\\%2B", "%20").replaceAll("\\+", "%20").replaceAll("\\%21", "!").replaceAll("\\%27", "'").replaceAll("\\%28", "(").replaceAll("\\%29", ")").replaceAll("\\%7E", "~").replaceAll("\\%25", "%"); | |||
@@ -324,12 +315,13 @@ public class IRSAPIRequest { | |||
throw new RuntimeException("encoding error"); | |||
} | |||
}); | |||
StringBuilder queryParamString = new StringBuilder(64); | |||
StringBuilder queryParamString = new StringBuilder(); | |||
for (Pair<String, String> encodeParam : encodeParamList) { | |||
queryParamString.append(encodeParam.getKey()).append("=").append(Optional.ofNullable(encodeParam.getValue()).orElse("")); | |||
queryParamString.append("&"); | |||
} | |||
return queryParamString.substring(0, queryParamString.length() - 1); | |||
} | |||
} |
@@ -26,9 +26,8 @@ public class ExpertUserInfoHelperImpl implements ExpertUserInfoHelper { | |||
*/ | |||
@Override | |||
public ExpertUserFullInfo getExpertBasicFullInfo(Long expertUserId) { | |||
ExpertUserFullInfo one = iExpertUserFullInfoService | |||
return iExpertUserFullInfoService | |||
.getOne(Wrappers.lambdaQuery(ExpertUserFullInfo.class).eq(ExpertUserFullInfo::getUserId, expertUserId)); | |||
return one; | |||
} | |||
/** | |||
@@ -98,7 +98,7 @@ public class TagsCacheImpl extends AbstractTagsCache { | |||
private List<TagTreeDTO> treeToList(TagTreeDTO tagTreeDTO) { | |||
List<TagTreeDTO> result = new ArrayList<>(); | |||
result.add(tagTreeDTO); | |||
if (tagTreeDTO.getChildren() != null && tagTreeDTO.getChildren().size() > 0) { | |||
if (tagTreeDTO.getChildren() != null && !tagTreeDTO.getChildren().isEmpty()) { | |||
tagTreeDTO.getChildren().forEach(node -> { | |||
result.addAll(treeToList(node)); | |||
}); | |||
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; | |||
import com.alibaba.fastjson.JSON; | |||
import com.alibaba.fastjson.JSONArray; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.google.common.collect.Lists; | |||
import com.ningdatech.file.service.FileService; | |||
import com.ningdatech.pmapi.common.constant.BizConst; | |||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||
@@ -13,7 +14,6 @@ import com.ningdatech.pmapi.provincial.model.dto.ProvincialApplicationDTO; | |||
import com.ningdatech.pmapi.provincial.model.dto.ProvincialProjectDTO; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.assertj.core.util.Lists; | |||
import java.math.BigDecimal; | |||
import java.util.*; | |||
@@ -29,10 +29,10 @@ import java.util.stream.Collectors; | |||
public class ApplicationConverter { | |||
public static ProvincialProjectDTO convertProject(Project projectInfo, List<ProjectApplication> applications, | |||
FileService fileService,String active) { | |||
FileService fileService, String active) { | |||
return ProvincialProjectDTO.builder() | |||
//暂时先写死 | |||
.operationManageUnit(StringUtils.isBlank(active)|| BizConst.DEV.equals(active) ? | |||
.operationManageUnit(StringUtils.isBlank(active) || BizConst.DEV.equals(active) ? | |||
"GO_a1479720291640b4982158fe3035a2d0" : projectInfo.getHigherSuperOrgCode()) | |||
.digitalReform(String.valueOf(projectInfo.getBizDomain())) | |||
.regionCode(projectInfo.getAreaCode()) | |||
@@ -43,7 +43,7 @@ public class ApplicationConverter { | |||
.totalMoney(projectInfo.getDeclareAmount()) | |||
.yearBudget(projectInfo.getAnnualPlanAmount()) | |||
.budgetFrom(checkAddBudget(projectInfo.getDeclareHaveAmount() | |||
,projectInfo.getDeclareGovOwnFinanceAmount(), | |||
, projectInfo.getDeclareGovOwnFinanceAmount(), | |||
projectInfo.getDeclareGovSuperiorFinanceAmount(), | |||
projectInfo.getDeclareBankLendingAmount(), | |||
projectInfo.getDeclareOtherAmount())) | |||
@@ -53,64 +53,63 @@ public class ApplicationConverter { | |||
.beginTime(projectInfo.getBeginTime()) | |||
.endTime(projectInfo.getEndTime()) | |||
.buildBasis("立项依据") | |||
.buildBasisFile(convertBasicFile(projectInfo.getBuildBasis(),fileService)) | |||
.buildBasisFile(convertBasicFile(projectInfo.getBuildBasis(), fileService)) | |||
.projectSummary(projectInfo.getProjectIntroduction()) | |||
.responsibleMan(projectInfo.getResponsibleMan()) | |||
.responsibleManPhone(projectInfo.getResponsibleManMobile()) | |||
.contactName(projectInfo.getContactName()) | |||
.contactPhone(projectInfo.getContactPhone()) | |||
.buildUnit(projectInfo.getBuildOrgName()) | |||
.buildUnitCode(StringUtils.isBlank(active)|| BizConst.DEV.equals(active) ? | |||
.buildUnitCode(StringUtils.isBlank(active) || BizConst.DEV.equals(active) ? | |||
"GO_a1479720291640b4982158fe3035a2d0" : projectInfo.getBuildOrgCode()) | |||
.superUnit(projectInfo.getSuperOrg()) | |||
.superUnitCode(StringUtils.isBlank(active)|| BizConst.DEV.equals(active) ? | |||
.superUnitCode(StringUtils.isBlank(active) || BizConst.DEV.equals(active) ? | |||
"GO_a1479720291640b4982158fe3035a2d0" : projectInfo.getSuperOrgCode()) | |||
.projectEstimateFile(convertFile(projectInfo.getCalculationTotalInvestmentFile(),fileService)) | |||
.unitThreePlan(convertFile(projectInfo.getMainResponsibilitiesApplicantFile(),fileService)) | |||
.otherFile(convertFile(projectInfo.getPreliminaryPlanFile(),fileService)) | |||
.projectEstimateFile(convertFile(projectInfo.getCalculationTotalInvestmentFile(), fileService)) | |||
.unitThreePlan(convertFile(projectInfo.getMainResponsibilitiesApplicantFile(), fileService)) | |||
.otherFile(convertFile(projectInfo.getPreliminaryPlanFile(), fileService)) | |||
.projectRemark(projectInfo.getProjectRemarks()) | |||
.includeApplication(projectInfo.getIncludeApplication()) | |||
.isEffective(1) | |||
.projectApplyFile(convertFile(projectInfo.getProjectApplicationForm(),fileService)) | |||
.researchReport(convertFile(projectInfo.getPreliminaryPlanFile(),fileService)) | |||
.applicationInfo(convertApplications(applications,fileService)) | |||
.projectApplyFile(convertFile(projectInfo.getProjectApplicationForm(), fileService)) | |||
.researchReport(convertFile(projectInfo.getPreliminaryPlanFile(), fileService)) | |||
.applicationInfo(convertApplications(applications, fileService)) | |||
.build(); | |||
} | |||
private static String checkAddBudget(BigDecimal declareHaveAmount, BigDecimal declareGovOwnFinanceAmount, | |||
BigDecimal declareGovSuperiorFinanceAmount,BigDecimal declareBankLendingAmount, | |||
BigDecimal declareGovSuperiorFinanceAmount, BigDecimal declareBankLendingAmount, | |||
BigDecimal otherAmount) { | |||
StringBuffer sb = new StringBuffer(); | |||
StringBuilder sb = new StringBuilder(); | |||
if(Objects.nonNull(declareHaveAmount) && declareHaveAmount.compareTo(BigDecimal.ZERO) > 0){ | |||
if (Objects.nonNull(declareHaveAmount) && declareHaveAmount.compareTo(BigDecimal.ZERO) > 0) { | |||
sb.append("自有资金,"); | |||
} | |||
if(Objects.nonNull(declareGovOwnFinanceAmount) && declareGovOwnFinanceAmount.compareTo(BigDecimal.ZERO) > 0){ | |||
if (Objects.nonNull(declareGovOwnFinanceAmount) && declareGovOwnFinanceAmount.compareTo(BigDecimal.ZERO) > 0) { | |||
sb.append("政府投资-本级财政资金,"); | |||
} | |||
if(Objects.nonNull(declareGovSuperiorFinanceAmount) && declareGovSuperiorFinanceAmount.compareTo(BigDecimal.ZERO) > 0){ | |||
if (Objects.nonNull(declareGovSuperiorFinanceAmount) && declareGovSuperiorFinanceAmount.compareTo(BigDecimal.ZERO) > 0) { | |||
sb.append("政府投资-上级财政资金,"); | |||
} | |||
if(Objects.nonNull(declareBankLendingAmount) && declareBankLendingAmount.compareTo(BigDecimal.ZERO) > 0){ | |||
if (Objects.nonNull(declareBankLendingAmount) && declareBankLendingAmount.compareTo(BigDecimal.ZERO) > 0) { | |||
sb.append("银行贷款,"); | |||
} | |||
if(Objects.nonNull(otherAmount) && otherAmount.compareTo(BigDecimal.ZERO) > 0){ | |||
if (Objects.nonNull(otherAmount) && otherAmount.compareTo(BigDecimal.ZERO) > 0) { | |||
sb.append("其他资金"); | |||
} | |||
return sb.toString(); | |||
} | |||
//放入项目 app | |||
private static List<ProvincialApplicationDTO> convertApplications(List<ProjectApplication> applications | |||
,FileService fileService) { | |||
if(CollUtil.isEmpty(applications)){ | |||
Collections.emptyList(); | |||
private static List<ProvincialApplicationDTO> convertApplications(List<ProjectApplication> applications, | |||
FileService fileService) { | |||
if (CollUtil.isEmpty(applications)) { | |||
return Collections.emptyList(); | |||
} | |||
return applications.stream().map(app -> convertApp(app,fileService)).collect(Collectors.toList()); | |||
return applications.stream().map(app -> convertApp(app, fileService)).collect(Collectors.toList()); | |||
} | |||
private static ProvincialApplicationDTO convertApp(ProjectApplication projectApplication,FileService fileService) { | |||
private static ProvincialApplicationDTO convertApp(ProjectApplication projectApplication, FileService fileService) { | |||
return ProvincialApplicationDTO.builder() | |||
.clouds(convertCloud(projectApplication)) | |||
.isFirst(projectApplication.getIsFirst()) | |||
@@ -145,7 +144,7 @@ public class ApplicationConverter { | |||
.publishSide(projectApplication.getPublishSide()) | |||
.isS2(projectApplication.getIsAccountAppName()) | |||
.accountAppName(projectApplication.getAccountAppName()) | |||
.applicationEstimateFile(convertFile(projectApplication.getApplicationEstimateFile(),fileService)) | |||
.applicationEstimateFile(convertFile(projectApplication.getApplicationEstimateFile(), fileService)) | |||
.cooperativeUnit(projectApplication.getBizCooperateInfo()) | |||
.build(); | |||
} | |||
@@ -168,18 +167,19 @@ public class ApplicationConverter { | |||
}).collect(Collectors.toList()); | |||
return JSON.toJSONString(files); | |||
} catch (Exception e) { | |||
log.info("转换省局上传 文件出错 {}",e.getMessage()); | |||
log.info("转换省局上传 文件出错 {}", e.getMessage()); | |||
} | |||
return null; | |||
} | |||
/** | |||
* 去除掉 oss链接的超时时间 | |||
* | |||
* @param url | |||
* @return | |||
*/ | |||
private static String removeExpire(String url) { | |||
if(StringUtils.isNotBlank(url)){ | |||
if (StringUtils.isNotBlank(url)) { | |||
String s = "Expires"; | |||
return url.replaceAll("&?" + s + "=[^&]*&", StringUtils.EMPTY); | |||
} | |||
@@ -191,37 +191,37 @@ public class ApplicationConverter { | |||
try { | |||
List<FileDTO> files = Lists.newArrayList(); | |||
JSONArray jsonArrays = JSON.parseArray(applicationEstimateFile); | |||
jsonArrays.stream().forEach(json -> { | |||
jsonArrays.forEach(json -> { | |||
JSONObject fileJson = (JSONObject) JSON.toJSON(json); | |||
JSONArray fileList = fileJson.getJSONArray("fileList"); | |||
fileList.stream().forEach(f -> { | |||
fileList.forEach(f -> { | |||
JSONObject fJson = (JSONObject) JSON.toJSON(f); | |||
Long fileId = fJson.getLong("id"); | |||
String fileName = fJson.getString("originalFileName"); | |||
Map<Long, String> fileMap = fileService.findUrlById(Lists.newArrayList(fileId)); | |||
String url = fileMap.get(fileId); | |||
url = removeExpire(url); | |||
FileDTO file = new FileDTO(); | |||
file.setFileId(String.valueOf(fileId)); | |||
file.setFileName(fileName); | |||
file.setAccessUrl(url); | |||
files.add(file); | |||
Long fileId = fJson.getLong("id"); | |||
String fileName = fJson.getString("originalFileName"); | |||
Map<Long, String> fileMap = fileService.findUrlById(Lists.newArrayList(fileId)); | |||
String url = fileMap.get(fileId); | |||
url = removeExpire(url); | |||
FileDTO file = new FileDTO(); | |||
file.setFileId(String.valueOf(fileId)); | |||
file.setFileName(fileName); | |||
file.setAccessUrl(url); | |||
files.add(file); | |||
}); | |||
}); | |||
return JSON.toJSONString(files); | |||
} catch (Exception e) { | |||
log.info("转换省局上传 basic文件出错 {}",e.getMessage()); | |||
log.info("转换省局上传 basic文件出错 {}", e.getMessage()); | |||
} | |||
return null; | |||
} | |||
private static List<ProvincialApplicationDTO.Cloud> convertCloud(ProjectApplication projectApplication) { | |||
return Lists.newArrayList(ProvincialApplicationDTO.Cloud.builder() | |||
.cloudType(projectApplication.getCloudsType()) | |||
.cloudNums(projectApplication.getCloudsNumber()) | |||
.cloudBasicSpec(projectApplication.getCloudsFoundationSpecifications()) | |||
.cloudUseDescription(projectApplication.getCloudsDescription()) | |||
.build()); | |||
.cloudType(projectApplication.getCloudsType()) | |||
.cloudNums(projectApplication.getCloudsNumber()) | |||
.cloudBasicSpec(projectApplication.getCloudsFoundationSpecifications()) | |||
.cloudUseDescription(projectApplication.getCloudsDescription()) | |||
.build()); | |||
} | |||
} |