@@ -1,10 +1,11 @@ | |||
package com.hz.pm.api.common.compare; | |||
import com.alibaba.fastjson.JSONObject; | |||
import lombok.extern.slf4j.Slf4j; | |||
import java.lang.reflect.Field; | |||
import java.util.*; | |||
/** | |||
* 使用须知: <br> | |||
* (1)该工具类主要用于两个同类对象的属性值比较; <br> | |||
@@ -15,10 +16,11 @@ import java.util.*; | |||
* @author zpf | |||
* @since 2023/07/21 | |||
*/ | |||
@Slf4j | |||
public class CompareUtils<T> { | |||
private static final String COMMA = ","; | |||
/** | |||
* 属性比较 | |||
* | |||
@@ -29,13 +31,13 @@ public class CompareUtils<T> { | |||
public String compare(T source, T target) { | |||
return compare(source, target, null); | |||
} | |||
/** | |||
* 属性比较 | |||
* | |||
* @param source 源数据对象 | |||
* @param target 目标数据对象 | |||
* @param source 源数据对象 | |||
* @param target 目标数据对象 | |||
* @param ignoreCompareFields 忽略比较的字段 | |||
* @return 对应属性值的比较变化 | |||
*/ | |||
@@ -77,7 +79,7 @@ public class CompareUtils<T> { | |||
return doCompareJson(sourceMap, targetMap, ignoreCompareFields); | |||
} | |||
private String doEmpty(Map<String, CompareNode> targetMap, List<String> ignoreCompareFields) { | |||
StringBuilder sb = new StringBuilder(); | |||
Collection<CompareNode> values = targetMap.values(); | |||
@@ -98,7 +100,7 @@ public class CompareUtils<T> { | |||
} | |||
return sb.toString(); | |||
} | |||
private String doCompare(Map<String, CompareNode> sourceMap, Map<String, CompareNode> targetMap, List<String> ignoreCompareFields) { | |||
StringBuilder sb = new StringBuilder(); | |||
Set<String> keys = sourceMap.keySet(); | |||
@@ -127,10 +129,7 @@ public class CompareUtils<T> { | |||
private JSONObject doCompareJson(Map<String, CompareNode> sourceMap, Map<String, CompareNode> targetMap, List<String> ignoreCompareFields) { | |||
JSONObject res = new JSONObject(); | |||
Set<String> keys = sourceMap.keySet(); | |||
int size = keys.size(); | |||
int current = 0; | |||
for (String key : keys) { | |||
current++; | |||
CompareNode sn = sourceMap.get(key); | |||
CompareNode tn = targetMap.get(key); | |||
if (Objects.nonNull(ignoreCompareFields) && ignoreCompareFields.contains(sn.getFieldKey())) { | |||
@@ -141,24 +140,24 @@ public class CompareUtils<T> { | |||
// 只有两者属性值不一致时, 才显示变化情况 | |||
if (!sv.equals(tv)) { | |||
JSONObject valueChange = new JSONObject(); | |||
valueChange.put("fieldKey",sn.getFieldKey()); | |||
valueChange.put("old",tv); | |||
valueChange.put("new",sv); | |||
res.put(sn.getFieldName(),valueChange); | |||
valueChange.put("fieldKey", sn.getFieldKey()); | |||
valueChange.put("old", tv); | |||
valueChange.put("new", sv); | |||
res.put(sn.getFieldName(), valueChange); | |||
} | |||
} | |||
return res; | |||
} | |||
private Map<String, CompareNode> getFiledValueMap(T t) { | |||
if (Objects.isNull(t)) { | |||
return Collections.emptyMap(); | |||
} | |||
Field[] fields = t.getClass().getDeclaredFields(); | |||
if (Objects.isNull(fields) || fields.length == 0) { | |||
if (fields.length == 0) { | |||
return Collections.emptyMap(); | |||
} | |||
Map<String, CompareNode> map = new LinkedHashMap(); | |||
Map<String, CompareNode> map = new LinkedHashMap<>(); | |||
for (Field field : fields) { | |||
Compare compareAnnotation = field.getAnnotation(Compare.class); | |||
if (Objects.isNull(compareAnnotation)) { | |||
@@ -173,10 +172,10 @@ public class CompareUtils<T> { | |||
node.setFieldName(compareAnnotation.value()); | |||
map.put(field.getName(), node); | |||
} catch (IllegalArgumentException | IllegalAccessException e) { | |||
e.printStackTrace(); | |||
log.error("获取字段属性异常:", e); | |||
} | |||
} | |||
return map; | |||
} | |||
} |
@@ -8,11 +8,14 @@ package com.hz.pm.api.common.constant; | |||
* @author WendyYang | |||
* @since 17:17 2023/01/29 | |||
*/ | |||
public interface BaseFieldConst { | |||
public class BaseFieldConst { | |||
String CREATE_BY = "createBy"; | |||
String UPDATE_BY = "updateBy"; | |||
String CREATE_ON = "createOn"; | |||
String UPDATE_ON = "updateOn"; | |||
private BaseFieldConst() { | |||
} | |||
public static final String CREATE_BY = "createBy"; | |||
public static final String UPDATE_BY = "updateBy"; | |||
public static final String CREATE_ON = "createOn"; | |||
public static final String UPDATE_ON = "updateOn"; | |||
} |
@@ -12,97 +12,100 @@ import java.math.BigDecimal; | |||
* @author WendyYang | |||
* @since 13:42 2022/12/1 | |||
*/ | |||
public interface BizConst { | |||
public class BizConst { | |||
private BizConst() { | |||
} | |||
/** | |||
* SQL查询一条 | |||
*/ | |||
String LIMIT_1 = "limit 1"; | |||
public static final String LIMIT_1 = "limit 1"; | |||
String COOKIE_KEY = "HZPM_SESSION"; | |||
public static final String COOKIE_KEY = "HZPM_SESSION"; | |||
/** | |||
* 一小时秒数 | |||
**/ | |||
BigDecimal SECONDS_BY_HOUR = new BigDecimal(60 * 60); | |||
public static final BigDecimal SECONDS_BY_HOUR = new BigDecimal(60 * 60); | |||
/** | |||
* 十分钟的毫秒数 | |||
*/ | |||
long MILLS_10_MIN = 1000L * 60 * 10; | |||
public static final long MILLS_10_MIN = 1000L * 60 * 10; | |||
/** | |||
* 中国行政区划编码 | |||
*/ | |||
long ROOT_REGION_CODE = 100000L; | |||
public static final long ROOT_REGION_CODE = 100000L; | |||
/** | |||
* 一级行政区划数量 | |||
*/ | |||
int NUM_PROVINCE = 34; | |||
public static final int NUM_PROVINCE = 34; | |||
/** | |||
* 默认的父id | |||
*/ | |||
long PARENT_ID = 0L; | |||
public static final long PARENT_ID = 0L; | |||
/** | |||
* 默认树层级 | |||
*/ | |||
int TREE_GRADE = 0; | |||
public static final int TREE_GRADE = 0; | |||
/** | |||
* 默认的排序 | |||
*/ | |||
int SORT_VALUE = 0; | |||
public static final int SORT_VALUE = 0; | |||
/** | |||
* 浙江省的region_id | |||
*/ | |||
long ZJ_REGION_CODE = 330000L; | |||
String NINE_AREA_CODE_LAST = "000"; | |||
public static final long ZJ_REGION_CODE = 330000L; | |||
public static final String NINE_AREA_CODE_LAST = "000"; | |||
/** | |||
* 省/直辖市 level | |||
*/ | |||
int GOV_L1 = 1; | |||
public static final int GOV_L1 = 1; | |||
/** | |||
* 市 level | |||
*/ | |||
int GOV_L2 = 2; | |||
public static final int GOV_L2 = 2; | |||
/** | |||
* 区/县 level | |||
*/ | |||
int GOV_L3 = 3; | |||
public static final int GOV_L3 = 3; | |||
/** | |||
* 密码正则:长度8-20位且至少包含大写字母、小写字母、数字或特殊符号中的任意三种 | |||
*/ | |||
String REGEX_PASS = "^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\\W_]+$)(?![a-z0-9]+$)(?![a-z\\W_]+$)(?![0-9\\W_]+$)[a-zA-Z0-9\\W_]{8,20}$"; | |||
public static final String REGEX_PASS = "^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\\W_]+$)(?![a-z0-9]+$)(?![a-z\\W_]+$)(?![0-9\\W_]+$)[a-zA-Z0-9\\W_]{8,20}$"; | |||
ApiResponse<Void> UNAUTHENTICATED = ApiResponse.of(401, "用户未登录", null); | |||
public static final ApiResponse<Void> UNAUTHENTICATED = ApiResponse.of(401, "用户未登录", null); | |||
int MAX_EXPORT_COUNT = 5000; | |||
public static final int MAX_EXPORT_COUNT = 5000; | |||
String RESPONSE_KEY_DATA = "data"; | |||
String RESPONSE_KEY_ID = "id"; | |||
String RESPONSE_KEY_DING_CODE = "dingCode"; | |||
String RESPONSE_KEY_MATTER_NAME = "matterName"; | |||
String RESPONSE_KEY_ORG_NAME = "orgName"; | |||
String RESPONSE_KEY_USER_STATE = "userState"; | |||
public static final String RESPONSE_KEY_DATA = "data"; | |||
public static final String RESPONSE_KEY_ID = "id"; | |||
public static final String RESPONSE_KEY_DING_CODE = "dingCode"; | |||
public static final String RESPONSE_KEY_MATTER_NAME = "matterName"; | |||
public static final String RESPONSE_KEY_ORG_NAME = "orgName"; | |||
public static final String RESPONSE_KEY_USER_STATE = "userState"; | |||
String RESPONSE_KEY_AREA_NAME = "areaName"; | |||
String ORG_NAME = "organizationName"; | |||
String ORG_CODE = "organizationCode"; | |||
public static final String RESPONSE_KEY_AREA_NAME = "areaName"; | |||
public static final String ORG_NAME = "organizationName"; | |||
public static final String ORG_CODE = "organizationCode"; | |||
String DEV = "dev"; | |||
String PRE = "pre"; | |||
String PROD = "prod"; | |||
public static final String DEV = "dev"; | |||
public static final String PRE = "pre"; | |||
public static final String PROD = "prod"; | |||
String SAVE_SUCCESS = "保存成功"; | |||
String OP_SUCCESS = "操作成功"; | |||
String OP_FAIL = "操作失败"; | |||
String SAVE_FAIL = "保存失败"; | |||
public static final String SAVE_SUCCESS = "保存成功"; | |||
public static final String OP_SUCCESS = "操作成功"; | |||
public static final String OP_FAIL = "操作失败"; | |||
public static final String SAVE_FAIL = "保存失败"; | |||
} |
@@ -1,5 +1,6 @@ | |||
package com.hz.pm.api.common.util; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.apache.http.HttpEntity; | |||
import org.apache.http.NameValuePair; | |||
import org.apache.http.client.config.RequestConfig; | |||
@@ -20,8 +21,6 @@ import org.apache.http.impl.client.HttpClients; | |||
import org.apache.http.message.BasicNameValuePair; | |||
import org.apache.http.ssl.SSLContexts; | |||
import org.apache.http.util.EntityUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; | |||
import javax.net.ssl.SSLContext; | |||
@@ -30,17 +29,28 @@ import java.net.URL; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.Map; | |||
/** | |||
* <p> | |||
* HttpUtil | |||
* </p> | |||
* | |||
* @author WendyYang | |||
* @since 14:39 2023/12/17 | |||
*/ | |||
@Slf4j | |||
public class HttpUtil { | |||
private Logger logger = LoggerFactory.getLogger(getClass()); | |||
private RequestConfig requestConfig = RequestConfig.custom() | |||
.setSocketTimeout(15000) | |||
.setConnectTimeout(15000) | |||
.setConnectionRequestTimeout(15000) | |||
.build(); | |||
private static final RequestConfig REQUEST_CONFIG = RequestConfig.custom() | |||
.setSocketTimeout(15000) | |||
.setConnectTimeout(15000) | |||
.setConnectionRequestTimeout(15000) | |||
.build(); | |||
private static HttpUtil instance = null; | |||
private HttpUtil(){} | |||
public static HttpUtil getInstance(){ | |||
private HttpUtil() { | |||
} | |||
public static HttpUtil getInstance() { | |||
if (instance == null) { | |||
instance = new HttpUtil(); | |||
} | |||
@@ -48,186 +58,142 @@ public class HttpUtil { | |||
} | |||
/** | |||
* 发送 post 请求 | |||
* @param httpUrl 地址 | |||
*/ | |||
* 发送 post 请求 | |||
* | |||
* @param httpUrl 地址 | |||
*/ | |||
public String sendHttpPost(String httpUrl) { | |||
HttpPost httpPost= new HttpPost(httpUrl);// 创建 httpPost | |||
// 创建 httpPost | |||
HttpPost httpPost = new HttpPost(httpUrl); | |||
return sendHttpPost(httpPost); | |||
} | |||
/** | |||
* 发送 post 请求 | |||
* @param httpUrl 地址 | |||
* @param params 参数(格式:key1=value1&key2=value2) | |||
*/ | |||
* 发送 post 请求 | |||
* | |||
* @param httpUrl 地址 | |||
* @param params 参数(格式:key1=value1&key2=value2) | |||
*/ | |||
public String sendHttpPost(String httpUrl, String params) { | |||
HttpPost httpPost= new HttpPost(httpUrl);// 创建 httpPost | |||
HttpPost httpPost = new HttpPost(httpUrl);// 创建 httpPost | |||
try { | |||
//设置参数 | |||
StringEntity stringEntity = new StringEntity(params, "UTF-8"); | |||
stringEntity.setContentType("application/x-www-form-urlencoded"); | |||
httpPost.setEntity(stringEntity); | |||
} catch (Exception e) { | |||
logger.error(e.getMessage(),e); | |||
log.error(e.getMessage(), e); | |||
} | |||
return sendHttpPost(httpPost); | |||
} | |||
/** | |||
* 发送 post 请求 | |||
* @param httpUrl 地址 | |||
* @param maps 参数 | |||
*/ | |||
* 发送 post 请求 | |||
* | |||
* @param httpUrl 地址 | |||
* @param maps 参数 | |||
*/ | |||
public String sendHttpPost(String httpUrl, Map<String, String> maps) { | |||
HttpPost httpPost= new HttpPost(httpUrl);// 创建 httpPost | |||
HttpPost httpPost = new HttpPost(httpUrl);// 创建 httpPost | |||
// 创建参数队列 | |||
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); | |||
for (String key : maps.keySet()) { | |||
nameValuePairs.add(new BasicNameValuePair(key, maps.get(key))); | |||
List<NameValuePair> nameValuePairs = new ArrayList<>(); | |||
for (Map.Entry<String, String> entry : maps.entrySet()) { | |||
nameValuePairs.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); | |||
} | |||
try { | |||
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8")); | |||
} catch (Exception e) { | |||
logger.error(e.getMessage(),e); | |||
log.error(e.getMessage(), e); | |||
} | |||
return sendHttpPost(httpPost); | |||
} | |||
/** | |||
* 发送 Post请求 | |||
* @param httpPost | |||
*@return | |||
*/ | |||
* 发送 Post请求 | |||
* | |||
* @param httpPost \ | |||
* @return \ | |||
*/ | |||
private String sendHttpPost(HttpPost httpPost) { | |||
CloseableHttpClient httpClient = null; | |||
CloseableHttpResponse response = null; | |||
HttpEntity entity = null; | |||
String responseContent = null; | |||
try { | |||
// 创建默认的 httpClient 实例. | |||
httpClient = HttpClients.createDefault(); | |||
httpPost.setConfig(requestConfig); | |||
// 执行请求 | |||
response = httpClient.execute(httpPost); | |||
entity = response.getEntity(); | |||
responseContent = EntityUtils.toString(entity, "UTF-8"); | |||
httpPost.setConfig(REQUEST_CONFIG); | |||
try (CloseableHttpClient httpClient = HttpClients.createDefault(); | |||
CloseableHttpResponse response = httpClient.execute(httpPost)) { | |||
HttpEntity entity = response.getEntity(); | |||
return EntityUtils.toString(entity, "UTF-8"); | |||
} catch (Exception e) { | |||
logger.error(e.getMessage(),e); | |||
} finally { | |||
try { | |||
// 关闭连接,释放资源 | |||
if (response != null) { | |||
response.close(); | |||
} | |||
if (httpClient != null) { | |||
httpClient.close(); | |||
} | |||
} catch (IOException e) { | |||
logger.error(e.getMessage(),e); | |||
} | |||
log.error(e.getMessage(), e); | |||
return null; | |||
} | |||
return responseContent; | |||
} | |||
/** | |||
* 发送 get 请求 | |||
* @param httpUrl | |||
*/ | |||
* 发送 get 请求 | |||
* | |||
* @param httpUrl \ | |||
*/ | |||
public String sendHttpGet(String httpUrl) { | |||
HttpGet httpGet = new HttpGet(httpUrl);// 创建 get 请求 | |||
return sendHttpGet(httpGet); | |||
} | |||
/** | |||
* 发送 get请求 Https | |||
* @param httpUrl | |||
*/ | |||
public String sendHttpsGet(String httpUrl) { | |||
* 发送 get请求 Https | |||
* | |||
* @param httpUrl \ | |||
*/ | |||
public String sendHttpsGet(String httpUrl) throws IOException { | |||
HttpGet httpGet = new HttpGet(httpUrl);// 创建 get 请求 | |||
return sendHttpsGet(httpGet); | |||
} | |||
/** | |||
* 发送 Get请求 | |||
* @param httpGet | |||
*@return | |||
*/ | |||
* 发送 Get请求 | |||
* | |||
* @param httpGet \ | |||
* @return \ | |||
*/ | |||
private String sendHttpGet(HttpGet httpGet) { | |||
CloseableHttpClient httpClient = null; | |||
CloseableHttpResponse response = null; | |||
HttpEntity entity = null; | |||
String responseContent = null; | |||
try { | |||
httpGet.setConfig(REQUEST_CONFIG); | |||
try (CloseableHttpClient httpClient = HttpClients.createDefault(); | |||
CloseableHttpResponse response = httpClient.execute(httpGet);) { | |||
// 创建默认的 httpClient 实例. | |||
httpClient = HttpClients.createDefault(); | |||
httpGet.setConfig(requestConfig); | |||
// 执行请求 | |||
response = httpClient.execute(httpGet); | |||
entity = response.getEntity(); | |||
responseContent = EntityUtils.toString(entity, "UTF-8"); | |||
HttpEntity entity = response.getEntity(); | |||
return EntityUtils.toString(entity, "UTF-8"); | |||
} catch (Exception e) { | |||
logger.error(e.getMessage(),e); | |||
} finally { | |||
try { | |||
// 关闭连接,释放资源 | |||
if (response != null) { | |||
response.close(); | |||
} | |||
if (httpClient != null) { | |||
httpClient.close(); | |||
} | |||
} catch (IOException e) { | |||
logger.error(e.getMessage(),e); | |||
} | |||
log.error(e.getMessage(), e); | |||
return null; | |||
} | |||
return responseContent; | |||
} | |||
/** | |||
* 发送 Get请求 Https | |||
*@return | |||
*/ | |||
private String sendHttpsGet(HttpGet httpGet) { | |||
CloseableHttpClient httpClient = null; | |||
CloseableHttpResponse response = null; | |||
HttpEntity entity = null; | |||
String responseContent = null; | |||
try { | |||
// 创建默认的 httpClient 实例. | |||
PublicSuffixMatcher publicSuffixMatcher = PublicSuffixMatcherLoader.load(new | |||
URL(httpGet.getURI().toString())); | |||
DefaultHostnameVerifier hostnameVerifier = new DefaultHostnameVerifier(publicSuffixMatcher); | |||
httpClient = HttpClients.custom().setSSLHostnameVerifier(hostnameVerifier).build(); | |||
httpGet.setConfig(requestConfig); | |||
// 执行请求 | |||
response = httpClient.execute(httpGet); | |||
entity = response.getEntity(); | |||
responseContent = EntityUtils.toString(entity, "UTF-8"); | |||
* 发送 Get请求 Https | |||
* | |||
* @return \ | |||
*/ | |||
private String sendHttpsGet(HttpGet httpGet) throws IOException { | |||
// 创建默认的 httpClient 实例. | |||
PublicSuffixMatcher publicSuffixMatcher = PublicSuffixMatcherLoader.load(new | |||
URL(httpGet.getURI().toString())); | |||
DefaultHostnameVerifier hostnameVerifier = new DefaultHostnameVerifier(publicSuffixMatcher); | |||
httpGet.setConfig(REQUEST_CONFIG); | |||
try (CloseableHttpClient httpClient = HttpClients.custom().setSSLHostnameVerifier(hostnameVerifier).build(); | |||
CloseableHttpResponse response = httpClient.execute(httpGet)) { | |||
HttpEntity entity = response.getEntity(); | |||
return EntityUtils.toString(entity, "UTF-8"); | |||
} catch (Exception e) { | |||
logger.error(e.getMessage(),e); | |||
} finally { | |||
try { | |||
// 关闭连接,释放资源 | |||
if (response != null) { | |||
response.close(); | |||
} | |||
if (httpClient != null) { | |||
httpClient.close(); | |||
} | |||
} catch (IOException e) { | |||
logger.error(e.getMessage(),e); | |||
} | |||
log.error(e.getMessage(), e); | |||
return null; | |||
} | |||
return responseContent; | |||
} | |||
/** | |||
* 通过该工厂类创建的RestTemplate发送请求时,可忽略https证书认证 | |||
* | |||
* @return 工厂 | |||
*/ | |||
public static HttpComponentsClientHttpRequestFactory generateHttpRequestFactory(){ | |||
try{ | |||
public static HttpComponentsClientHttpRequestFactory generateHttpRequestFactory() { | |||
try { | |||
TrustStrategy acceptingTrustStrategy = ((x509Certificates, authType) -> true); | |||
SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build(); | |||
SSLConnectionSocketFactory connectionSocketFactory = new SSLConnectionSocketFactory(sslContext, new NoopHostnameVerifier()); | |||
@@ -238,8 +204,8 @@ public class HttpUtil { | |||
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(); | |||
factory.setHttpClient(httpClient); | |||
return factory; | |||
}catch (Exception e){ | |||
e.printStackTrace(); | |||
} catch (Exception e) { | |||
log.error(e.getMessage(), e); | |||
} | |||
return null; | |||
} |
@@ -295,8 +295,6 @@ public class DingInfoPullController { | |||
}else { | |||
return wb = null; | |||
} | |||
} catch (FileNotFoundException e) { | |||
e.printStackTrace(); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
@@ -1,11 +1,10 @@ | |||
package com.hz.pm.api.expert.service; | |||
import cn.hutool.core.collection.CollUtil; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.baomidou.mybatisplus.extension.service.IService; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import com.hz.pm.api.expert.entity.ExpertUserFullInfo; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import java.util.Collection; | |||
import java.util.List; | |||
@@ -4,7 +4,6 @@ import cn.hutool.core.util.StrUtil; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.google.common.collect.Lists; | |||
import com.hz.pm.api.expert.entity.ExpertGovBusinessStrip; | |||
import com.hz.pm.api.expert.entity.ExpertUserFullInfo; | |||
import com.hz.pm.api.expert.service.IExpertGovBusinessStripService; | |||
@@ -24,7 +23,6 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; | |||
import org.springframework.stereotype.Component; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import java.io.FileInputStream; | |||
import java.io.IOException; | |||
import java.nio.file.Files; | |||
import java.nio.file.Paths; | |||
@@ -1,12 +1,8 @@ | |||
package com.hz.pm.api.irs.service; | |||
import com.baomidou.mybatisplus.extension.service.IService; | |||
import com.hz.pm.api.gov.entity.BelongOrg; | |||
import com.hz.pm.api.irs.model.entity.ProjectCoreBiz; | |||
import java.util.Collection; | |||
import java.util.List; | |||
/** | |||
* <p> | |||
* 服务类 | |||
@@ -1,26 +1,24 @@ | |||
package com.hz.pm.api.irs.sign; | |||
import cn.hutool.core.io.FileUtil; | |||
import com.alibaba.fastjson.JSON; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.ningdatech.basic.exception.BizException; | |||
import com.ningdatech.basic.util.StrPool; | |||
import com.hz.pm.api.irs.config.IrsSealPlatformProperties; | |||
import com.hz.pm.api.todocenter.model.dto.SignReqDTO; | |||
import com.ningdatech.basic.exception.BizException; | |||
import com.ningdatech.basic.util.StrPool; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.apache.commons.lang3.tuple.Pair; | |||
import org.apache.http.HttpEntity; | |||
import org.apache.http.HttpResponse; | |||
import org.apache.http.client.HttpClient; | |||
import org.apache.http.client.config.RequestConfig; | |||
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; | |||
import org.apache.http.client.methods.HttpPost; | |||
import org.apache.http.entity.ByteArrayEntity; | |||
import org.apache.http.entity.ContentType; | |||
import org.apache.http.impl.client.CloseableHttpClient; | |||
import org.apache.http.impl.client.HttpClientBuilder; | |||
import org.apache.http.impl.client.HttpClients; | |||
import sun.misc.BASE64Decoder; | |||
import sun.misc.BASE64Encoder; | |||
import javax.crypto.Mac; | |||
import javax.crypto.spec.SecretKeySpec; | |||
@@ -35,6 +33,7 @@ import java.text.DateFormat; | |||
import java.text.SimpleDateFormat; | |||
import java.util.*; | |||
import java.util.stream.Collectors; | |||
@Slf4j | |||
public class IRSAPIRequest { | |||
@@ -215,17 +214,12 @@ public class IRSAPIRequest { | |||
* @Author fuyuwei | |||
* Create Date: 2015年8月3日 下午9:52:30 | |||
*/ | |||
public static String PDFToBase64(File file) { | |||
FileInputStream fin = null; | |||
BufferedInputStream bin = null; | |||
ByteArrayOutputStream baos; | |||
BufferedOutputStream bout = null; | |||
try { | |||
fin = new FileInputStream(file); | |||
bin = new BufferedInputStream(fin); | |||
baos = new ByteArrayOutputStream(); | |||
bout = new BufferedOutputStream(baos); | |||
byte[] buffer = new byte[1024]; | |||
public static String pdfToBase64(File file) { | |||
try (FileInputStream fin = new FileInputStream(file); | |||
BufferedInputStream bin = new BufferedInputStream(fin); | |||
ByteArrayOutputStream bos = new ByteArrayOutputStream(); | |||
BufferedOutputStream bout = new BufferedOutputStream(bos);) { | |||
byte[] buffer = new byte[1024 * 16]; | |||
int len = bin.read(buffer); | |||
while (len != -1) { | |||
bout.write(buffer, 0, len); | |||
@@ -233,19 +227,10 @@ public class IRSAPIRequest { | |||
} | |||
//刷新此输出流并强制写出所有缓冲的输出字节 | |||
bout.flush(); | |||
byte[] bytes = baos.toByteArray(); | |||
byte[] bytes = bos.toByteArray(); | |||
return String.valueOf(Base64.getEncoder().encode(bytes)); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} finally { | |||
try { | |||
fin.close(); | |||
bin.close(); | |||
bout.close(); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
log.error(e.getMessage(), e); | |||
} | |||
return null; | |||
} | |||
@@ -253,31 +238,19 @@ public class IRSAPIRequest { | |||
/** | |||
* Description: 将base64编码内容转换为Pdf | |||
* <p> | |||
* // * @param base64编码内容,文件的存储路径(含文件名) | |||
* | |||
* @Author fuyuwei | |||
* Create Date: 2015年7月30日 上午9:40:23 | |||
* @param base64Content 文件的存储路径(含文件名) | |||
*/ | |||
public static void base64StringToPdf(String base64Content, String filePath) { | |||
public static void base64StringToPdf(String base64Content, String filePath) throws IOException { | |||
BASE64Decoder decoder = new BASE64Decoder(); | |||
BufferedInputStream bis; | |||
FileOutputStream fos; | |||
BufferedOutputStream bos; | |||
try { | |||
// base64编码内容转换为字节数组 | |||
byte[] bytes = decoder.decodeBuffer(base64Content); | |||
ByteArrayInputStream byteInputStream = new ByteArrayInputStream(bytes); | |||
bis = new BufferedInputStream(byteInputStream); | |||
File file = new File(filePath); | |||
File path = file.getParentFile(); | |||
if (!path.exists()) { | |||
path.mkdirs(); | |||
} | |||
fos = new FileOutputStream(file); | |||
bos = new BufferedOutputStream(fos); | |||
byte[] buffer = new byte[1024]; | |||
byte[] bytes = decoder.decodeBuffer(base64Content); | |||
File file = new File(filePath); | |||
FileUtil.mkParentDirs(file); | |||
try (ByteArrayInputStream byteInputStream = new ByteArrayInputStream(bytes); | |||
BufferedInputStream bis = new BufferedInputStream(byteInputStream); | |||
FileOutputStream fos = new FileOutputStream(file); | |||
BufferedOutputStream bos = new BufferedOutputStream(fos)) { | |||
byte[] buffer = new byte[1024 * 16]; | |||
int length = bis.read(buffer); | |||
while (length != -1) { | |||
bos.write(buffer, 0, length); | |||
@@ -285,9 +258,7 @@ public class IRSAPIRequest { | |||
} | |||
bos.flush(); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
} finally { | |||
//closeStream(bis, fos, bos); | |||
log.error(e.getMessage(), e); | |||
} | |||
} | |||
@@ -306,7 +277,9 @@ public class IRSAPIRequest { | |||
queryParamList.add(pair); | |||
} | |||
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>> 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.forEach(param -> { | |||
try { | |||
@@ -314,7 +287,7 @@ public class IRSAPIRequest { | |||
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", "%"); | |||
encodeParamList.add(Pair.of(key, value)); | |||
} catch (UnsupportedEncodingException e) { | |||
throw new RuntimeException("encoding error"); | |||
throw new BizException("encoding error"); | |||
} | |||
}); | |||
@@ -14,7 +14,6 @@ import java.util.List; | |||
import java.util.Map; | |||
import java.util.concurrent.ConcurrentHashMap; | |||
import java.util.concurrent.TimeUnit; | |||
import java.util.stream.Collectors; | |||
/** | |||
* @author liuxinxin | |||
@@ -1,14 +1,13 @@ | |||
package com.hz.pm.api.organization.controller; | |||
import com.ningdatech.basic.model.PageVo; | |||
import com.ningdatech.log.annotation.WebLog; | |||
import com.hz.pm.api.organization.manage.OrganizationManage; | |||
import com.hz.pm.api.organization.model.po.ReqOrganizationListPO; | |||
import com.hz.pm.api.organization.model.po.ReqSynthesizePO; | |||
import com.hz.pm.api.organization.model.vo.KeyTreeVO; | |||
import com.hz.pm.api.organization.model.vo.OrganizationTreeVO; | |||
import com.hz.pm.api.organization.model.vo.ResOrganizationListVO; | |||
import com.ningdatech.basic.model.PageVo; | |||
import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiOperation; | |||
import lombok.RequiredArgsConstructor; | |||
@@ -5,11 +5,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.StringUtils; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import com.hz.pm.api.organization.mapper.DingOrganizationMapper; | |||
import com.hz.pm.api.organization.model.entity.DingEmployeeInfo; | |||
import com.hz.pm.api.organization.model.entity.DingOrganization; | |||
import com.hz.pm.api.organization.service.IDingOrganizationService; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import org.springframework.stereotype.Service; | |||
import java.util.*; | |||
@@ -92,11 +92,11 @@ public class DingOrganizationServiceImpl extends ServiceImpl<DingOrganizationMap | |||
Map<String, DingOrganization> orgMap = this.getOrgMap(orgCodeList); | |||
Map<String, DingOrganization> empCodeOrgMap = new HashMap<String, DingOrganization>(); | |||
for(DingEmployeeInfo dingEmployeeInfo:employeeInfoList){ | |||
Map<String, DingOrganization> empCodeOrgMap = new HashMap<>(); | |||
for (DingEmployeeInfo dingEmployeeInfo : employeeInfoList) { | |||
DingOrganization dingOrganization = orgMap.get(dingEmployeeInfo.getEmpPosUnitCode()); | |||
if (Objects.nonNull(dingOrganization)){ | |||
empCodeOrgMap.put(dingEmployeeInfo.getEmployeeCode(),dingOrganization); | |||
if (Objects.nonNull(dingOrganization)) { | |||
empCodeOrgMap.put(dingEmployeeInfo.getEmployeeCode(), dingOrganization); | |||
} | |||
} | |||
return empCodeOrgMap; | |||
@@ -19,6 +19,10 @@ import java.net.URLEncoder; | |||
* @since 2023/08/17 21:05 | |||
*/ | |||
public final class ContentTypeUtils { | |||
private ContentTypeUtils() { | |||
} | |||
public static final String CONTENT_DISPOSITION; | |||
public static final String APPLICATION_EXCEL; | |||
static { | |||
@@ -1,11 +1,8 @@ | |||
package com.hz.pm.api.projectdeclared.controller; | |||
import com.ningdatech.basic.model.PageVo; | |||
import com.ningdatech.log.annotation.WebLog; | |||
import com.hz.pm.api.common.util.ExcelDownUtil; | |||
import com.hz.pm.api.projectdeclared.manage.ConstructionManage; | |||
import com.hz.pm.api.projectdeclared.model.dto.ContractSaveDTO; | |||
import com.hz.pm.api.projectdeclared.model.dto.PaymentPlanSaveDTO; | |||
import com.hz.pm.api.projectdeclared.model.dto.PaymentPlanSupplementDTO; | |||
import com.hz.pm.api.projectdeclared.model.dto.PreInsSaveDTO; | |||
import com.hz.pm.api.projectdeclared.model.vo.ContractVO; | |||
@@ -13,12 +10,15 @@ import com.hz.pm.api.projectdeclared.model.vo.PreInsVO; | |||
import com.hz.pm.api.projectdeclared.model.vo.ProjectContractListVO; | |||
import com.hz.pm.api.projectlib.model.req.ProjectListReq; | |||
import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO; | |||
import com.ningdatech.basic.model.PageVo; | |||
import com.ningdatech.log.annotation.WebLog; | |||
import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiOperation; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.validation.annotation.Validated; | |||
import org.springframework.web.bind.annotation.*; | |||
import javax.servlet.http.HttpServletResponse; | |||
import java.util.List; | |||
@@ -52,8 +52,8 @@ public class ConstructionController { | |||
@GetMapping("/contract/export") | |||
@ApiOperation("待合同备案的项目列表导出") | |||
@WebLog("待合同备案的项目列表导出") | |||
public void exportList(ProjectListReq req, HttpServletResponse response){ | |||
ExcelDownUtil.downXls(response,req,constructionManage::exportList); | |||
public void exportList(ProjectListReq req, HttpServletResponse response) { | |||
ExcelDownUtil.downXls(response, req, constructionManage::exportList); | |||
} | |||
@ApiOperation(value = "合同备案的详情-通过项目ID", notes = "合同备案的详情-通过项目ID") | |||
@@ -85,8 +85,8 @@ public class ConstructionController { | |||
@GetMapping("/pre-ins/export") | |||
@ApiOperation("待初验备案的项目列表导出") | |||
@WebLog("待初验备案的项目列表导出") | |||
public void exportPreList(ProjectListReq req, HttpServletResponse response){ | |||
ExcelDownUtil.downXls(response,req,constructionManage::exportPreList); | |||
public void exportPreList(ProjectListReq req, HttpServletResponse response) { | |||
ExcelDownUtil.downXls(response, req, constructionManage::exportPreList); | |||
} | |||
@ApiOperation(value = "初验备案的详情-通过项目ID", notes = "初验备案的详情-通过项目ID") | |||
@@ -7,17 +7,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.google.common.collect.Lists; | |||
import com.ningdatech.basic.exception.BizException; | |||
import com.ningdatech.basic.function.VUtils; | |||
import com.ningdatech.basic.model.PageVo; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import com.ningdatech.basic.util.NdDateUtils; | |||
import com.hz.pm.api.common.constant.BizConst; | |||
import com.hz.pm.api.common.helper.UserInfoHelper; | |||
import com.hz.pm.api.common.statemachine.util.StateMachineUtils; | |||
import com.hz.pm.api.common.util.ExcelDownUtil; | |||
import com.hz.pm.api.common.util.ExcelExportStyle; | |||
import com.hz.pm.api.projectdeclared.model.dto.*; | |||
import com.hz.pm.api.projectdeclared.model.dto.ContractSaveDTO; | |||
import com.hz.pm.api.projectdeclared.model.dto.DeclaredProjectExportDTO; | |||
import com.hz.pm.api.projectdeclared.model.dto.PaymentPlanSupplementDTO; | |||
import com.hz.pm.api.projectdeclared.model.dto.PreInsSaveDTO; | |||
import com.hz.pm.api.projectdeclared.model.entity.Contract; | |||
import com.hz.pm.api.projectdeclared.model.entity.PaymentPlan; | |||
import com.hz.pm.api.projectdeclared.model.entity.PreInsAcceptancePerson; | |||
@@ -28,7 +26,6 @@ import com.hz.pm.api.projectdeclared.service.IPaymentPlanService; | |||
import com.hz.pm.api.projectdeclared.service.IPreInsAcceptancePersonService; | |||
import com.hz.pm.api.projectdeclared.service.IPurchaseService; | |||
import com.hz.pm.api.projectlib.enumeration.ProjectStatusEnum; | |||
import com.hz.pm.api.projectlib.enumeration.ProjectTypeEnum; | |||
import com.hz.pm.api.projectlib.enumeration.ProjectTypeNewEnum; | |||
import com.hz.pm.api.projectlib.helper.ProjectHelper; | |||
import com.hz.pm.api.projectlib.model.entity.Project; | |||
@@ -37,6 +34,11 @@ import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO; | |||
import com.hz.pm.api.projectlib.service.IProjectService; | |||
import com.hz.pm.api.user.security.auth.model.UserFullInfoDTO; | |||
import com.hz.pm.api.user.util.LoginUserUtil; | |||
import com.ningdatech.basic.exception.BizException; | |||
import com.ningdatech.basic.function.VUtils; | |||
import com.ningdatech.basic.model.PageVo; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import com.ningdatech.basic.util.NdDateUtils; | |||
import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.apache.commons.lang3.StringUtils; | |||
@@ -44,8 +46,8 @@ import org.springframework.beans.BeanUtils; | |||
import org.springframework.stereotype.Component; | |||
import javax.servlet.http.HttpServletResponse; | |||
import java.io.IOException; | |||
import java.math.BigDecimal; | |||
import java.math.RoundingMode; | |||
import java.time.LocalDateTime; | |||
import java.time.format.DateTimeFormatter; | |||
import java.util.Collections; | |||
@@ -95,7 +97,7 @@ public class ConstructionManage { | |||
query.eq(Project::getStage, ProjectStatusEnum.PROJECT_APPROVED.getCode()); | |||
query.eq(Project::getNewest, Boolean.TRUE); | |||
//只能看自己单位的 | |||
query.eq(Project::getBuildOrgCode,user.getEmpPosUnitCode()); | |||
query.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()); | |||
query.orderByAsc(Project::getTransactionTime); | |||
Page<Project> page = projectService.page(req.page(), query); | |||
long total; | |||
@@ -128,6 +130,7 @@ public class ConstructionManage { | |||
/** | |||
* 已完善合同信息的列表 | |||
* | |||
* @param req | |||
* @return | |||
*/ | |||
@@ -141,7 +144,7 @@ public class ConstructionManage { | |||
.isNotNull(Project::getContractAmount))); | |||
query.eq(Project::getNewest, Boolean.TRUE); | |||
//只能看自己单位的 | |||
query.eq(Project::getBuildOrgCode,user.getEmpPosUnitCode()); | |||
query.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()); | |||
query.orderByAsc(Project::getUpdateOn); | |||
Page<Project> page = projectService.page(req.page(), query); | |||
@@ -158,9 +161,9 @@ public class ConstructionManage { | |||
.collect(Collectors.groupingBy(PaymentPlan::getProjectCode)); | |||
List<ProjectContractListVO> records = CollUtils.convert(page.getRecords(), w -> { | |||
ProjectContractListVO item = BeanUtil.copyProperties(w,ProjectContractListVO.class); | |||
ProjectContractListVO item = BeanUtil.copyProperties(w, ProjectContractListVO.class); | |||
item.setBuildOrg(w.getBuildOrgName()); | |||
item.setSupplemented(checkIsSupplement(w,paymentMap)); | |||
item.setSupplemented(checkIsSupplement(w, paymentMap)); | |||
return item; | |||
}); | |||
return PageVo.of(records, page.getTotal()); | |||
@@ -168,18 +171,19 @@ public class ConstructionManage { | |||
/** | |||
* 判断 是否需要补充 | |||
* | |||
* @param w | |||
* @param paymentMap | |||
* @return | |||
*/ | |||
private Boolean checkIsSupplement(Project w, Map<String, List<PaymentPlan>> paymentMap) { | |||
if(paymentMap.containsKey(w.getProjectCode())){ | |||
if (paymentMap.containsKey(w.getProjectCode())) { | |||
List<PaymentPlan> paymentPlans = paymentMap.get(w.getProjectCode()); | |||
if(CollUtil.isEmpty(paymentPlans)){ | |||
if (CollUtil.isEmpty(paymentPlans)) { | |||
return Boolean.FALSE; | |||
} | |||
for (PaymentPlan plan : paymentPlans){ | |||
if(Objects.isNull(plan.getActualPaymentAmount())){ | |||
for (PaymentPlan plan : paymentPlans) { | |||
if (Objects.isNull(plan.getActualPaymentAmount())) { | |||
return Boolean.FALSE; | |||
} | |||
} | |||
@@ -237,10 +241,8 @@ public class ConstructionManage { | |||
.registerWriteHandler(ExcelExportStyle.formalStyle()) | |||
.sheet(fileName) | |||
.doWrite(collect); | |||
} catch (IOException e) { | |||
throw new RuntimeException(e); | |||
} catch (Exception e) { | |||
throw new RuntimeException(e); | |||
throw new BizException(e); | |||
} | |||
} | |||
@@ -252,7 +254,7 @@ public class ConstructionManage { | |||
*/ | |||
public ContractVO detailContractByProjectId(Long projectId) { | |||
Project project = projectService.getNewProject(projectId); | |||
if(Objects.isNull(project)){ | |||
if (Objects.isNull(project)) { | |||
return null; | |||
} | |||
Contract contract = contractService.getOne(Wrappers.lambdaQuery(Contract.class) | |||
@@ -280,7 +282,7 @@ public class ConstructionManage { | |||
PaymentPlanVO vo = BeanUtil.copyProperties(p, PaymentPlanVO.class); | |||
vo.setRatio((Objects.isNull(totalAmount) || totalAmount.compareTo(BigDecimal.ZERO) == 0) ? "0%" | |||
: p.getPaymentAmount().multiply(BigDecimal.valueOf(100)) | |||
.divide(totalAmount, BigDecimal.ROUND_CEILING, BigDecimal.ROUND_CEILING) + "%"); | |||
.divide(totalAmount, BigDecimal.ROUND_CEILING, RoundingMode.CEILING) + "%"); | |||
return vo; | |||
}) | |||
.collect(Collectors.toList()); | |||
@@ -376,7 +378,7 @@ public class ConstructionManage { | |||
query.eq(Project::getStage, ProjectStatusEnum.PROJECT_APPROVED.getCode()); | |||
query.eq(Project::getNewest, Boolean.TRUE); | |||
//只能看自己单位的 | |||
query.eq(Project::getBuildOrgCode,user.getEmpPosUnitCode()); | |||
query.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()); | |||
//交货时间 排序 | |||
query.isNotNull(Project::getDeliveryTime); | |||
query.orderByAsc(Project::getDeliveryTime); | |||
@@ -418,7 +420,7 @@ public class ConstructionManage { | |||
LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(param); | |||
//待采购状态 | |||
//只能看自己单位的 | |||
query.eq(Project::getBuildOrgCode,user.getEmpPosUnitCode()); | |||
query.eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()); | |||
query.eq(Project::getStatus, ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()); | |||
query.eq(Project::getStage, ProjectStatusEnum.PROJECT_APPROVED.getCode()); | |||
query.eq(Project::getNewest, Boolean.TRUE); | |||
@@ -441,7 +443,7 @@ public class ConstructionManage { | |||
exportDTO.setDeliveryTime(r.getDeliveryTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); | |||
exportDTO.setContractAmount(r.getContractAmount()); | |||
exportDTO.setAnnualPlanAmount(r.getAnnualPlanAmount()); | |||
if(Objects.nonNull(r.getTransactionTime())){ | |||
if (Objects.nonNull(r.getTransactionTime())) { | |||
exportDTO.setTransactionTime(r.getTransactionTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); | |||
} | |||
exportDTO.setTransactionAmount(r.getTransactionAmount()); | |||
@@ -459,7 +461,7 @@ public class ConstructionManage { | |||
.sheet(fileName) | |||
.doWrite(collect); | |||
} catch (Exception e) { | |||
throw new RuntimeException(e); | |||
throw new BizException(e); | |||
} | |||
} | |||
@@ -551,15 +553,16 @@ public class ConstructionManage { | |||
/** | |||
* 补充项目 合同 实际支付信息 | |||
* | |||
* @param plans | |||
* @return | |||
*/ | |||
public String supplement(List<PaymentPlanSupplementDTO> plans) { | |||
if(CollUtil.isEmpty(plans)){ | |||
if (CollUtil.isEmpty(plans)) { | |||
throw new BizException("入参"); | |||
} | |||
for(PaymentPlanSupplementDTO plan : plans){ | |||
for (PaymentPlanSupplementDTO plan : plans) { | |||
PaymentPlan paymentPlan = paymentPlanService.getById(plan.getId()); | |||
VUtils.isTrue(Objects.isNull(paymentPlan)) | |||
.throwMessage("保存失败 该支付信息不存在 :" + plan.getId()); | |||
@@ -1,15 +1,10 @@ | |||
package com.hz.pm.api.projectdeclared.manage; | |||
import cn.hutool.core.bean.BeanUtil; | |||
import cn.hutool.core.collection.CollUtil; | |||
import com.alibaba.excel.EasyExcel; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.ningdatech.basic.exception.BizException; | |||
import com.ningdatech.basic.function.VUtils; | |||
import com.ningdatech.basic.model.PageVo; | |||
import com.ningdatech.basic.util.NdDateUtils; | |||
import com.hz.pm.api.common.constant.BizConst; | |||
import com.hz.pm.api.common.constant.CommonConst; | |||
import com.hz.pm.api.common.constant.RegionConst; | |||
@@ -28,7 +23,6 @@ import com.hz.pm.api.projectdeclared.model.req.ConstrctionPlanListReq; | |||
import com.hz.pm.api.projectdeclared.service.IConstrctionSuggestionsService; | |||
import com.hz.pm.api.projectlib.enumeration.InstTypeEnum; | |||
import com.hz.pm.api.projectlib.enumeration.ProjectStatusEnum; | |||
import com.hz.pm.api.projectlib.enumeration.ProjectTypeEnum; | |||
import com.hz.pm.api.projectlib.enumeration.ProjectTypeNewEnum; | |||
import com.hz.pm.api.projectlib.helper.ProjectHelper; | |||
import com.hz.pm.api.projectlib.manage.ProjectLibManage; | |||
@@ -44,6 +38,10 @@ import com.hz.pm.api.sys.manage.NoticeManage; | |||
import com.hz.pm.api.todocenter.constant.WorkNoticeConstant; | |||
import com.hz.pm.api.user.security.auth.model.UserFullInfoDTO; | |||
import com.hz.pm.api.user.util.LoginUserUtil; | |||
import com.ningdatech.basic.exception.BizException; | |||
import com.ningdatech.basic.function.VUtils; | |||
import com.ningdatech.basic.model.PageVo; | |||
import com.ningdatech.basic.util.NdDateUtils; | |||
import com.wflow.bean.entity.WflowModels; | |||
import com.wflow.exception.BusinessException; | |||
import com.wflow.workflow.bean.dto.OrgInfoDTO; | |||
@@ -54,7 +52,6 @@ import lombok.RequiredArgsConstructor; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.flowable.engine.HistoryService; | |||
import org.flowable.engine.history.HistoricActivityInstance; | |||
import org.springframework.beans.BeanUtils; | |||
import org.springframework.stereotype.Component; | |||
import org.springframework.transaction.annotation.Transactional; | |||
@@ -93,6 +90,7 @@ public class ConstructionPlanManage { | |||
private final HistoryService historyService; | |||
private final IConstrctionSuggestionsService constrctionSuggestionsService; | |||
/** | |||
* 建设方案 | |||
* | |||
@@ -118,7 +116,7 @@ public class ConstructionPlanManage { | |||
!ProjectStatusEnum.NOT_APPROVED.getCode().equals(oldProject.getStage())) | |||
.throwMessage("提交失败 该项目不是 方案待申报状态或者未立项阶段"); | |||
if(StringUtils.isNotBlank(user.getRegionCode())){ | |||
if (StringUtils.isNotBlank(user.getRegionCode())) { | |||
projectInfo.setAreaCode(user.getRegionCode()); | |||
projectInfo.setArea(regionCacheHelper.getRegionName(user.getRegionCode(), RegionConst.RL_COUNTY)); | |||
} | |||
@@ -127,8 +125,8 @@ public class ConstructionPlanManage { | |||
projectInfo.setBuildOrgName(user.getEmpPosUnitName()); | |||
// 项目名称去重 | |||
if(StringUtils.isNotBlank(projectInfo.getProjectName()) && !projectInfo.getProjectName() | |||
.equals(oldProject.getProjectName())){ | |||
if (StringUtils.isNotBlank(projectInfo.getProjectName()) && !projectInfo.getProjectName() | |||
.equals(oldProject.getProjectName())) { | |||
projectInfo.setProjectCode(oldProject.getProjectCode()); | |||
defaultDeclaredProjectManage.checkDuplication(projectInfo); | |||
} | |||
@@ -136,13 +134,13 @@ public class ConstructionPlanManage { | |||
defaultDeclaredProjectManage.checkAmount(projectInfo); | |||
//如果主管单位没有 那么主管单位就是自己 | |||
if(CommonEnum.NO.getCode().equals(projectInfo.getIsSuperOrg())){ | |||
if (CommonEnum.NO.getCode().equals(projectInfo.getIsSuperOrg())) { | |||
projectInfo.setSuperOrgCode(user.getEmpPosUnitCode()); | |||
projectInfo.setSuperOrg(user.getEmpPosUnitName()); | |||
} | |||
Project constructProject = new Project(); | |||
BeanUtils.copyProperties(projectInfo,constructProject); | |||
BeanUtils.copyProperties(projectInfo, constructProject); | |||
constructProject.setStatus(oldProject.getStatus()); | |||
constructProject.setStage(oldProject.getStage()); | |||
@@ -159,7 +157,7 @@ public class ConstructionPlanManage { | |||
} | |||
//如果被禁用了的话 直接跳过 进入到下一个状态 | |||
if(model.getIsStop()){ | |||
if (Boolean.TRUE.equals(model.getIsStop())) { | |||
//被禁用了 调2次状态机 | |||
stateMachineUtils.pass(constructProject); | |||
stateMachineUtils.pass(constructProject); | |||
@@ -173,23 +171,23 @@ public class ConstructionPlanManage { | |||
params.setProcessUsers(Collections.emptyMap()); | |||
//放入条件判断的项目字段 | |||
//把条件值给放入工作流 | |||
defaultDeclaredProjectManage.buildCondition(params, oldProject,dto); | |||
defaultDeclaredProjectManage.buildCondition(params, oldProject, dto); | |||
// 获取发起单位、发起单位主管单位、发起单位上级条线主管单位信息 | |||
Map<String, OrgInfoDTO> orgModelMap = defaultDeclaredProjectManage.buildOrgModelMap(employeeCode, constructProject); | |||
String instanceId = processService.startProcessLs(model, params, orgModelMap); | |||
log.info("建设方案项目申报成功 【{}】", instanceId); | |||
// 保存建设项目相关 | |||
Project buildProject = new Project(); | |||
if(dto.getRestart()){ | |||
Project buildProject; | |||
if (Boolean.TRUE.equals(dto.getRestart())) { | |||
//如果是重新提交 不用生成新版本 前面已经生成过了 | |||
buildProject = contructionPlanModifyProject(oldProject, instanceId); | |||
}else{ | |||
buildProject = projectLibManage.saveConstructProjectInDeclared(projectInfo,instanceId,employeeCode,oldProject); | |||
} else { | |||
buildProject = projectLibManage.saveConstructProjectInDeclared(projectInfo, instanceId, employeeCode, oldProject); | |||
} | |||
//发送给第一个审批人消息 | |||
noticeManage.sendFirtUser(buildProject,model.getFormName(),instanceId, | |||
noticeManage.sendFirtUser(buildProject, model.getFormName(), instanceId, | |||
WorkNoticeConstant.PASS_MSG_TEMPLATE, MsgTypeEnum.PROJECT_REVIEW); | |||
return instanceId; | |||
@@ -231,8 +229,8 @@ public class ConstructionPlanManage { | |||
VUtils.isTrue(Objects.isNull(projectInfo)).throwMessage("提交失败 此项目不存在!"); | |||
VUtils.isTrue(StringUtils.isBlank(projectDto.getConstructionPlanFile())).throwMessage("提交失败 请提交建设方案!"); | |||
//直接先到待方案审批 | |||
Project project = projectLibManage.saveProjectWithVersionAndStatus(projectDto,null, | |||
ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode(),Boolean.TRUE); | |||
Project project = projectLibManage.saveProjectWithVersionAndStatus(projectDto, null, | |||
ProjectStatusEnum.PLAN_TO_BE_DECLARED.getCode(), Boolean.TRUE); | |||
dto.getProjectInfo().setId(project.getId()); | |||
dto.setRestart(Boolean.TRUE); | |||
return startTheProcess(dto); | |||
@@ -333,33 +331,34 @@ public class ConstructionPlanManage { | |||
/** | |||
* 专家建设方案建议 暂存 等流程成功后 保存到项目 | |||
* | |||
* @param dto | |||
*/ | |||
public void constructionSuggestions(ContructionSuggestionsDTO dto) { | |||
String instanceId = dto.getInstanceId(); | |||
Project project = projectService.getProjectByCode(dto.getProjectCode()); | |||
if(Objects.isNull(project)){ | |||
if (Objects.isNull(project)) { | |||
throw new BizException("该项目不存在!"); | |||
} | |||
ProjectInst projectInst = projectInstService.getOne(Wrappers.lambdaQuery(ProjectInst.class) | |||
.eq(ProjectInst::getInstCode, instanceId) | |||
.eq(ProjectInst::getProjectId,project.getId()) | |||
.eq(ProjectInst::getProjectId, project.getId()) | |||
.last(BizConst.LIMIT_1)); | |||
if(Objects.isNull(projectInst)){ | |||
if (Objects.isNull(projectInst)) { | |||
throw new BizException("该流程的项目关联信息不存在!"); | |||
} | |||
if(!InstTypeEnum.CONSTRUCTION_PLAN_REVIEW.getCode().equals(projectInst.getInstType())){ | |||
if (!InstTypeEnum.CONSTRUCTION_PLAN_REVIEW.getCode().equals(projectInst.getInstType())) { | |||
throw new BizException("此流程不是建设方案流程 保存失败!"); | |||
} | |||
ProjectConstructionSuggestions saveEntity = BeanUtil.copyProperties(dto,ProjectConstructionSuggestions.class); | |||
ProjectConstructionSuggestions saveEntity = BeanUtil.copyProperties(dto, ProjectConstructionSuggestions.class); | |||
ProjectConstructionSuggestions pcs = constrctionSuggestionsService.getOne(Wrappers.lambdaQuery(ProjectConstructionSuggestions.class) | |||
.eq(ProjectConstructionSuggestions::getProjectCode, dto.getProjectCode()) | |||
.eq(ProjectConstructionSuggestions::getInstanceId, instanceId) | |||
.last(BizConst.LIMIT_1)); | |||
if(Objects.nonNull(pcs)){ | |||
if (Objects.nonNull(pcs)) { | |||
saveEntity.setId(pcs.getId()); | |||
} | |||
saveEntity.setInstanceId(instanceId); | |||
@@ -1,10 +1,11 @@ | |||
package com.hz.pm.api.projectdeclared.model.entity; | |||
import com.baomidou.mybatisplus.annotation.*; | |||
import com.baomidou.mybatisplus.annotation.IdType; | |||
import com.baomidou.mybatisplus.annotation.TableId; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import org.joda.time.LocalDate; | |||
import java.math.BigDecimal; | |||
import java.time.LocalDateTime; | |||
@@ -2,7 +2,6 @@ package com.hz.pm.api.projectdeclared.service; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.baomidou.mybatisplus.extension.service.IService; | |||
import com.hz.pm.api.common.constant.BizConst; | |||
import com.hz.pm.api.projectdeclared.model.entity.Purchase; | |||
import java.util.List; | |||
@@ -1,33 +1,31 @@ | |||
package com.hz.pm.api.projectlib.handle; | |||
import java.time.LocalDateTime; | |||
import java.util.List; | |||
import java.util.Objects; | |||
import cn.hutool.core.collection.CollUtil; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.google.common.collect.Lists; | |||
import com.ningdatech.basic.exception.BizException; | |||
import com.ningdatech.basic.util.NdDateUtils; | |||
import com.hz.pm.api.common.constant.BizConst; | |||
import com.hz.pm.api.common.constant.CommonConst; | |||
import com.hz.pm.api.projectlib.enumeration.InstTypeEnum; | |||
import com.hz.pm.api.projectlib.model.entity.Project; | |||
import com.hz.pm.api.projectlib.model.entity.ProjectInst; | |||
import com.hz.pm.api.projectlib.service.IProjectInstService; | |||
import com.hz.pm.api.projectlib.service.IProjectService; | |||
import com.hz.pm.api.projectlib.utils.ProjectVersionUtil; | |||
import com.hz.pm.api.todocenter.constant.TodoCenterConstant; | |||
import com.hz.pm.api.todocenter.utils.BuildUserUtils; | |||
import com.ningdatech.basic.util.NdDateUtils; | |||
import com.wflow.workflow.bean.process.ProgressNode; | |||
import com.wflow.workflow.bean.vo.ProcessDetailVO; | |||
import com.wflow.workflow.bean.vo.ProcessProgressVo; | |||
import com.wflow.workflow.enums.ProcessStatusEnum; | |||
import com.wflow.workflow.enums.StepStatusEnum; | |||
import com.wflow.workflow.service.ProcessInstanceService; | |||
import org.springframework.core.annotation.Order; | |||
import org.springframework.stereotype.Component; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.hz.pm.api.common.constant.CommonConst; | |||
import com.hz.pm.api.projectlib.enumeration.InstTypeEnum; | |||
import com.hz.pm.api.projectlib.model.entity.ProjectInst; | |||
import com.hz.pm.api.projectlib.service.IProjectInstService; | |||
import com.wflow.workflow.bean.vo.ProcessProgressVo; | |||
import com.wflow.workflow.enums.ProcessStatusEnum; | |||
import com.wflow.workflow.service.ProcessInstanceService; | |||
import java.time.LocalDateTime; | |||
import java.util.List; | |||
import java.util.Objects; | |||
/** | |||
* 建设方案评审处理 | |||
@@ -47,7 +45,7 @@ public class ConstructionPlanReviewHandle extends AbstractProcessBusinessHandle | |||
private Integer order = 7; | |||
public ConstructionPlanReviewHandle(IProjectInstService projectInstService, ProcessInstanceService processInstanceService, BuildUserUtils buildUserUtils, ProjectVersionUtil projectVersionUtil, IProjectService projectService){ | |||
public ConstructionPlanReviewHandle(IProjectInstService projectInstService, ProcessInstanceService processInstanceService, BuildUserUtils buildUserUtils, ProjectVersionUtil projectVersionUtil, IProjectService projectService) { | |||
this.projectInstService = projectInstService; | |||
this.processInstanceService = processInstanceService; | |||
this.buildUserUtils = buildUserUtils; | |||
@@ -71,22 +69,22 @@ public class ConstructionPlanReviewHandle extends AbstractProcessBusinessHandle | |||
ProcessProgressVo instanceDetail = null; | |||
// 未找到当前版本项目的建设方案审核流程且当前项目版本号大于1(是被驳回重新申报的项目) | |||
if (Objects.isNull(projectInst)) { | |||
if (project.getVersion() > CommonConst.VERSION_ONE ){ | |||
if (project.getVersion() > CommonConst.VERSION_ONE) { | |||
// 获取上个版本的信息 | |||
instanceDetail = projectVersionUtil.getPreVerProcessInfo(projectId,InstTypeEnum.CONSTRUCTION_PLAN_REVIEW); | |||
instanceDetail = projectVersionUtil.getPreVerProcessInfo(projectId, InstTypeEnum.CONSTRUCTION_PLAN_REVIEW); | |||
} | |||
}else { | |||
} else { | |||
String instCode = projectInst.getInstCode(); | |||
instanceDetail = processInstanceService.getProgressInstanceDetail(null, instCode); | |||
} | |||
if (Objects.isNull(instanceDetail)){ | |||
if (Objects.isNull(instanceDetail)) { | |||
processDetailVO.setStepStatus(StepStatusEnum.NOT_START); | |||
processDetailVO.setProcessName(CommonConst.CONSTRUCTION_PLAN_REVIEW); | |||
processSchedule.add(processDetailVO); | |||
return; | |||
} | |||
String status = instanceDetail.getStatus(); | |||
if (ProcessStatusEnum.UNDER_REVIEW.getDesc().equals(status)){ | |||
if (ProcessStatusEnum.UNDER_REVIEW.getDesc().equals(status)) { | |||
processDetailVO.setStepStatus(StepStatusEnum.ON_GOING); | |||
} else if (ProcessStatusEnum.BE_REJECTED.getDesc().equals(status)) { | |||
processDetailVO.setStepStatus(StepStatusEnum.REJECTED); | |||
@@ -106,7 +104,7 @@ public class ConstructionPlanReviewHandle extends AbstractProcessBusinessHandle | |||
LocalDateTime finishTime = NdDateUtils.date2LocalDateTime(progressNode.getFinishTime()); | |||
processDetailVO.setFinishTime(finishTime); | |||
} | |||
}else { | |||
} else { | |||
LocalDateTime finishTime = NdDateUtils.date2LocalDateTime(instanceDetail.getStartTime()); | |||
processDetailVO.setFinishTime(finishTime); | |||
} | |||
@@ -102,7 +102,7 @@ public class ApplicationManage { | |||
headers.add(entry.getKey(), entry.getValue()); | |||
} | |||
//封装请求头 | |||
HttpEntity<MultiValueMap<String, Object>> formEntity = new HttpEntity<MultiValueMap<String, Object>>(headers); | |||
HttpEntity<MultiValueMap<String, Object>> formEntity = new HttpEntity<>(headers); | |||
RestTemplate restTemplate = new RestTemplate(); | |||
ResponseEntity<ApiResponse> forEntity = restTemplate.exchange(appUrl, HttpMethod.GET,formEntity, ApiResponse.class); | |||
@@ -4,7 +4,6 @@ import com.hz.pm.api.organization.model.vo.ProvincialGovBusinessStripVO; | |||
import com.hz.pm.api.provincial.model.dto.ProvincialProjectDTO; | |||
import com.hz.pm.api.provincial.model.res.SjApiResponse; | |||
import java.security.NoSuchAlgorithmException; | |||
import java.util.List; | |||
/** | |||
@@ -152,7 +152,7 @@ public class JoinReviewProvincialBureauServiceImpl implements IJoinReviewProvinc | |||
@Override | |||
public List<ProvincialGovBusinessStripVO> searchGovUnits() { | |||
Long timeStamp = System.currentTimeMillis(); | |||
long timeStamp = System.currentTimeMillis(); | |||
Long timeSeconds = System.currentTimeMillis()/1000; | |||
String appSecret = govAppSecret; | |||
String appKey = govAppKey; | |||
@@ -9,6 +9,9 @@ package com.hz.pm.api.sys.utils; | |||
*/ | |||
public class AuthCacheKeyUtils { | |||
private AuthCacheKeyUtils() { | |||
} | |||
private static final String USER_RESOURCE_CKP = "user_resource:"; | |||
private static final String USER_MENU_CKP = "user_menu:"; | |||
private static final String USER_ROLE_CKP = "user_role:"; | |||
@@ -1,5 +1,7 @@ | |||
package com.hz.pm.api.user.security.auth.constants; | |||
import com.ningdatech.basic.exception.BizException; | |||
/** | |||
* @author Liuxinxin | |||
* @date 2021/7/30 下午2:10 | |||
@@ -42,6 +44,6 @@ public enum AuthTypeEnum { | |||
return value; | |||
} | |||
} | |||
throw new RuntimeException(String.format("invalid AuthTypeEnum = %s", key)); | |||
throw BizException.wrap("无效的授权类型:", key); | |||
} | |||
} |
@@ -1,11 +1,9 @@ | |||
package com.hz.pm.api.user.security.auth.handler; | |||
import com.fasterxml.jackson.databind.ObjectMapper; | |||
import com.ningdatech.basic.model.ApiResponse; | |||
import com.hz.pm.api.user.security.auth.errorcode.AuthErrorCodeEnum; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import com.ningdatech.basic.model.ApiResponse; | |||
import lombok.RequiredArgsConstructor; | |||
import org.springframework.http.HttpStatus; | |||
import org.springframework.security.web.session.SessionInformationExpiredEvent; | |||
import org.springframework.security.web.session.SessionInformationExpiredStrategy; | |||
@@ -20,12 +18,13 @@ import java.io.IOException; | |||
* @Version 1.0 | |||
**/ | |||
@Component | |||
@RequiredArgsConstructor | |||
public class DefaultExpiredSessionStrategy implements SessionInformationExpiredStrategy { | |||
public static final Logger LOG = LoggerFactory.getLogger(DefaultExpiredSessionStrategy.class); | |||
private final ObjectMapper objectMapper; | |||
private static final ApiResponse<Void> SESSION_EXPIRED = ApiResponse.of(AuthErrorCodeEnum.SESSION_EXPIRED.getCode(), | |||
AuthErrorCodeEnum.SESSION_EXPIRED.getMsg()); | |||
@Autowired | |||
private ObjectMapper objectMapper; | |||
@Override | |||
public void onExpiredSessionDetected(SessionInformationExpiredEvent sessionInformationExpiredEvent) | |||
@@ -33,7 +32,7 @@ public class DefaultExpiredSessionStrategy implements SessionInformationExpiredS | |||
HttpServletResponse response = sessionInformationExpiredEvent.getResponse(); | |||
response.setStatus(HttpStatus.UNAUTHORIZED.value()); | |||
response.setContentType("application/json;charset=UTF-8"); | |||
response.getWriter().write(objectMapper.writeValueAsString( | |||
ApiResponse.of(AuthErrorCodeEnum.SESSION_EXPIRED.getCode(), AuthErrorCodeEnum.SESSION_EXPIRED.getMsg(), null))); | |||
response.getWriter().write(objectMapper.writeValueAsString(SESSION_EXPIRED)); | |||
} | |||
} |