diff --git a/pmapi/pom.xml b/pmapi/pom.xml index a35fa48..9954d4d 100644 --- a/pmapi/pom.xml +++ b/pmapi/pom.xml @@ -128,7 +128,6 @@ org.springframework.boot spring-boot-starter-test - org.mapstruct @@ -141,7 +140,6 @@ java-jwt 3.10.3 - org.mapstruct mapstruct-processor @@ -203,10 +201,6 @@ com.ningdatech - nd-basic - - - com.ningdatech nd-irs-starter @@ -226,11 +220,6 @@ com.ningdatech nd-flowable-starter - - - - - com.alibaba.xxpt @@ -240,11 +229,6 @@ ${basedir}/src/lib/zwdd-sdk-java-1.2.0.jar - org.apache.httpcomponents - httpclient - - - joda-time joda-time diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/basic/AbstractRegionCacheHelper.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/basic/AbstractRegionCacheHelper.java index f23c5dc..4296134 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/basic/AbstractRegionCacheHelper.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/basic/AbstractRegionCacheHelper.java @@ -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; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java index 7dc75e0..e02c0dc 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java @@ -129,79 +129,72 @@ public class UserInfoHelperImpl implements UserInfoHelper { /** * 批量查询 这里 会没有角色 - * @param userInfos - * @return + * + * @param userInfos \ + * @return \ */ @Override public List getUserFullInfos(List userInfos) { - List res = Lists.newArrayList(); - - if(CollUtil.isEmpty(userInfos)){ - return res; + if (CollUtil.isEmpty(userInfos)) { + return Collections.emptyList(); } - - Map userMap = userInfos.stream().collect(Collectors.toMap(UserInfo::getEmployeeCode,e->e)); - + Map userMap = userInfos.stream().collect(Collectors.toMap(UserInfo::getEmployeeCode, e -> e)); // 获取浙政钉雇员信息 组织信息 List employeeCodes = userInfos.stream().map(UserInfo::getEmployeeCode).collect(Collectors.toList()); - if (CollUtil.isNotEmpty(employeeCodes)) { - List dingEmployeeInfoList = iDingEmployeeInfoService - .list(Wrappers.lambdaQuery(DingEmployeeInfo.class) - .in(DingEmployeeInfo::getEmployeeCode, employeeCodes) - .eq(DingEmployeeInfo::getMainJob, "true")); + List 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 empPosUnitCodes = dingEmployeeInfoList.stream().map(DingEmployeeInfo::getEmpPosUnitCode).collect(Collectors.toList()); - List orgCodes = dingEmployeeInfoList.stream().map(DingEmployeeInfo::getOrganizationCode).collect(Collectors.toList()); - List allOrgCodes = Stream.concat(empPosUnitCodes.stream(),orgCodes.stream()).collect(Collectors.toList()); - if (CollUtil.isEmpty(allOrgCodes)) { - return res; + // 装配用户任职所在单位 + List empPosUnitCodes = dingEmployeeInfoList.stream().map(DingEmployeeInfo::getEmpPosUnitCode).collect(Collectors.toList()); + List orgCodes = dingEmployeeInfoList.stream().map(DingEmployeeInfo::getOrganizationCode).collect(Collectors.toList()); + List allOrgCodes = Stream.concat(empPosUnitCodes.stream(), orgCodes.stream()).collect(Collectors.toList()); + if (CollUtil.isEmpty(allOrgCodes)) { + return Collections.emptyList(); + } + List dingOrganizations = iDingOrganizationService.listByCodes(allOrgCodes); + if (CollUtil.isEmpty(dingOrganizations)) { + return Collections.emptyList(); + } + Map 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 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 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 diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/util/ExcelDownUtil.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/util/ExcelDownUtil.java index 05e10b6..4d6fb17 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/util/ExcelDownUtil.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/util/ExcelDownUtil.java @@ -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; /** *

@@ -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> getTaskExportDatas(List columnList,List taskVoList, Map projectInfoMap) { + public static List> getTaskExportDatas(List columnList, List taskVoList, Map projectInfoMap) { // 表体行数据集合 List> rowList = Lists.newArrayList(); for (ExportOptionEnum column : columnList) { List 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> getInstExportDatas(List columnList,List instanceVoList, Map projectInfoMap) { + public static List> getInstExportDatas(List columnList, List instanceVoList, Map projectInfoMap) { // 表体行数据集合 List> rowList = Lists.newArrayList(); for (ExportOptionEnum column : columnList) { List 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> getProjectExportDatas(List columnList,List projects) { + public static List> getProjectExportDatas(List columnList, List projects) { // 表体行数据集合 List> rowList = Lists.newArrayList(); for (ExportOptionEnum column : columnList) { List 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 fileArray = JSON.parseArray(fileStr, JSONObject.class); List 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); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/util/Md5Utils.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/util/Md5Utils.java index 6254ec3..cc09421 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/util/Md5Utils.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/util/Md5Utils.java @@ -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; } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/util/SendWorkNoticeUtil.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/util/SendWorkNoticeUtil.java index 77b0b73..a213c7b 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/util/SendWorkNoticeUtil.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/util/SendWorkNoticeUtil.java @@ -40,7 +40,7 @@ public class SendWorkNoticeUtil { GenericResult 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)); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/irs/sign/IRSAPIRequest.java b/pmapi/src/main/java/com/ningdatech/pmapi/irs/sign/IRSAPIRequest.java index 4393846..fc7e84e 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/irs/sign/IRSAPIRequest.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/irs/sign/IRSAPIRequest.java @@ -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> queryParamList = new ArrayList<>(); @@ -315,7 +306,7 @@ public class IRSAPIRequest { List> sortedParamList = queryParamList.stream().sorted(Comparator.comparing(param -> param.getKey() + "=" + Optional.ofNullable(param.getValue()).orElse(""))).collect(Collectors.toList()); List> 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 encodeParam : encodeParamList) { queryParamString.append(encodeParam.getKey()).append("=").append(Optional.ofNullable(encodeParam.getValue()).orElse("")); queryParamString.append("&"); } - return queryParamString.substring(0, queryParamString.length() - 1); } + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meta/helper/ExpertUserInfoHelperImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/meta/helper/ExpertUserInfoHelperImpl.java index 63e2497..fa16617 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meta/helper/ExpertUserInfoHelperImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meta/helper/ExpertUserInfoHelperImpl.java @@ -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; } /** diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meta/helper/impl/TagsCacheImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/meta/helper/impl/TagsCacheImpl.java index 0781219..e6929e6 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meta/helper/impl/TagsCacheImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meta/helper/impl/TagsCacheImpl.java @@ -98,7 +98,7 @@ public class TagsCacheImpl extends AbstractTagsCache { private List treeToList(TagTreeDTO tagTreeDTO) { List 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)); }); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/converter/ApplicationConverter.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/converter/ApplicationConverter.java index 7413968..98213a8 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/converter/ApplicationConverter.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/converter/ApplicationConverter.java @@ -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 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 convertApplications(List applications - ,FileService fileService) { - if(CollUtil.isEmpty(applications)){ - Collections.emptyList(); + private static List convertApplications(List 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 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 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 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 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()); } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java index 95ec6b6..ee66831 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java @@ -1,65 +1,19 @@ package com.ningdatech.pmapi.todocenter.manage; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.*; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import javax.servlet.http.HttpServletResponse; - +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; +import cn.hutool.core.codec.Base64; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.ObjectUtil; -import com.ningdatech.basic.exception.BizException; -import com.ningdatech.pmapi.common.constant.RegionConst; -import com.ningdatech.pmapi.common.enumeration.CommonEnum; -import com.ningdatech.pmapi.performance.model.dto.ProjectCoreBusinessDTO; -import com.ningdatech.pmapi.performance.model.entity.ProjectCoreBusinessIndicators; -import com.ningdatech.pmapi.performance.service.IProjectCoreBusinessIndicatorsService; -import com.ningdatech.pmapi.projectlib.enumeration.*; -import com.ningdatech.pmapi.projectlib.model.dto.ProjectApplicationDTO; -import com.ningdatech.pmapi.sys.model.entity.Region; -import com.ningdatech.pmapi.sys.service.IRegionService; -import com.ningdatech.pmapi.todocenter.constant.TodoCenterConstant; -import com.ningdatech.pmapi.todocenter.handle.PassHandle; -import com.ningdatech.pmapi.todocenter.handle.WithDrawHandle; -import com.ningdatech.pmapi.todocenter.model.dto.*; -import com.ningdatech.pmapi.todocenter.model.vo.*; -import com.ningdatech.pmapi.todocenter.model.vo.TodoNumVO; -import com.ningdatech.pmapi.todocenter.service.ITodoService; -import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; -import com.wflow.contants.HisProInsEndActId; -import com.wflow.workflow.bean.dto.ReqAuditOpinionSaveDTO; -import com.wflow.workflow.bean.process.enums.NodeTypeEnum; -import com.wflow.workflow.utils.ProcessTaskUtils; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.StringUtils; -import org.assertj.core.util.Lists; -import org.flowable.bpmn.model.BpmnModel; -import org.flowable.bpmn.model.FlowElement; -import org.flowable.bpmn.model.FlowElementsContainer; -import org.flowable.bpmn.model.SubProcess; -import org.flowable.engine.HistoryService; -import org.flowable.engine.RepositoryService; -import org.flowable.engine.TaskService; -import org.flowable.engine.history.HistoricProcessInstance; -import org.flowable.task.api.Task; -import org.flowable.task.api.history.HistoricTaskInstance; -import org.flowable.variable.api.history.HistoricVariableInstance; -import org.springframework.beans.BeanUtils; -import org.springframework.mock.web.MockMultipartFile; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.multipart.MultipartFile; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; +import com.ningdatech.basic.exception.BizException; import com.ningdatech.basic.function.VUtils; import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.util.CollUtils; @@ -69,12 +23,19 @@ import com.ningdatech.file.entity.File; import com.ningdatech.file.entity.vo.result.FileResultVO; import com.ningdatech.file.service.FileService; import com.ningdatech.pmapi.common.constant.CommonConst; +import com.ningdatech.pmapi.common.constant.RegionConst; +import com.ningdatech.pmapi.common.enumeration.CommonEnum; import com.ningdatech.pmapi.common.helper.UserInfoHelper; import com.ningdatech.pmapi.common.model.entity.ExcelExportWriter; import com.ningdatech.pmapi.common.util.ExcelDownUtil; import com.ningdatech.pmapi.irs.sign.IRSAPIRequest; +import com.ningdatech.pmapi.performance.model.dto.ProjectCoreBusinessDTO; +import com.ningdatech.pmapi.performance.model.entity.ProjectCoreBusinessIndicators; +import com.ningdatech.pmapi.performance.service.IProjectCoreBusinessIndicatorsService; import com.ningdatech.pmapi.projectdeclared.manage.DefaultDeclaredProjectManage; +import com.ningdatech.pmapi.projectlib.enumeration.*; import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage; +import com.ningdatech.pmapi.projectlib.model.dto.ProjectApplicationDTO; import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO; import com.ningdatech.pmapi.projectlib.model.entity.Project; import com.ningdatech.pmapi.projectlib.model.entity.ProjectApplication; @@ -85,34 +46,74 @@ import com.ningdatech.pmapi.projectlib.service.IProjectInstService; import com.ningdatech.pmapi.projectlib.service.IProjectService; import com.ningdatech.pmapi.signature.entity.CompanySignature; import com.ningdatech.pmapi.signature.service.ICompanySignatureService; +import com.ningdatech.pmapi.sys.model.entity.Region; +import com.ningdatech.pmapi.sys.service.IRegionService; +import com.ningdatech.pmapi.todocenter.constant.TodoCenterConstant; import com.ningdatech.pmapi.todocenter.enumeration.IsAppendProjectEnum; import com.ningdatech.pmapi.todocenter.enumeration.IsOrNotEnum; +import com.ningdatech.pmapi.todocenter.handle.PassHandle; +import com.ningdatech.pmapi.todocenter.handle.WithDrawHandle; +import com.ningdatech.pmapi.todocenter.model.dto.AdjustHandleDTO; +import com.ningdatech.pmapi.todocenter.model.dto.PdfGenerateDTO; +import com.ningdatech.pmapi.todocenter.model.dto.SealInfoDTO; +import com.ningdatech.pmapi.todocenter.model.dto.SignReqDTO; import com.ningdatech.pmapi.todocenter.model.po.TodoCenterStatisticsPO; import com.ningdatech.pmapi.todocenter.model.req.ProcessDetailReq; import com.ningdatech.pmapi.todocenter.model.req.ToBeProcessedExportReq; import com.ningdatech.pmapi.todocenter.model.req.ToBeProcessedReq; +import com.ningdatech.pmapi.todocenter.model.vo.*; +import com.ningdatech.pmapi.todocenter.service.ITodoService; import com.ningdatech.pmapi.todocenter.service.StatisticsService; import com.ningdatech.pmapi.todocenter.utils.BuildUserUtils; import com.ningdatech.pmapi.todocenter.utils.PdfUtils; import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; +import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; import com.ningdatech.pmapi.user.util.LoginUserUtil; +import com.wflow.contants.HisProInsEndActId; import com.wflow.exception.BusinessException; +import com.wflow.workflow.bean.dto.ReqAuditOpinionSaveDTO; import com.wflow.workflow.bean.dto.ReqProcessHandlerDTO; import com.wflow.workflow.bean.dto.TodoCenterListReqDTO; import com.wflow.workflow.bean.process.ProgressNode; +import com.wflow.workflow.bean.process.enums.NodeTypeEnum; import com.wflow.workflow.bean.vo.ProcessInstanceVo; import com.wflow.workflow.bean.vo.ProcessProgressVo; import com.wflow.workflow.bean.vo.ProcessTaskVo; import com.wflow.workflow.service.ProcessInstanceService; import com.wflow.workflow.service.ProcessTaskService; -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.codec.Base64; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; +import com.wflow.workflow.utils.ProcessTaskUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; +import org.flowable.bpmn.model.BpmnModel; +import org.flowable.bpmn.model.FlowElement; +import org.flowable.bpmn.model.FlowElementsContainer; +import org.flowable.bpmn.model.SubProcess; +import org.flowable.engine.HistoryService; +import org.flowable.engine.RepositoryService; +import org.flowable.engine.TaskService; +import org.flowable.engine.history.HistoricProcessInstance; +import org.flowable.task.api.Task; +import org.flowable.task.api.history.HistoricTaskInstance; +import org.flowable.variable.api.history.HistoricVariableInstance; +import org.springframework.beans.BeanUtils; +import org.springframework.mock.web.MockMultipartFile; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; import sun.misc.BASE64Decoder; +import javax.servlet.http.HttpServletResponse; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; + /** * @author ZPF * @since 2023/02/19 16:09 @@ -155,16 +156,16 @@ public class TodoCenterManage { */ public PageVo todoProjectList(ToBeProcessedReq param) { String employeeCode = param.getEmployeeCode(); - if(StringUtils.isBlank(employeeCode)){ + if (StringUtils.isBlank(employeeCode)) { // 获取登录用户ID Long userId = Optional.ofNullable(param.getLoginUserId()).orElseGet(LoginUserUtil::getUserId); // 获取登录用户全量信息 UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); // 获取员工浙政钉code - if(Objects.nonNull(userFullInfo)){ + if (Objects.nonNull(userFullInfo)) { employeeCode = userFullInfo.getEmployeeCode(); } - if(StringUtils.isBlank(employeeCode)){ + if (StringUtils.isBlank(employeeCode)) { return PageVo.empty(); } } @@ -173,7 +174,7 @@ public class TodoCenterManage { ProjectListReq projectListReq = new ProjectListReq(); BeanUtils.copyProperties(param, projectListReq); List projects = projectLibManage.projectList(projectListReq); - if(CollUtil.isEmpty(projects)){ + if (CollUtil.isEmpty(projects)) { return PageVo.empty(); } Map projectsMap = projects.stream().collect(Collectors.toMap(Project::getId, v -> v)); @@ -183,9 +184,9 @@ public class TodoCenterManage { List projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) .in(ProjectInst::getProjectId, projectIdList) .orderByDesc(ProjectInst::getProjectId)); - Map projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p-> projectsMap.get(p.getProjectId()))); + Map projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p -> projectsMap.get(p.getProjectId()))); List instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); - if(CollUtil.isEmpty(instCodes)){ + if (CollUtil.isEmpty(instCodes)) { return PageVo.empty(); } // 查出用户工作流 @@ -200,10 +201,9 @@ public class TodoCenterManage { //有退回待办的 List backList = processTaskService.getBackTodoList(req); //合并 并且排序 - List list = Stream.concat(todoList.stream(),backList.stream()) + List list = Stream.concat(todoList.stream(), backList.stream()) .filter(Objects::nonNull) - .sorted(Comparator.comparing(ProcessTaskVo::getTaskCreateTime) - .reversed()) + .sorted(Comparator.comparing(ProcessTaskVo::getTaskCreateTime).reversed()) .collect(Collectors.toList()); if (CollUtil.isEmpty(list)) { @@ -217,13 +217,12 @@ public class TodoCenterManage { Set processSet = Sets.newHashSet(); Map taskMap = userTodoList.stream() - .sorted((t1,t2) -> t2.getTaskCreateTime().compareTo(t1.getTaskCreateTime())) + .sorted((t1, t2) -> t2.getTaskCreateTime().compareTo(t1.getTaskCreateTime())) .collect(Collectors.toList()).stream() .filter(v -> processSet.add(v.getNodeId())) .collect(Collectors.toMap(ProcessTaskVo::getNodeId, v -> v)); - List resVos = userTodoList.stream().map(d -> { Project projectInfo = projectInfoMap.get(d.getInstanceId()); ResToBeProcessedVO res = new ResToBeProcessedVO(); @@ -246,15 +245,15 @@ public class TodoCenterManage { } private String findSubProcessName(ProcessTaskVo d) { - if(StringUtils.isBlank(d.getProcessDefId())){ + if (StringUtils.isBlank(d.getProcessDefId())) { return null; } BpmnModel bpmnModel = repositoryService.getBpmnModel(d.getProcessDefId()); - if(Objects.nonNull(bpmnModel)){ + if (Objects.nonNull(bpmnModel)) { FlowElement flowElement = bpmnModel.getFlowElement(d.getTaskDefKey()); FlowElementsContainer parentContainer = flowElement.getParentContainer(); - if(parentContainer instanceof SubProcess){ + if (parentContainer instanceof SubProcess) { return ((SubProcess) parentContainer).getName(); } } @@ -264,9 +263,8 @@ public class TodoCenterManage { /** * 待办中心列表导出 * - * @param response - * @param param - * @return void + * @param response \ + * @param param \ * @author CMM * @since 2023/02/01 */ @@ -286,16 +284,14 @@ public class TodoCenterManage { BeanUtils.copyProperties(param, projectListReq); List projects = projectLibManage.projectList(projectListReq); if (CollUtil.isNotEmpty(projects)) { - Map projectsMap = projects.stream().collect(Collectors.toMap(Project::getId, v -> v)); + Map projectsMap = CollUtils.listToMap(projects, Project::getId); // 再查出项目关联的流程实例ID List projectIdList = projects.stream().map(Project::getId).collect(Collectors.toList()); List projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) .in(ProjectInst::getProjectId, projectIdList).orderByDesc(ProjectInst::getProjectId)); - projectInfoMap = projectInstList.stream() - .collect(Collectors.toMap(ProjectInst::getInstCode, p -> projectsMap.get(p.getProjectId()))); + projectInstList.forEach(p -> projectInfoMap.put(p.getInstCode(), projectsMap.get(p.getProjectId()))); List instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); - // 查出用户工作流 TodoCenterListReqDTO req = new TodoCenterListReqDTO(); req.setInstCodes(instCodes); @@ -307,8 +303,11 @@ public class TodoCenterManage { // 有退回待办的 List backList = processTaskService.getBackTodoList(req); // 合并 并且排序 - userTodoList = Stream.concat(todoList.stream(), backList.stream()).filter(Objects::nonNull) - .sorted(Comparator.comparing(ProcessTaskVo::getTaskCreateTime).reversed()).collect(Collectors.toList()); + Stream.of(todoList, backList) + .flatMap(Collection::stream) + .filter(Objects::nonNull) + .sorted(Comparator.comparing(ProcessTaskVo::getTaskCreateTime).reversed()) + .forEach(userTodoList::add); } ExcelExportWriter excelExportWriter = new ExcelExportWriter(); String fileName = null; @@ -371,8 +370,8 @@ public class TodoCenterManage { switch (param.getAction()) { // 通过 case PASS: - // 盖章并通过 - case SEAL_PASS: + // 盖章并通过 + case SEAL_PASS: { //前置判断前端传的taskId是否存在不存在的情况 有可能是 或签被别人审批掉了 Task task = taskService.createTaskQuery().taskId(param.getTaskId()).active().singleResult(); if (ObjectUtil.isNull(task)) { @@ -382,52 +381,53 @@ public class TodoCenterManage { // 通过该任务,流程到下一审核人处 processTaskService.handleTask(param, employeeCode); //通过审核后 所处理的逻辑 - handlerManage.afterPassTodo(declaredProject,instance); + handlerManage.afterPassTodo(declaredProject, instance); - return findNextTaskId(instance,employeeCode,nodeId,param.getTaskId()); + return findNextTaskId(instance, employeeCode, nodeId, param.getTaskId()); + } // 驳回 - case REJECT: + case REJECT: { //前置判断前端传的taskId是否存在不存在的情况 有可能是 或签被别人审批掉了 - task = taskService.createTaskQuery().taskId(param.getTaskId()).active().singleResult(); + Task task = taskService.createTaskQuery().taskId(param.getTaskId()).active().singleResult(); if (ObjectUtil.isNull(task)) { return TodoCenterConstant.Handler.TASKID_ERROR; } - nodeId = task.getTaskDefinitionKey(); // 驳回该任务,中止流程并使项目进入对应状态,给项目创建人、流程发起人发送浙政钉工作通知: // 【项目名称】的【流程名称】被驳回,请及时处理。 processTaskService.handleTask(param, employeeCode); //驳回审核后 所处理的逻辑 - handlerManage.afterRejectTodo(declaredProject,instance); - break; + handlerManage.afterRejectTodo(declaredProject, instance); + } + break; // 退回 - case BACK: + case BACK: { //前置判断前端传的taskId是否存在不存在的情况 有可能是 或签被别人审批掉了 - task = taskService.createTaskQuery().taskId(param.getTaskId()).active().singleResult(); + Task task = taskService.createTaskQuery().taskId(param.getTaskId()).active().singleResult(); if (ObjectUtil.isNull(task)) { return TodoCenterConstant.Handler.TASKID_ERROR; } - nodeId = task.getTaskDefinitionKey(); // 退回该任务 processTaskService.handleTaskLs(param, employeeCode); //退回审核后 所处理的逻辑 - handlerManage.afterBackTodo(declaredProject,instance); - break; + handlerManage.afterBackTodo(declaredProject, instance); + } + break; // 撤回(流程发起人和当前流程审核人的前一个审核人操作) - case WITHDRAW: + case WITHDRAW: { /** * 新逻辑 * 不判断前端传的taskId * 1.先判断 用户是否是ROOT 发起人 并且流程没有开始审批 */ - if(withDrawHandle.canRootWithDraw(instance,employeeCode)){ + if (withDrawHandle.canRootWithDraw(instance, employeeCode)) { // 登录用户是流程发起人,且是流程发起人撤回 processTaskService.rootWithdrawTask(param, employeeCode); //发起人撤回 handlerManage.rootWithDraw(declaredProject); - }else{ + } else { // 2.如果用户不是ROOT发起人 或者 不满足root撤回 那么必定要判断 他是不是上个节点审批人 或者 当前会签已审批的审批人 // 这里有个小操作 check的同时 把对应的操作人的taskId 也塞入 - VUtils.isTrue(!withDrawHandle.checkUserIsBefore(currentInstanceDetail.getProgressInfo(),param)) + VUtils.isTrue(!withDrawHandle.checkUserIsBefore(currentInstanceDetail.getProgressInfo(), param)) .throwMessage("当前登录用户不是发起人,也不是上一个节点审批人或者当前会签已批审批人 无法进行撤回操作!"); //前置判断前端传的taskId是否存在不存在的情况 有可能是 或签被别人审批掉了 @@ -435,14 +435,14 @@ public class TodoCenterManage { if (ObjectUtil.isNull(taskInst)) { return TodoCenterConstant.Handler.TASKID_ERROR; } - nodeId = taskInst.getTaskDefinitionKey(); - + String nodeId = taskInst.getTaskDefinitionKey(); //上个审批人处理逻辑 processTaskService.lastWithdrawTask(param); - return findNextTaskId(instance,employeeCode,nodeId,param.getTaskId()); + return findNextTaskId(instance, employeeCode, nodeId, param.getTaskId()); } - break; + } + break; default: throw new IllegalStateException("Unexpected value: " + param.getAction()); } @@ -489,7 +489,7 @@ public class TodoCenterManage { CompanySignature companySignature = companySignatureService.getOne(Wrappers.lambdaQuery(CompanySignature.class) .eq(CompanySignature::getOrganizationCode, userFullInfo.getEmpPosUnitCode())); sealSn = companySignature.getSealSn(); - }else { + } else { // 区县预审时,对有上级条线主管单位并进行了盖章的情况,需要根据上次的印章编号再次盖章 sealSn = req.getSealSn(); } @@ -512,8 +512,8 @@ public class TodoCenterManage { } } inputStream = new ByteArrayInputStream(b); - }catch (Exception e){ - + } catch (Exception e) { + log.error("获取盖章后的pdf文件异常:", e); } } // 转换成MultipartFile @@ -553,25 +553,25 @@ public class TodoCenterManage { String nodeId = request.getNodeId(); Long projectId = request.getProjectId(); String taskId = request.getTaskId(); - ProcessProgressVo progressInstanceDetail = processInstanceService.getProgressInstanceDetail(nodeId, instanceId,taskId); + ProcessProgressVo progressInstanceDetail = processInstanceService.getProgressInstanceDetail(nodeId, instanceId, taskId); - if(Objects.isNull(progressInstanceDetail)){ + if (Objects.isNull(progressInstanceDetail)) { return null; } List progressInfo = progressInstanceDetail.getProgressInfo(); Boolean isHighLine = Boolean.FALSE; - if (CollUtil.isNotEmpty(progressInfo)){ + if (CollUtil.isNotEmpty(progressInfo)) { buildUserUtils.buildUserByProcessInfo(progressInfo); - isHighLine = checkHighLine(progressInfo,taskId,LoginUserUtil.loginUserDetail()); + isHighLine = checkHighLine(progressInfo, taskId, LoginUserUtil.loginUserDetail()); } ProcessProgressDetailVo res = new ProcessProgressDetailVo(); res.setProcessProgressVo(progressInstanceDetail); res.setStatus(progressInstanceDetail.getStatus()); res.setProjectId(projectId); - res.setCanWithdraw(withDrawHandle.checkCanWithdraw(instanceId,progressInstanceDetail,request.getTaskId())); + res.setCanWithdraw(withDrawHandle.checkCanWithdraw(instanceId, progressInstanceDetail, request.getTaskId())); res.setIsHighLine(isHighLine); - passHandle.checkCanPassOrSeal(request.getInstanceId(),request.getTaskId(),employeeCode,res); + passHandle.checkCanPassOrSeal(request.getInstanceId(), request.getTaskId(), employeeCode, res); //是不是被 驳回|退回 res.setIsChange(todoService.isChangeRecord(projectId)); return res; @@ -579,39 +579,39 @@ public class TodoCenterManage { /** * 筛选 当前登录人 是不是 上级条线单位的审批 + * * @param progressInfo * @param taskId * @param user * @return */ private Boolean checkHighLine(List progressInfo, String taskId, UserInfoDetails user) { - if(CollUtil.isEmpty(progressInfo)){ + if (CollUtil.isEmpty(progressInfo)) { return Boolean.FALSE; } final Boolean[] res = {Boolean.FALSE}; progressInfo.forEach(p -> { //如果是 子流程 - if(Objects.nonNull(p.getNodeType()) && NodeTypeEnum.SUB.name().equals(p.getNodeType().name())){ + if (Objects.nonNull(p.getNodeType()) && NodeTypeEnum.SUB.name().equals(p.getNodeType().name())) { //如果不是上级条线单位 根本不用理 - if(!p.getIsHighLine()){ + if (!p.getIsHighLine()) { return; } List children = p.getChildren(); ProgressNode progressNode = children.get(0); String userId = progressNode.getUserId(); - if(StringUtils.isBlank(userId)){ + if (StringUtils.isBlank(userId)) { return; } UserFullInfoDTO userFullInfoDTO = userInfoHelper.getUserFullInfoByEmployeeCode(userId); - if(Objects.nonNull(userFullInfoDTO) && user.getEmpPosUnitCode() - .equals(userFullInfoDTO.getEmpPosUnitCode())){ + if (Objects.nonNull(userFullInfoDTO) && user.getEmpPosUnitCode() + .equals(userFullInfoDTO.getEmpPosUnitCode())) { //说明是此单位的人 //那么要去看 taskId 是不是 在这个单位内的任务 - Boolean isContainsTask = HandlerManage.checkIsContainsTask(children,taskId); - if(isContainsTask){ - res[0] = Boolean.TRUE; - return; + Boolean isContainsTask = HandlerManage.checkIsContainsTask(children, taskId); + if (isContainsTask) { + res[0] = Boolean.TRUE; } } } @@ -649,7 +649,7 @@ public class TodoCenterManage { List projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) .in(ProjectInst::getProjectId, projectIdList) .orderByDesc(ProjectInst::getProjectId)); - Map projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p-> projectsMap.get(p.getProjectId()))); + Map projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p -> projectsMap.get(p.getProjectId()))); List instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); // 查出用户工作流 @@ -720,7 +720,7 @@ public class TodoCenterManage { List projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) .in(ProjectInst::getProjectId, projectIdList) .orderByDesc(ProjectInst::getProjectId)); - projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p-> projectsMap.get(p.getProjectId()))); + projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p -> projectsMap.get(p.getProjectId()))); List instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); // 查出用户工作流 @@ -789,7 +789,7 @@ public class TodoCenterManage { List projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) .in(ProjectInst::getProjectId, projectIdList) .orderByDesc(ProjectInst::getProjectId)); - Map projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p-> projectsMap.get(p.getProjectId()))); + Map projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p -> projectsMap.get(p.getProjectId()))); List instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); // 查出用户工作流 @@ -823,7 +823,7 @@ public class TodoCenterManage { res.setProcessLaunchTime(d.getStartTime()); return res; }).collect(Collectors.toList()); - return PageVo.of(resVos,submittedList.size()); + return PageVo.of(resVos, submittedList.size()); } /** @@ -858,7 +858,7 @@ public class TodoCenterManage { List projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) .in(ProjectInst::getProjectId, projectIdList) .orderByDesc(ProjectInst::getProjectId)); - projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p-> projectsMap.get(p.getProjectId()))); + projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p -> projectsMap.get(p.getProjectId()))); List instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); // 查出用户工作流 @@ -928,7 +928,7 @@ public class TodoCenterManage { List projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) .in(ProjectInst::getProjectId, projectIdList) .orderByDesc(ProjectInst::getProjectId)); - Map projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p-> projectsMap.get(p.getProjectId()))); + Map projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p -> projectsMap.get(p.getProjectId()))); List instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); // 查出用户工作流 @@ -998,7 +998,7 @@ public class TodoCenterManage { List projectInstList = projectInstService.list(Wrappers.lambdaQuery(ProjectInst.class) .in(ProjectInst::getProjectId, projectIdList) .orderByDesc(ProjectInst::getProjectId)); - projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p-> projectsMap.get(p.getProjectId()))); + projectInfoMap = projectInstList.stream().collect(Collectors.toMap(ProjectInst::getInstCode, p -> projectsMap.get(p.getProjectId()))); List instCodes = projectInstList.stream().map(ProjectInst::getInstCode).collect(Collectors.toList()); // 分页查出用户工作流 @@ -1038,6 +1038,7 @@ public class TodoCenterManage { /** * 被退回项目内容调整并重新通过 + * * @param dto * @return */ @@ -1050,15 +1051,15 @@ public class TodoCenterManage { //项目名称去重 //项目名称去重 - if(StringUtils.isNotBlank(projectDto.getProjectName()) && - !projectDto.getProjectName().equals(projectInfo.getProjectName())){ + if (StringUtils.isNotBlank(projectDto.getProjectName()) && + !projectDto.getProjectName().equals(projectInfo.getProjectName())) { defaultDeclaredProjectManage.checkDuplication(projectDto); } projectDto.setProjectCode(projectInfo.getProjectCode()); defaultDeclaredProjectManage.checkAmount(projectDto); //修改项目内容 - if(!modifyProject(projectDto,projectInfo)){ + if (!modifyProject(projectDto, projectInfo)) { throw new BusinessException("调整项目失败!"); } @@ -1078,17 +1079,18 @@ public class TodoCenterManage { /** * 要改成 生成新版本号 + * * @param projectDto * @return */ - private Boolean modifyProject(ProjectDTO projectDto,Project oldProject) { + private Boolean modifyProject(ProjectDTO projectDto, Project oldProject) { //先修改项目信息 Project project = new Project(); VUtils.isTrue(Objects.isNull(oldProject)) .throwMessage("项目不存在!"); - BeanUtil.copyProperties(oldProject,project, CopyOptions.create() + BeanUtil.copyProperties(oldProject, project, CopyOptions.create() .setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE)); - BeanUtil.copyProperties(projectDto,project, CopyOptions.create() + BeanUtil.copyProperties(projectDto, project, CopyOptions.create() .setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE)); project.setVersion(oldProject.getVersion() + 1); project.setId(null); @@ -1113,9 +1115,9 @@ public class TodoCenterManage { projectInstService.save(newPi); projectService.update(Wrappers.lambdaUpdate(Project.class) - .set(Project::getNewest,Boolean.FALSE) - .ne(Project::getId,project.getId()) - .eq(Project::getProjectCode,project.getProjectCode())); + .set(Project::getNewest, Boolean.FALSE) + .ne(Project::getId, project.getId()) + .eq(Project::getProjectCode, project.getProjectCode())); //再修改应用信息 Boolean isApp = Objects.nonNull(projectDto.getIncludeApplication()) && 1 == projectDto.getIncludeApplication() @@ -1131,10 +1133,10 @@ public class TodoCenterManage { projectApplicationService.removeBatchByIds(applicationList); List applicationIds = applicationList.stream().map(ProjectApplication::getId).collect(Collectors.toList()); projectCoreBusinessIndicatorsService.remove(Wrappers.lambdaQuery(ProjectCoreBusinessIndicators.class) - .in(ProjectCoreBusinessIndicators::getApplicationId,applicationIds)); + .in(ProjectCoreBusinessIndicators::getApplicationId, applicationIds)); List applications = projectDto.getApplicationList(); - if(isApp && CollUtil.isNotEmpty(applications)){ + if (isApp && CollUtil.isNotEmpty(applications)) { // 添加应用关联的核心业务 for (ProjectApplicationDTO application : applications) { ProjectApplication projectApplication = new ProjectApplication(); @@ -1167,6 +1169,7 @@ public class TodoCenterManage { /** * 获取未盖章的预审申请单/建设方案申请单pdf文件 + * * @param req * @return java.lang.Long * @author CMM @@ -1194,10 +1197,10 @@ public class TodoCenterManage { Long pretrialFileId = project.getPretrialFileId(); Region region = regionService.getOne(Wrappers.lambdaQuery(Region.class) .eq(Region::getRegionCode, areaCode) - .eq(Region::getRegionName,areaName)); + .eq(Region::getRegionName, areaName)); VUtils.isTrue(Objects.isNull(region)).throwMessage("项目所属区域不存在!"); Integer regionLevel = region.getRegionLevel(); - if (CommonEnum.LS_SBJ.getDesc().equals(areaName)){ + if (CommonEnum.LS_SBJ.getDesc().equals(areaName)) { regionLevel = RegionConst.RL_CITY; } // 获取项目申报时是否选择了主管单位和上级条线主管单位 @@ -1216,9 +1219,9 @@ public class TodoCenterManage { } String cityTemplateName = TodoCenterConstant.SealTemplate.CITY_TEMPLATE; // 设置pdf模板参数 - JSONObject cityParamsMap = assemblyPdfParams(project,cityTemplateName); + JSONObject cityParamsMap = assemblyPdfParams(project, cityTemplateName); // 盖章审核为主管单位审核 - if (CommonEnum.YES.getCode().equals(isSuperOrg)){ + if (CommonEnum.YES.getCode().equals(isSuperOrg)) { // 有主管单位信息且登录用户所在单位是主管单位 checkEmpPosUnitCode(empPosUnitCode, auditOpinion, auditDate, superOrgCode, cityParamsMap); } else if (CommonEnum.NO.getCode().equals(isSuperOrg)) { @@ -1243,7 +1246,7 @@ public class TodoCenterManage { // 有上级条线主管单位信息且登录用户所在单位是上级条线主管单位, // 如果项目关联的预审文件ID和上级条线审核意见不为空,说明已经提交过审核意见,直接返回文件ID if (Boolean.TRUE.equals(getCountryHigherNotSealedInfoVO(pretrialFileId, notSealedInfoVo, - project.getCountryHigherSealAuditOpinion()))){ + project.getCountryHigherSealAuditOpinion()))) { return notSealedInfoVo; } countryParamsMap.put("higherOrgOpinion", auditOpinion); @@ -1273,32 +1276,32 @@ public class TodoCenterManage { // 装配本级主管单位审核意见 // 如果项目关联的预审文件ID和上级条线审核意见以及区县审核意见不为空,说明已经提交过审核意见,直接返回文件ID if (Boolean.TRUE.equals(getCountryNotSealedInfoVO(pretrialFileId, notSealedInfoVo, - project.getCountryHigherSealAuditOpinion(),project.getCountrySealAuditOpinion()))){ + project.getCountryHigherSealAuditOpinion(), project.getCountrySealAuditOpinion()))) { return notSealedInfoVo; } // 保存区县本级主管单位盖章审核意见、审核日期 project.setCountrySealAuditOpinion(auditOpinion); project.setCountrySealAuditDate(auditDate); projectService.updateById(project); - checkEmpPosUnitCode(empPosUnitCode,auditOpinion,auditDate,superOrgCode,countryParamsMap); + checkEmpPosUnitCode(empPosUnitCode, auditOpinion, auditDate, superOrgCode, countryParamsMap); // 装配上级条线主管单位意见,调用盖章接口, // 重新生成上级条线主管单位盖章而本级主管单位未盖章的pdf文件 SealInfoDTO sealInfoDTO = getHigherSealInfoDTO(project, countryParamsMap); Long notSealedPdfId = generateNotSealedPdf(projectId, countryTemplateName, countryParamsMap); notSealedId = generateSealedPdf(sealInfoDTO, project, countryTemplateName, notSealedPdfId); - }else if (CommonEnum.NO.getCode().equals(isSuperOrg)) { + } else if (CommonEnum.NO.getCode().equals(isSuperOrg)) { // 有上级条线主管单位信息,没有本级主管单位信息 // 没有选主管单位,默认为项目建设单位且登录用户所在单位为项目建设单位 // 如果项目关联的预审文件ID和上级条线审核意见以及区县审核意见不为空,说明已经提交过审核意见,直接返回文件ID if (Boolean.TRUE.equals(getCountryNotSealedInfoVO(pretrialFileId, notSealedInfoVo, - project.getCountryHigherSealAuditOpinion(),project.getCountrySealAuditOpinion()))){ + project.getCountryHigherSealAuditOpinion(), project.getCountrySealAuditOpinion()))) { return notSealedInfoVo; } // 保存区县本级主管单位盖章审核意见、审核日期 project.setCountrySealAuditOpinion(auditOpinion); project.setCountrySealAuditDate(auditDate); projectService.updateById(project); - checkEmpPosUnitCode(empPosUnitCode,auditOpinion,auditDate,buildOrgCode,countryParamsMap); + checkEmpPosUnitCode(empPosUnitCode, auditOpinion, auditDate, buildOrgCode, countryParamsMap); // 装配上级条线主管单位意见,调用盖章接口, // 重新生成上级条线主管单位盖章而本级主管单位未盖章的pdf文件 SealInfoDTO sealInfoDTO = getHigherSealInfoDTO(project, countryParamsMap); @@ -1315,7 +1318,7 @@ public class TodoCenterManage { // 有本级主管单位信息 if (CommonEnum.YES.getCode().equals(isSuperOrg)) { // 登录用户所在单位是本级主管单位,装配本级主管单位审核意见 - checkEmpPosUnitCode(empPosUnitCode,auditOpinion,auditDate,superOrgCode,countryParamsMap); + checkEmpPosUnitCode(empPosUnitCode, auditOpinion, auditDate, superOrgCode, countryParamsMap); // 直接返回装配了本级主管单位审核意见的未盖章文件 countryParamsMap.put("higherOrgOpinion", null); countryParamsMap.put("higherOrgAuditDate", null); @@ -1324,7 +1327,7 @@ public class TodoCenterManage { // 没有选主管单位,默认为项目建设单位 else if (CommonEnum.NO.getCode().equals(isSuperOrg)) { // 登录用户所在单位为项目建设单位 - checkEmpPosUnitCode(empPosUnitCode,auditOpinion,auditDate,buildOrgCode,countryParamsMap); + checkEmpPosUnitCode(empPosUnitCode, auditOpinion, auditDate, buildOrgCode, countryParamsMap); // 直接返回装配了项目建设单位审核意见的未盖章文件 countryParamsMap.put("higherOrgOpinion", null); countryParamsMap.put("higherOrgAuditDate", null); @@ -1339,7 +1342,7 @@ public class TodoCenterManage { } } // 如果为建设方案申报审批 - else if (InstTypeEnum.CONSTRUCTION_PLAN_REVIEW.getCode().equals(instType)){ + else if (InstTypeEnum.CONSTRUCTION_PLAN_REVIEW.getCode().equals(instType)) { Long constructFileId = project.getConstructFileId(); // 如果项目关联的建设方案文件ID不为空,说明已经提交过审核意见,直接返回文件ID if (Boolean.TRUE.equals(getCityNotSealedInfoVO(constructFileId, notSealedInfoVo))) { @@ -1350,8 +1353,8 @@ public class TodoCenterManage { JSONObject constructParamsMap = assemblyPdfParams(project, constructTemplateName); // 审核为指定大数据局盖章 // 获取流程配置的指定单位信息 - constructParamsMap.put("bigDataBureauOpinion",auditOpinion); - constructParamsMap.put("bigDataBureauAuditDate",auditDate); + constructParamsMap.put("bigDataBureauOpinion", auditOpinion); + constructParamsMap.put("bigDataBureauAuditDate", auditDate); Long constructNotFileId = generateNotSealedPdf(projectId, constructTemplateName, constructParamsMap); notSealedInfoVo.setFileId(constructNotFileId); checkAuditOpinion(auditOpinion, notSealedInfoVo); @@ -1366,8 +1369,8 @@ public class TodoCenterManage { } } - private Boolean getCityNotSealedInfoVO(Long fileId,NotSealedInfoVO notSealedInfoVo) { - if (Objects.nonNull(fileId)){ + private Boolean getCityNotSealedInfoVO(Long fileId, NotSealedInfoVO notSealedInfoVo) { + if (Objects.nonNull(fileId)) { notSealedInfoVo.setFileId(fileId); notSealedInfoVo.setIsCommit(Boolean.TRUE); return true; @@ -1376,7 +1379,7 @@ public class TodoCenterManage { } private Boolean getCountryHigherNotSealedInfoVO(Long fileId, NotSealedInfoVO notSealedInfoVo, String auditOpinion) { - if (Objects.nonNull(fileId) && StringUtils.isNotBlank(auditOpinion)){ + if (Objects.nonNull(fileId) && StringUtils.isNotBlank(auditOpinion)) { notSealedInfoVo.setFileId(fileId); notSealedInfoVo.setIsCommit(Boolean.TRUE); return true; @@ -1387,7 +1390,7 @@ public class TodoCenterManage { private Boolean getCountryNotSealedInfoVO(Long fileId, NotSealedInfoVO notSealedInfoVo, String higherAuditOpinion, String auditOpinion) { if (Objects.nonNull(fileId) && StringUtils.isNotBlank(higherAuditOpinion) - && StringUtils.isNotBlank(auditOpinion)){ + && StringUtils.isNotBlank(auditOpinion)) { notSealedInfoVo.setFileId(fileId); notSealedInfoVo.setIsCommit(Boolean.TRUE); return true; @@ -1414,7 +1417,7 @@ public class TodoCenterManage { if (empPosUnitCode.equals(orgCode)) { cityParamsMap.put("superOrgOpinion", auditOpinion); cityParamsMap.put("superOrgAuditDate", auditDate); - }else { + } else { cityParamsMap.put("superOrgOpinion", null); cityParamsMap.put("superOrgAuditDate", null); } @@ -1423,10 +1426,10 @@ public class TodoCenterManage { private Long generateNotSealedPdf(Long projectId, String templateName, JSONObject paramsMap) { // 获取本地目录的pdf模板 String fileName; - if (templateName.contains(StrPool.DASH)){ + if (templateName.contains(StrPool.DASH)) { int index = templateName.indexOf(StrPool.DASH); fileName = templateName.substring(index + 1); - }else { + } else { fileName = templateName; } InputStream htmlInputStream = @@ -1489,10 +1492,10 @@ public class TodoCenterManage { private JSONObject assemblyPdfParams(Project project, String templateName) { // 获取本地目录的pdf模板 String fileName; - if (templateName.contains(StrPool.DASH)){ + if (templateName.contains(StrPool.DASH)) { int index = templateName.indexOf(StrPool.DASH); fileName = templateName.substring(index + 1); - }else { + } else { fileName = templateName; } Long projectId = project.getId(); @@ -1503,7 +1506,7 @@ public class TodoCenterManage { JSONObject paramsMap = JSONObject.parseObject(JSONObject.toJSONString(pdfGenerateDTO)); // 设置title String title = "【" + project.getProjectName() + "】" + fileName; - paramsMap.put("title",title); + paramsMap.put("title", title); // 获取预审申报的开始时间 ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class) .eq(ProjectInst::getProjectId, projectId) @@ -1514,7 +1517,7 @@ public class TodoCenterManage { if (Objects.nonNull(projectInst)) { time = projectInst.getCreatOn(); paramsMap.put("time", NdDateUtils.format(time, "yyyy-MM-dd HH:mm")); - }else { + } else { paramsMap.put("time", null); } // 获取是否临时增补项目 @@ -1540,39 +1543,39 @@ public class TodoCenterManage { paramsMap.put("fourSystems", fourSystem); // 获取是否数字化改革项目 String isDigitalReform = IsOrNotEnum.getDescByCode(project.getIsDigitalReform()); - paramsMap.put("isDigitalReform",isDigitalReform); - if (IsOrNotEnum.NOT.getDesc().equals(isDigitalReform)){ + paramsMap.put("isDigitalReform", isDigitalReform); + if (IsOrNotEnum.NOT.getDesc().equals(isDigitalReform)) { paramsMap.put("bizDomain", null); - }else { + } else { paramsMap.put("bizDomain", BizDomainEnum.getDescByCode(project.getBizDomain())); } // 获取是否上云 String isCloud = IsOrNotEnum.getDescByCode(project.getIsCloud()); paramsMap.put("isCloud", isCloud); - if (IsOrNotEnum.NOT.getDesc().equals(isCloud)){ + if (IsOrNotEnum.NOT.getDesc().equals(isCloud)) { paramsMap.put("cloudType", null); - }else { + } else { String cloudType = project.getCloudType(); String cloudTypeName; // 云类型为多选 - if (cloudType.contains(StrPool.COMMA)){ + if (cloudType.contains(StrPool.COMMA)) { cloudTypeName = Arrays.stream(cloudType.split(StrPool.COMMA)) .map(s -> CloudTypeEnum.getDescByCode(Integer.valueOf(s))) .collect(Collectors.joining(StrPool.COMMA)); - }else { + } else { cloudTypeName = CloudTypeEnum.getDescByCode(Integer.valueOf(cloudType)); } - paramsMap.put("cloudType",cloudTypeName); + paramsMap.put("cloudType", cloudTypeName); } // 获取本年计划投资金额 BigDecimal yearPlanInvest = project.getAnnualPlanAmount(); - paramsMap.put("yearPlanInvest",yearPlanInvest); + paramsMap.put("yearPlanInvest", yearPlanInvest); // TODO 根据地区编码获取当地大数据局(中心)的名称 - paramsMap.put("bigDataBureauName",null); + paramsMap.put("bigDataBureauName", null); // 备注模块如果为空 - if (Objects.isNull(pdfGenerateDTO.getProjectRemarks())){ - paramsMap.put("projectRemarks",null); + if (Objects.isNull(pdfGenerateDTO.getProjectRemarks())) { + paramsMap.put("projectRemarks", null); } // 获取立项依据 @@ -1591,14 +1594,14 @@ public class TodoCenterManage { String fileInfo = jsonObject.getString(CommonConst.FILE_LIST); List fileInfoArray = JSON.parseArray(fileInfo, JSONObject.class); List nameList = CollUtils.fieldList(fileInfoArray, w -> w.getString(CommonConst.FILE_NAME)); - String appendixStr = nameList.stream().collect(Collectors.joining(StrPool.COMMA)); + String appendixStr = String.join(StrPool.COMMA, nameList); builder.append(CommonConst.APPENDIX); builder.append(appendixStr); builder.append(StrPool.SEMICOLON); builder.append(StrPool.NEWLINE); } String buildBasisList = builder.toString(); - paramsMap.put("buildBasisList",buildBasisList); + paramsMap.put("buildBasisList", buildBasisList); return paramsMap; } @@ -1618,43 +1621,41 @@ public class TodoCenterManage { String areaName = declaredProject.getArea(); Region region = regionService.getOne(Wrappers.lambdaQuery(Region.class) .eq(Region::getRegionCode, areaCode) - .eq(Region::getRegionName,areaName)); - if (Objects.isNull(region)){ + .eq(Region::getRegionName, areaName)); + if (Objects.isNull(region)) { throw new BizException("项目所属区域不存在!"); } Integer regionLevel = region.getRegionLevel(); - if (CommonEnum.LS_SBJ.getDesc().equals(areaName)){ + if (CommonEnum.LS_SBJ.getDesc().equals(areaName)) { regionLevel = RegionConst.RL_CITY; } switch (regionLevel) { // 市级预审(市本级) case RegionConst.RL_CITY: String cityTemplateName = TodoCenterConstant.SealTemplate.CITY_TEMPLATE; - return generateSealedPdf(req, declaredProject,cityTemplateName,notSealedFileId); + return generateSealedPdf(req, declaredProject, cityTemplateName, notSealedFileId); // 区县预审 case RegionConst.RL_COUNTY: String countryTemplateName = TodoCenterConstant.SealTemplate.COUNTRY_TEMPLATE; - return generateSealedPdf(req, declaredProject,countryTemplateName, notSealedFileId); + return generateSealedPdf(req, declaredProject, countryTemplateName, notSealedFileId); default: throw new IllegalStateException("Unexpected value: " + regionLevel); } } // 如果为建设方案申报审批 - else if (InstTypeEnum.CONSTRUCTION_PLAN_REVIEW.getCode().equals(instType)){ + else if (InstTypeEnum.CONSTRUCTION_PLAN_REVIEW.getCode().equals(instType)) { // 设置pdf模板参数 String constructTemplateName = TodoCenterConstant.SealTemplate.CONSTRUCT_TEMPLATE; - return generateSealedPdf(req, declaredProject,constructTemplateName, notSealedFileId); + return generateSealedPdf(req, declaredProject, constructTemplateName, notSealedFileId); } return null; } //获取当前登录人的 待办中心统计数据 - public TodoCenterStatisticsVO todoCenterStatistics(String employeeCode){ + public TodoCenterStatisticsVO todoCenterStatistics(String employeeCode) { //为了查询效率 还是自己去写统计接口 TodoCenterStatisticsPO statistics = statisticsService.getStatistics(employeeCode); - TodoCenterStatisticsVO statisticsVO = BeanUtil.copyProperties(statistics,TodoCenterStatisticsVO.class); - - return statisticsVO; + return BeanUtil.copyProperties(statistics, TodoCenterStatisticsVO.class); } public TodoNumVO getTodoNums(ToBeProcessedReq param) { @@ -1669,7 +1670,7 @@ public class TodoCenterManage { ProjectListReq projectListReq = new ProjectListReq(); BeanUtils.copyProperties(param, projectListReq); List projects = projectLibManage.projectList(projectListReq); - if(CollUtil.isEmpty(projects)){ + if (CollUtil.isEmpty(projects)) { return todoNumVo; } // 再查出项目关联的流程实例ID @@ -1690,18 +1691,18 @@ public class TodoCenterManage { //有退回待办的 List backList = processTaskService.getBackTodoList(req); //合并 并且排序 - List list = Stream.concat(todoList.stream(),backList.stream()) + List list = Stream.concat(todoList.stream(), backList.stream()) .filter(Objects::nonNull) .sorted(Comparator.comparing(ProcessTaskVo::getTaskCreateTime) .reversed()) .collect(Collectors.toList()); - if (CollUtil.isEmpty(list)){ + if (CollUtil.isEmpty(list)) { return todoNumVo; } Map projectsMap = projects.stream().collect(Collectors.toMap(Project::getId, v -> v)); Map projectInfoMap = projectInstList.stream() - .collect(Collectors.toMap(ProjectInst::getInstCode, p-> projectsMap.get(p.getProjectId()))); + .collect(Collectors.toMap(ProjectInst::getInstCode, p -> projectsMap.get(p.getProjectId()))); // 关联项目信息 List projectList = list.stream() .map(d -> projectInfoMap.get(d.getInstanceId())) @@ -1713,13 +1714,13 @@ public class TodoCenterManage { List appendProjects = projectList.stream() .filter(p -> IsAppendProjectEnum.APPEND_PROJECT.getCode().equals(p.getIsTemporaryAugment())) .collect(Collectors.toList()); - if (CollUtil.isNotEmpty(appendProjects)){ + if (CollUtil.isNotEmpty(appendProjects)) { todoNumVo.setAppendNum(appendProjects.size()); } List notAppendProjects = projectList.stream() .filter(p -> IsAppendProjectEnum.NOT_APPEND_PROJECT.getCode().equals(p.getIsTemporaryAugment())) .collect(Collectors.toList()); - if (CollUtil.isNotEmpty(notAppendProjects)){ + if (CollUtil.isNotEmpty(notAppendProjects)) { todoNumVo.setNotAppendNum(notAppendProjects.size()); } return todoNumVo; @@ -1727,10 +1728,11 @@ public class TodoCenterManage { /** * 寻找下一个审核task + * * @param instance * @return */ - private String findNextTaskId(HistoricProcessInstance instance,String employeeCode,String nodeId,String taskId) { + private String findNextTaskId(HistoricProcessInstance instance, String employeeCode, String nodeId, String taskId) { BpmnModel bpmnModel = repositoryService.getBpmnModel(instance.getProcessDefinitionId()); Map subNodeMap = ProcessTaskUtils.getSubNodeMap(bpmnModel); String subProcessId = subNodeMap.get(nodeId); @@ -1744,7 +1746,7 @@ public class TodoCenterManage { .orderByTaskCreateTime() .asc() .list(); - if(CollUtil.isEmpty(tasks)){ + if (CollUtil.isEmpty(tasks)) { //如果此子单位为空 那就直接再查下 他的其它任务 List currentTasks = taskService.createTaskQuery() .processInstanceId(instance.getId()) @@ -1752,7 +1754,7 @@ public class TodoCenterManage { .orderByTaskCreateTime() .asc() .list(); - if(CollUtil.isNotEmpty(currentTasks)){ + if (CollUtil.isNotEmpty(currentTasks)) { return currentTasks.get(0).getId(); } return taskId; @@ -1762,6 +1764,7 @@ public class TodoCenterManage { /** * 取当前用户的下一个taskId + * * @param instanceId * @return */ @@ -1773,7 +1776,7 @@ public class TodoCenterManage { .orderByTaskCreateTime() .asc() .list(); - if(CollUtil.isEmpty(tasks)){ + if (CollUtil.isEmpty(tasks)) { return null; } return tasks.get(0).getId(); @@ -1790,6 +1793,6 @@ public class TodoCenterManage { if (ObjectUtil.isNull(task)) { return TodoCenterConstant.Handler.TASKID_ERROR; } - return processTaskService.saveAuditOpinion(param,employeeCode); + return processTaskService.saveAuditOpinion(param, employeeCode); } }