forked from luyan/epmet-cloud-lingshan
223 changed files with 5909 additions and 524 deletions
@ -0,0 +1,9 @@ |
|||||
|
INSERT INTO `epmet_admin`.`sys_dict_type` (`id`, `dict_type`, `dict_name`, `remark`, `sort`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1518396655261097986', 'item_type_query', '居民信息组件查询方式', '', 18, 0, 0, '1', '2022-04-25 09:09:08', '1', '2022-04-25 09:09:45'); |
||||
|
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `dict_p_value`, `remark`, `sort`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1518420223504064513', 1518396655261097986, 'equal', 'cascader', '0', '级联组件', 8, 0, 0, '1', '2022-04-25 10:42:47', '1', '2022-04-25 10:42:47'); |
||||
|
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `dict_p_value`, `remark`, `sort`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1518398370672713730', 1518396655261097986, 'list_equal', 'checkbox', '0', '多选框', 6, 0, 0, '1', '2022-04-25 09:15:57', '1', '2022-04-25 09:15:57'); |
||||
|
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `dict_p_value`, `remark`, `sort`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1518397686728531969', 1518396655261097986, 'daterange', 'datepicker', '0', '日期', 3, 0, 0, '1', '2022-04-25 09:13:14', '1', '2022-04-25 09:13:14'); |
||||
|
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `dict_p_value`, `remark`, `sort`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1518398756393492482', 1518396655261097986, 'daterange', 'daterange', '0', '时间范围组件eg:参战时间', 7, 0, 0, '1', '2022-04-25 09:17:29', '1', '2022-04-25 09:17:29'); |
||||
|
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `dict_p_value`, `remark`, `sort`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1518397589986910209', 1518396655261097986, 'like', 'input', '0', '文本输入框', 2, 0, 0, '1', '2022-04-25 09:12:51', '1', '2022-04-25 09:12:51'); |
||||
|
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `dict_p_value`, `remark`, `sort`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1518398274627346434', 1518396655261097986, 'equal', 'radio', '0', '单选框', 5, 0, 0, '1', '2022-04-25 09:15:34', '1', '2022-04-25 09:15:34'); |
||||
|
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `dict_p_value`, `remark`, `sort`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1518397514623655938', 1518396655261097986, 'equal', 'select', '0', '下拉框', 1, 0, 0, '1', '2022-04-25 09:12:33', '1', '2022-04-25 09:12:33'); |
||||
|
INSERT INTO `epmet_admin`.`sys_dict_data` (`id`, `dict_type_id`, `dict_label`, `dict_value`, `dict_p_value`, `remark`, `sort`, `DEL_FLAG`, `REVISION`, `CREATED_BY`, `CREATED_TIME`, `UPDATED_BY`, `UPDATED_TIME`) VALUES ('1518397787941281794', 1518396655261097986, 'like', 'textarea', '0', '文本域', 4, 0, 0, '1', '2022-04-25 09:13:38', '1', '2022-04-25 09:13:38'); |
@ -0,0 +1,25 @@ |
|||||
|
package com.epmet.auth.dto.result; |
||||
|
|
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
/** |
||||
|
* @ClassName BlockChainStaffAuthResultDTO |
||||
|
* @Description 区块链用户认证结果 |
||||
|
* @Author wangxianzhang |
||||
|
* @Date 2022/1/20 10:41 上午 |
||||
|
*/ |
||||
|
@Data |
||||
|
@NoArgsConstructor |
||||
|
@AllArgsConstructor |
||||
|
public class BlockChainStaffAuthResultDTO { |
||||
|
|
||||
|
private String userId; |
||||
|
private String realName; |
||||
|
private String phone; |
||||
|
private String headUrl; |
||||
|
private String agencyId; |
||||
|
private String agencyName; |
||||
|
|
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
|
||||
|
/** |
||||
|
* @ClassName BcAdminLoginFormDTO |
||||
|
* @Description 区块链管理系统staff身份认证 |
||||
|
* @Author wangxianzhang |
||||
|
* @Date 2022/1/17 10:11 下午 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class BcStaffAuthenticationFormDTO { |
||||
|
|
||||
|
@NotBlank(message = "客户ID必填") |
||||
|
private String customerId; |
||||
|
|
||||
|
@NotBlank(message = "手机号必填") |
||||
|
private String mobile; |
||||
|
|
||||
|
@NotBlank(message = "密码必填") |
||||
|
private String password; |
||||
|
} |
@ -0,0 +1,44 @@ |
|||||
|
package com.epmet.commons.tools.annotation; |
||||
|
|
||||
|
import com.epmet.commons.tools.enums.RequirePermissionEnum; |
||||
|
import javassist.runtime.Inner; |
||||
|
|
||||
|
import java.lang.annotation.*; |
||||
|
import java.util.function.Function; |
||||
|
|
||||
|
/** |
||||
|
* 标记一个接口,它的返回值中的某些字段需要打掩码 |
||||
|
*/ |
||||
|
@Target(ElementType.METHOD) |
||||
|
@Retention(RetentionPolicy.RUNTIME) |
||||
|
@Documented |
||||
|
public @interface MaskResponse { |
||||
|
|
||||
|
/** |
||||
|
* 掩码类型 |
||||
|
*/ |
||||
|
String MASK_TYPE_ID_CARD = "ID_CARD"; |
||||
|
String MASK_TYPE_MOBILE = "MOBILE"; |
||||
|
|
||||
|
///**
|
||||
|
// * 默认的一些字段,如果没有手动指定,就会使用默认的。如果手动指定了,就不再使用默认的
|
||||
|
// */
|
||||
|
//String[] defaultFieldnames = {"idCard","mobile","phone"};
|
||||
|
//
|
||||
|
///**
|
||||
|
// * 默认字段对应的掩码类型
|
||||
|
// */
|
||||
|
//String[] defaultFieldsMaskType = { MASK_TYPE_ID_CARD, MASK_TYPE_MOBILE, MASK_TYPE_MOBILE };
|
||||
|
|
||||
|
/** |
||||
|
* 要打码的字段列表。会递归的着这些字段 |
||||
|
* @return |
||||
|
*/ |
||||
|
String[] fieldNames() default {"idCard","mobile","phone"}; |
||||
|
|
||||
|
/** |
||||
|
* 要打码的类型 |
||||
|
* @return |
||||
|
*/ |
||||
|
String[] fieldsMaskType() default { MASK_TYPE_ID_CARD, MASK_TYPE_MOBILE, MASK_TYPE_MOBILE }; |
||||
|
} |
@ -0,0 +1,36 @@ |
|||||
|
package com.epmet.commons.tools.aspect; |
||||
|
|
||||
|
import com.epmet.commons.tools.annotation.MaskResponse; |
||||
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
||||
|
import com.epmet.commons.tools.exception.EpmetException; |
||||
|
import com.epmet.commons.tools.processor.MaskProcessor; |
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import org.aspectj.lang.JoinPoint; |
||||
|
import org.aspectj.lang.annotation.AfterReturning; |
||||
|
import org.aspectj.lang.annotation.Aspect; |
||||
|
import org.aspectj.lang.reflect.MethodSignature; |
||||
|
import org.springframework.core.annotation.Order; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
@Aspect |
||||
|
@Component |
||||
|
@Order(0) |
||||
|
public class MaskResponseAspect { |
||||
|
|
||||
|
@AfterReturning(pointcut = "@annotation(com.epmet.commons.tools.annotation.MaskResponse)", returning = "result") |
||||
|
public Object proceed(JoinPoint point, Result result) throws Throwable { |
||||
|
MethodSignature signature = (MethodSignature) point.getSignature(); |
||||
|
MaskResponse maskResponseAnno = signature.getMethod().getAnnotation(MaskResponse.class); |
||||
|
|
||||
|
String[] fieldNames = maskResponseAnno.fieldNames(); |
||||
|
String[] fieldsMaskType = maskResponseAnno.fieldsMaskType(); |
||||
|
|
||||
|
if (fieldNames.length != fieldsMaskType.length) { |
||||
|
String msg = "掩码配置错误"; |
||||
|
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), msg, msg); |
||||
|
} |
||||
|
|
||||
|
new MaskProcessor(fieldNames, fieldsMaskType).mask(result); |
||||
|
return null; |
||||
|
} |
||||
|
} |
@ -0,0 +1,78 @@ |
|||||
|
package com.epmet.commons.tools.dto.form; |
||||
|
|
||||
|
import com.epmet.commons.tools.validator.group.AddGroup; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import javax.validation.constraints.NotEmpty; |
||||
|
import java.io.Serializable; |
||||
|
import java.util.List; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 自定义表单导出模板 |
||||
|
* |
||||
|
* @author generator generator@elink-cn.com |
||||
|
* @since v1.0.0 2022-04-21 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class IcExportItemListFormDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
@NotEmpty(message = "请至少添加一个导出项") |
||||
|
private List<IcExportItemListFormDTO> children; |
||||
|
|
||||
|
/** |
||||
|
* 父id |
||||
|
*/ |
||||
|
private String pid; |
||||
|
|
||||
|
/** |
||||
|
* ic_form_item.id |
||||
|
*/ |
||||
|
@NotBlank(message = "itemId不能为空",groups = AddGroup.class) |
||||
|
private String itemId; |
||||
|
|
||||
|
/** |
||||
|
* 表头宽度 |
||||
|
*/ |
||||
|
private Integer width; |
||||
|
|
||||
|
/** |
||||
|
* 项标签 |
||||
|
*/ |
||||
|
@NotBlank(message = "名称不能为空",groups = AddGroup.class) |
||||
|
private String label; |
||||
|
|
||||
|
/** |
||||
|
* 排序 |
||||
|
*/ |
||||
|
private Integer sort; |
||||
|
|
||||
|
/** |
||||
|
* 表名 |
||||
|
*/ |
||||
|
private String tableName; |
||||
|
|
||||
|
/** |
||||
|
* 列名 |
||||
|
*/ |
||||
|
private String columnName; |
||||
|
|
||||
|
/** |
||||
|
* item选项 值 |
||||
|
*/ |
||||
|
private String optionSourceValue; |
||||
|
/** |
||||
|
* item选项 值获取方式 |
||||
|
*/ |
||||
|
private String optionSourceType; |
||||
|
|
||||
|
/** |
||||
|
* 是否支持添加(即多对一,eg:需求列表) |
||||
|
*/ |
||||
|
private boolean supportAdd; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,58 @@ |
|||||
|
package com.epmet.commons.tools.dto.form; |
||||
|
|
||||
|
import com.epmet.commons.tools.validator.group.AddGroup; |
||||
|
import lombok.Data; |
||||
|
import org.hibernate.validator.constraints.Length; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import javax.validation.constraints.NotEmpty; |
||||
|
import java.io.Serializable; |
||||
|
import java.util.List; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 自定义表单导出模板 |
||||
|
* |
||||
|
* @author generator generator@elink-cn.com |
||||
|
* @since v1.0.0 2022-04-21 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class IcExportTemplateSaveFormDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 是否保存为模板 是:true 否:false |
||||
|
*/ |
||||
|
private Boolean isSaveTemp = false; |
||||
|
|
||||
|
/** |
||||
|
* 表单CODE,从字典获取 |
||||
|
*/ |
||||
|
@NotBlank(message = "表单CODE不能为空",groups = AddGroup.class) |
||||
|
private String formCode; |
||||
|
|
||||
|
/** |
||||
|
* 模板名称 |
||||
|
*/ |
||||
|
@Length(max = 20, message = "模板名称最多为20个字", groups = { AddGroup.class }) |
||||
|
private String name; |
||||
|
|
||||
|
/** |
||||
|
* 0:动态;1:文件 |
||||
|
*/ |
||||
|
private Integer type; |
||||
|
|
||||
|
/** |
||||
|
* 排序 |
||||
|
*/ |
||||
|
private Integer sort; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 父id |
||||
|
*/ |
||||
|
@NotEmpty(message = "请至少添加一个导出项") |
||||
|
private List<IcExportItemListFormDTO> itemList; |
||||
|
|
||||
|
} |
@ -0,0 +1,183 @@ |
|||||
|
package com.epmet.commons.tools.processor; |
||||
|
|
||||
|
import cn.hutool.core.util.StrUtil; |
||||
|
import com.epmet.commons.tools.annotation.MaskResponse; |
||||
|
import com.epmet.commons.tools.exception.ExceptionUtils; |
||||
|
import com.epmet.commons.tools.page.PageData; |
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.util.CollectionUtils; |
||||
|
|
||||
|
import java.lang.reflect.Field; |
||||
|
import java.util.Arrays; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.regex.Pattern; |
||||
|
|
||||
|
@Slf4j |
||||
|
public class MaskProcessor { |
||||
|
|
||||
|
|
||||
|
public static final String EPMET_PACKAGE_PREFIX = "com.epmet"; |
||||
|
|
||||
|
private List<String> fieldNames; |
||||
|
private List<String> fieldsMaskType; |
||||
|
|
||||
|
public MaskProcessor(String[] fields, String[] fieldsMaskType) { |
||||
|
if (fields != null && fields.length > 0) { |
||||
|
this.fieldNames = Arrays.asList(fields); |
||||
|
this.fieldsMaskType = Arrays.asList(fieldsMaskType); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 为dto中的属性打掩码 |
||||
|
* @param object |
||||
|
*/ |
||||
|
public void mask(Object object) { |
||||
|
if (object == null) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
if (object instanceof Result) { |
||||
|
mask(((Result<?>) object).getData()); |
||||
|
return; |
||||
|
} else if (object instanceof PageData) { |
||||
|
mask(((PageData<?>) object).getList()); |
||||
|
return; |
||||
|
} else if (object instanceof List) { |
||||
|
((List)object).forEach(e -> mask(e)); |
||||
|
return; |
||||
|
} else if (object instanceof Map) { |
||||
|
maskMap((Map) object); |
||||
|
return; |
||||
|
} else if (object.getClass().getName().startsWith(EPMET_PACKAGE_PREFIX)) { |
||||
|
// 自定义bean,走反射
|
||||
|
maskEpmetBean(object); |
||||
|
return; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 为map打码,只打value中的码 |
||||
|
* - 如果value是epmet的dto,那么去反射它 |
||||
|
* - 如果value是字符串,那么直接给他打码 |
||||
|
* - 如果value是其他类型,跳过 |
||||
|
* @param map |
||||
|
*/ |
||||
|
private void maskMap(Map<Object, Object> map) { |
||||
|
if (CollectionUtils.isEmpty(map)) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
for (Map.Entry<Object, Object> entry : map.entrySet()) { |
||||
|
Object value = entry.getValue(); |
||||
|
Object key = entry.getKey(); |
||||
|
if (value != null && value.getClass().getName().startsWith(EPMET_PACKAGE_PREFIX)) { |
||||
|
// 是epmet的对象
|
||||
|
maskEpmetBean(value); |
||||
|
continue; |
||||
|
} else if (value instanceof String) { |
||||
|
int index = fieldNames.indexOf(key); |
||||
|
if (index != -1) { |
||||
|
String maskResult = maskString((String) value, fieldsMaskType.get(index)); |
||||
|
entry.setValue(maskResult); |
||||
|
} |
||||
|
continue; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 反射 |
||||
|
* @param object |
||||
|
*/ |
||||
|
private void maskEpmetBean(Object object) { |
||||
|
Field[] declaredFields = object.getClass().getDeclaredFields(); |
||||
|
for (Field currentField : declaredFields) { |
||||
|
currentField.setAccessible(true); |
||||
|
try { |
||||
|
String fieldName = currentField.getName(); |
||||
|
Object value = currentField.get(object); |
||||
|
// 是epmet的类,继续下钻
|
||||
|
if (currentField.getClass().getName().startsWith(EPMET_PACKAGE_PREFIX)) { |
||||
|
maskEpmetBean(value); |
||||
|
continue; |
||||
|
} |
||||
|
|
||||
|
// 是字符串
|
||||
|
String fieldValue; |
||||
|
if (value instanceof String && StringUtils.isNotBlank(fieldValue = (String) value)) { |
||||
|
int fieldIndexInAnnoAttrs = fieldNames.indexOf(fieldName); |
||||
|
if (fieldIndexInAnnoAttrs != -1) { |
||||
|
String product = maskString(fieldValue, fieldsMaskType.get(fieldIndexInAnnoAttrs)); |
||||
|
currentField.set(object, product); |
||||
|
} |
||||
|
continue; |
||||
|
} |
||||
|
|
||||
|
// 非字符串,非epmet类的其他类型
|
||||
|
mask(value); |
||||
|
} catch (IllegalAccessException e) { |
||||
|
log.error("【mask一些字段报错】{}", ExceptionUtils.getErrorStackTrace(e)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 把字符串变更为掩码 |
||||
|
* @param originString |
||||
|
* @return |
||||
|
*/ |
||||
|
public String maskString(String originString, String maskType) { |
||||
|
if (MaskResponse.MASK_TYPE_ID_CARD.equals(maskType)) { |
||||
|
return maskIdCard(originString); |
||||
|
} else if (MaskResponse.MASK_TYPE_MOBILE.equals(maskType)) { |
||||
|
return maskMobile(originString); |
||||
|
} else { |
||||
|
return originString; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 将明文字符串打码变为掩码。保留前6,后面打码 |
||||
|
* @param originString |
||||
|
* @return |
||||
|
*/ |
||||
|
private String maskIdCard(String originString) { |
||||
|
// 仅将6位之后的全都打码
|
||||
|
int length = originString.length(); |
||||
|
if (length <= 6) { |
||||
|
return originString; |
||||
|
} |
||||
|
|
||||
|
String maskStr = StrUtil.repeatByLength("*", length - 6); |
||||
|
|
||||
|
return originString.replaceAll("^(\\d{6})[a-zA-Z0-9]*$", new StringBuilder("$1").append(maskStr).toString()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 将明文字符串打码变为掩码。保留前3后4,中间打码 |
||||
|
* 187****3461 |
||||
|
* @param originString |
||||
|
* @return |
||||
|
*/ |
||||
|
private String maskMobile(String originString) { |
||||
|
int length = originString.length(); |
||||
|
if (length <= 7) { |
||||
|
return originString; |
||||
|
} |
||||
|
|
||||
|
String maskStr = StrUtil.repeatByLength("*", length - 7); |
||||
|
|
||||
|
return originString.replaceAll("^(1\\d{2})\\d*(\\d{4})$", new StringBuilder("$1").append(maskStr).append("$2").toString()); |
||||
|
} |
||||
|
|
||||
|
public static void main(String[] args) { |
||||
|
String[] idc = {"idCard"}; |
||||
|
String[] idct = {MaskResponse.MASK_TYPE_ID_CARD}; |
||||
|
String r = new MaskProcessor(idc, idct).maskString("333333333333333333", MaskResponse.MASK_TYPE_ID_CARD); |
||||
|
System.out.println(r); |
||||
|
} |
||||
|
} |
@ -0,0 +1,389 @@ |
|||||
|
package com.epmet.commons.tools.utils; |
||||
|
|
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
|
||||
|
import java.io.*; |
||||
|
import java.nio.charset.StandardCharsets; |
||||
|
import java.security.MessageDigest; |
||||
|
import java.security.NoSuchAlgorithmException; |
||||
|
import java.util.*; |
||||
|
|
||||
|
/** |
||||
|
* desc: 市北大数据局的工具 |
||||
|
* |
||||
|
* @return |
||||
|
* @author LiuJanJun |
||||
|
* @date 2022/4/22 5:19 下午 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
public class AuthCodeUtil { |
||||
|
|
||||
|
public enum DiscuzAuthcodeMode { |
||||
|
Encode, Decode |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* <summary> |
||||
|
* 从字符串的指定位置截取指定长度的子字符串 |
||||
|
* </summary> |
||||
|
* <param name="str">原字符串</param> |
||||
|
* <param name="startIndex">子字符串的起始位置</param> |
||||
|
* <param name="length">子字符串的长度</param> |
||||
|
* <returns>子字符串</returns> |
||||
|
*/ |
||||
|
public static String CutString(String str, int startIndex, int length) { |
||||
|
if (startIndex >= 0) { |
||||
|
if (length < 0) { |
||||
|
length = length * -1; |
||||
|
if (startIndex - length < 0) { |
||||
|
length = startIndex; |
||||
|
startIndex = 0; |
||||
|
} else { |
||||
|
startIndex = startIndex - length; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (startIndex > str.length()) { |
||||
|
return ""; |
||||
|
} |
||||
|
|
||||
|
} else { |
||||
|
if (length < 0) { |
||||
|
return ""; |
||||
|
} else { |
||||
|
if (length + startIndex > 0) { |
||||
|
length = length + startIndex; |
||||
|
startIndex = 0; |
||||
|
} else { |
||||
|
return ""; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (str.length() - startIndex < length) { |
||||
|
|
||||
|
length = str.length() - startIndex; |
||||
|
} |
||||
|
|
||||
|
return str.substring(startIndex, startIndex + length); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* <summary> |
||||
|
* 从字符串的指定位置开始截取到字符串结尾的了符串 |
||||
|
* </summary> |
||||
|
* <param name="str">原字符串</param> |
||||
|
* <param name="startIndex">子字符串的起始位置</param> |
||||
|
* <returns>子字符串</returns> |
||||
|
*/ |
||||
|
public static String CutString(String str, int startIndex) { |
||||
|
return CutString(str, startIndex, str.length()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* <summary> |
||||
|
* 返回文件是否存在 |
||||
|
* </summary> |
||||
|
* <param name="filename">文件名</param> |
||||
|
* <returns>是否存在</returns> |
||||
|
*/ |
||||
|
public static boolean FileExists(String filename) { |
||||
|
File f = new File(filename); |
||||
|
return f.exists(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* <summary> |
||||
|
* MD5函数 |
||||
|
* </summary> |
||||
|
* <param name="str">原始字符串</param> |
||||
|
* <returns>MD5结果</returns> |
||||
|
*/ |
||||
|
public static String MD5(String str) { |
||||
|
StringBuffer sb = new StringBuffer(); |
||||
|
String part = null; |
||||
|
try { |
||||
|
MessageDigest md = MessageDigest.getInstance("MD5"); |
||||
|
byte[] md5 = md.digest(str.getBytes()); |
||||
|
|
||||
|
for (int i = 0; i < md5.length; i++) { |
||||
|
part = Integer.toHexString(md5[i] & 0xFF); |
||||
|
if (part.length() == 1) { |
||||
|
part = "0" + part; |
||||
|
} |
||||
|
sb.append(part); |
||||
|
} |
||||
|
|
||||
|
} catch (NoSuchAlgorithmException ex) { |
||||
|
} |
||||
|
return sb.toString(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* <summary> |
||||
|
* 字段串是否为Null或为""(空) |
||||
|
* </summary> |
||||
|
* <param name="str"></param> |
||||
|
* <returns></returns> |
||||
|
*/ |
||||
|
public static boolean StrIsNullOrEmpty(String str) { |
||||
|
// if NET1
|
||||
|
if (str == null || str.trim().equals("")) { |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* <summary> |
||||
|
* 用于 RC4 处理密码 |
||||
|
* </summary> |
||||
|
* <param name="pass">密码字串</param> |
||||
|
* <param name="kLen">密钥长度,一般为 256</param> |
||||
|
* <returns></returns> |
||||
|
*/ |
||||
|
static private byte[] GetKey(byte[] pass, int kLen) { |
||||
|
byte[] mBox = new byte[kLen]; |
||||
|
|
||||
|
for (int i = 0; i < kLen; i++) { |
||||
|
mBox[i] = (byte) i; |
||||
|
} |
||||
|
|
||||
|
int j = 0; |
||||
|
for (int i = 0; i < kLen; i++) { |
||||
|
|
||||
|
j = (j + (int) ((mBox[i] + 256) % 256) + pass[i % pass.length]) |
||||
|
% kLen; |
||||
|
|
||||
|
byte temp = mBox[i]; |
||||
|
mBox[i] = mBox[j]; |
||||
|
mBox[j] = temp; |
||||
|
} |
||||
|
|
||||
|
return mBox; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* <summary> |
||||
|
* 生成随机字符 |
||||
|
* </summary> |
||||
|
* <param name="lens">随机字符长度</param> |
||||
|
* <returns>随机字符</returns> |
||||
|
*/ |
||||
|
public static String RandomString(int lens) { |
||||
|
char[] CharArray = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', |
||||
|
'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', |
||||
|
'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; |
||||
|
int clens = CharArray.length; |
||||
|
String sCode = ""; |
||||
|
Random random = new Random(); |
||||
|
for (int i = 0; i < lens; i++) { |
||||
|
sCode += CharArray[Math.abs(random.nextInt(clens))]; |
||||
|
} |
||||
|
return sCode; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* <summary> |
||||
|
* 使用 Discuz authcode 方法对字符串加密 |
||||
|
* </summary> |
||||
|
* <param name="source">原始字符串</param> |
||||
|
* <param name="key">密钥</param> |
||||
|
* <param name="expiry">加密字串有效时间,单位是秒</param> |
||||
|
* <returns>加密结果</returns> |
||||
|
*/ |
||||
|
public static String authcodeEncode(String source, String key, int expiry) { |
||||
|
return authcode(source, key, DiscuzAuthcodeMode.Encode, expiry); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* <summary> |
||||
|
* 使用 Discuz authcode 方法对字符串加密 |
||||
|
* </summary> |
||||
|
* <param name="source">原始字符串</param> |
||||
|
* <param name="key">密钥</param> |
||||
|
* <returns>加密结果</returns> |
||||
|
*/ |
||||
|
public static String authcodeEncode(String source, String key) { |
||||
|
return authcode(source, key, DiscuzAuthcodeMode.Encode, 0); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* <summary> |
||||
|
* 使用 Discuz authcode 方法对字符串解密 |
||||
|
* </summary> |
||||
|
* <param name="source">原始字符串</param> |
||||
|
* <param name="key">密钥</param> |
||||
|
* <returns>解密结果</returns> |
||||
|
*/ |
||||
|
public static String authcodeDecode(String source, String key) { |
||||
|
return authcode(source, key, DiscuzAuthcodeMode.Decode, 0); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* <summary> |
||||
|
* 使用 变形的 rc4 编码方法对字符串进行加密或者解密 |
||||
|
* </summary> |
||||
|
* <param name="source">原始字符串</param> |
||||
|
* <param name="key">密钥</param> |
||||
|
* <param name="operation">操作 加密还是解密</param> |
||||
|
* <param name="expiry">加密字串过期时间</param> |
||||
|
* <returns>加密或者解密后的字符串</returns> |
||||
|
*/ |
||||
|
private static String authcode(String source, String key, |
||||
|
DiscuzAuthcodeMode operation, int expiry) { |
||||
|
try { |
||||
|
if (source == null || key == null) { |
||||
|
return ""; |
||||
|
} |
||||
|
|
||||
|
int ckey_length = 4; |
||||
|
String keya, keyb, keyc, cryptkey, result; |
||||
|
|
||||
|
key = MD5(key); |
||||
|
|
||||
|
keya = MD5(CutString(key, 0, 16)); |
||||
|
|
||||
|
keyb = MD5(CutString(key, 16, 16)); |
||||
|
|
||||
|
keyc = ckey_length > 0 ? (operation == DiscuzAuthcodeMode.Decode ? CutString( |
||||
|
source, 0, ckey_length) : RandomString(ckey_length)) |
||||
|
: ""; |
||||
|
|
||||
|
cryptkey = keya + MD5(keya + keyc); |
||||
|
|
||||
|
if (operation == DiscuzAuthcodeMode.Decode) { |
||||
|
byte[] temp; |
||||
|
|
||||
|
temp = Base64.getDecoder().decode(CutString(source, ckey_length)); |
||||
|
result = new String(RC4(temp, cryptkey)); |
||||
|
if (CutString(result, 10, 16).equals( |
||||
|
CutString(MD5(CutString(result, 26) + keyb), 0, 16))) { |
||||
|
return CutString(result, 26); |
||||
|
} else { |
||||
|
temp = Base64.getDecoder().decode(CutString(source + "=", ckey_length)); |
||||
|
result = new String(RC4(temp, cryptkey)); |
||||
|
if (CutString(result, 10, 16) |
||||
|
.equals(CutString( |
||||
|
MD5(CutString(result, 26) + keyb), 0, 16))) { |
||||
|
return CutString(result, 26); |
||||
|
} else { |
||||
|
temp = Base64.getDecoder().decode(CutString(source + "==", |
||||
|
ckey_length)); |
||||
|
result = new String(RC4(temp, cryptkey)); |
||||
|
if (CutString(result, 10, 16).equals( |
||||
|
CutString(MD5(CutString(result, 26) + keyb), 0, |
||||
|
16))) { |
||||
|
return CutString(result, 26); |
||||
|
} else { |
||||
|
return "2"; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} else { |
||||
|
source = "0000000000" + CutString(MD5(source + keyb), 0, 16) |
||||
|
+ source; |
||||
|
|
||||
|
byte[] temp = RC4(source.getBytes("GBK"), cryptkey); |
||||
|
|
||||
|
return keyc + Base64.getEncoder().encode(temp); |
||||
|
|
||||
|
} |
||||
|
} catch (Exception e) { |
||||
|
return ""; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* <summary> |
||||
|
* RC4 原始算法 |
||||
|
* </summary> |
||||
|
* <param name="input">原始字串数组</param> |
||||
|
* <param name="pass">密钥</param> |
||||
|
* <returns>处理后的字串数组</returns> |
||||
|
*/ |
||||
|
private static byte[] RC4(byte[] input, String pass) { |
||||
|
if (input == null || pass == null) |
||||
|
return null; |
||||
|
|
||||
|
byte[] output = new byte[input.length]; |
||||
|
byte[] mBox = GetKey(pass.getBytes(), 256); |
||||
|
|
||||
|
// 加密
|
||||
|
int i = 0; |
||||
|
int j = 0; |
||||
|
|
||||
|
for (int offset = 0; offset < input.length; offset++) { |
||||
|
i = (i + 1) % mBox.length; |
||||
|
j = (j + (int) ((mBox[i] + 256) % 256)) % mBox.length; |
||||
|
|
||||
|
byte temp = mBox[i]; |
||||
|
mBox[i] = mBox[j]; |
||||
|
mBox[j] = temp; |
||||
|
byte a = input[offset]; |
||||
|
|
||||
|
// byte b = mBox[(mBox[i] + mBox[j] % mBox.Length) % mBox.Length];
|
||||
|
// mBox[j] 一定比 mBox.Length 小,不需要在取模
|
||||
|
byte b = mBox[(toInt(mBox[i]) + toInt(mBox[j])) % mBox.length]; |
||||
|
|
||||
|
output[offset] = (byte) ((int) a ^ (int) toInt(b)); |
||||
|
} |
||||
|
|
||||
|
return output; |
||||
|
} |
||||
|
|
||||
|
public static int toInt(byte b) { |
||||
|
return (int) ((b + 256) % 256); |
||||
|
} |
||||
|
|
||||
|
public long getUnixTimestamp() { |
||||
|
Calendar cal = Calendar.getInstance(); |
||||
|
return cal.getTimeInMillis() / 1000; |
||||
|
} |
||||
|
|
||||
|
public static void main(String[] args) throws IOException { |
||||
|
getStr(); |
||||
|
//readFile02("/Users/liujianjun/Downloads/abc.txt");
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 读取一个文本 一行一行读取 |
||||
|
* |
||||
|
* @param path |
||||
|
* @return |
||||
|
* @throws IOException |
||||
|
*/ |
||||
|
private static void readFile02(String path) throws IOException { |
||||
|
// 使用一个字符串集合来存储文本中的路径 ,也可用String []数组
|
||||
|
List<String> list = new ArrayList<String>(); |
||||
|
FileInputStream fis = new FileInputStream(path); |
||||
|
// 防止路径乱码 如果utf-8 乱码 改GBK eclipse里创建的txt 用UTF-8,在电脑上自己创建的txt 用GBK
|
||||
|
InputStreamReader isr = new InputStreamReader(fis, StandardCharsets.UTF_8); |
||||
|
BufferedReader br = new BufferedReader(isr); |
||||
|
String line = ""; |
||||
|
String result = null; |
||||
|
while ((line = br.readLine()) != null) { |
||||
|
String key = "TvFwHe6tGA"; |
||||
|
result = AuthCodeUtil.authcodeDecode(line, key); |
||||
|
System.out.println(result); |
||||
|
} |
||||
|
br.close(); |
||||
|
isr.close(); |
||||
|
fis.close(); |
||||
|
System.out.println("==========end"); |
||||
|
} |
||||
|
|
||||
|
private static void getStr(){ |
||||
|
String tel = "4fb1lYySlVqMUaf/LnlBEM1nDZgCKnX+Q52azUGgSLCV0hioBvLFFZoJS1Vu"; |
||||
|
tel = "a1孙1增勤"; |
||||
|
String result = AuthCodeUtil.authcodeDecode(tel, "TvFwHe6tGA"); |
||||
|
System.out.println(result); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,96 @@ |
|||||
|
package com.epmet.commons.tools.utils.poi.excel.handler; |
||||
|
|
||||
|
/** |
||||
|
* desc:设置columnWith宽度 |
||||
|
* |
||||
|
* @author: LiuJanJun |
||||
|
* @date: 2022/4/28 5:05 下午 |
||||
|
* @version: 1.0 |
||||
|
*/ |
||||
|
|
||||
|
import com.alibaba.excel.enums.CellDataTypeEnum; |
||||
|
import com.alibaba.excel.metadata.Head; |
||||
|
import com.alibaba.excel.metadata.data.WriteCellData; |
||||
|
import com.alibaba.excel.util.MapUtils; |
||||
|
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; |
||||
|
import com.alibaba.excel.write.style.column.AbstractColumnWidthStyleStrategy; |
||||
|
import org.apache.commons.collections4.CollectionUtils; |
||||
|
import org.apache.poi.ss.usermodel.Cell; |
||||
|
|
||||
|
import java.util.HashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* Take the width of the longest column as the width. |
||||
|
* <p> |
||||
|
* This is not very useful at the moment, for example if you have Numbers it will cause a newline.And the length is not |
||||
|
* exactly the same as the actual length. |
||||
|
* |
||||
|
* @author Jiaju Zhuang |
||||
|
*/ |
||||
|
public class ColumnWidthStyleStrategy extends AbstractColumnWidthStyleStrategy { |
||||
|
|
||||
|
private static final int MAX_COLUMN_WIDTH = 255; |
||||
|
/** |
||||
|
* 是否 根据内容设置宽度 |
||||
|
*/ |
||||
|
private boolean isSetContentWidth = false; |
||||
|
|
||||
|
private final Map<Integer, Map<Integer, Integer>> cache = MapUtils.newHashMapWithExpectedSize(8); |
||||
|
|
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
protected void setColumnWidth(WriteSheetHolder writeSheetHolder, List<WriteCellData<?>> cellDataList, Cell cell, |
||||
|
Head head, |
||||
|
Integer relativeRowIndex, Boolean isHead) { |
||||
|
boolean needSetWidth = (isHead || isSetContentWidth) && CollectionUtils.isNotEmpty(cellDataList); |
||||
|
if (!needSetWidth) { |
||||
|
return; |
||||
|
} |
||||
|
Map<Integer, Integer> maxColumnWidthMap = cache.computeIfAbsent(writeSheetHolder.getSheetNo(), k -> new HashMap<>(16)); |
||||
|
Integer columnWidth = dataLength(cellDataList, cell, isHead); |
||||
|
if (columnWidth < 0) { |
||||
|
return; |
||||
|
} |
||||
|
if (columnWidth > MAX_COLUMN_WIDTH) { |
||||
|
columnWidth = MAX_COLUMN_WIDTH; |
||||
|
} |
||||
|
Integer maxColumnWidth = maxColumnWidthMap.get(cell.getColumnIndex()); |
||||
|
if (maxColumnWidth == null || columnWidth > maxColumnWidth) { |
||||
|
maxColumnWidthMap.put(cell.getColumnIndex(), columnWidth); |
||||
|
writeSheetHolder.getSheet().setColumnWidth(cell.getColumnIndex(), columnWidth * 256); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private Integer dataLength(List<WriteCellData<?>> cellDataList, Cell cell, Boolean isHead) { |
||||
|
if (isHead) { |
||||
|
return cell.getStringCellValue().getBytes().length+3; |
||||
|
} |
||||
|
WriteCellData<?> cellData = cellDataList.get(0); |
||||
|
CellDataTypeEnum type = cellData.getType(); |
||||
|
if (type == null) { |
||||
|
return -1; |
||||
|
} |
||||
|
switch (type) { |
||||
|
case STRING: |
||||
|
return cellData.getStringValue().getBytes().length; |
||||
|
case BOOLEAN: |
||||
|
return cellData.getBooleanValue().toString().getBytes().length; |
||||
|
case NUMBER: |
||||
|
return cellData.getNumberValue().toString().getBytes().length; |
||||
|
default: |
||||
|
return -1; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public ColumnWidthStyleStrategy() { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public ColumnWidthStyleStrategy(boolean isSetContentWidth) { |
||||
|
this.isSetContentWidth = isSetContentWidth; |
||||
|
} |
||||
|
} |
@ -0,0 +1,121 @@ |
|||||
|
package com.epmet.commons.tools.utils.poi.excel.handler; |
||||
|
|
||||
|
import com.alibaba.excel.metadata.Head; |
||||
|
import com.alibaba.excel.metadata.data.WriteCellData; |
||||
|
import com.alibaba.excel.write.handler.CellWriteHandler; |
||||
|
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; |
||||
|
import com.alibaba.excel.write.metadata.holder.WriteTableHolder; |
||||
|
import org.apache.poi.ss.usermodel.Cell; |
||||
|
import org.apache.poi.ss.usermodel.CellType; |
||||
|
import org.apache.poi.ss.usermodel.Row; |
||||
|
import org.apache.poi.ss.usermodel.Sheet; |
||||
|
import org.apache.poi.ss.util.CellRangeAddress; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* desc:单元格合并策略 |
||||
|
* |
||||
|
* @author liujianjun |
||||
|
*/ |
||||
|
public class ExcelFillCellMergeStrategy implements CellWriteHandler { |
||||
|
|
||||
|
/** |
||||
|
* 需要合并的列 下标 |
||||
|
*/ |
||||
|
private int[] mergeColumnIndexArr; |
||||
|
/** |
||||
|
* 从下标n行开始合并 |
||||
|
*/ |
||||
|
private int mergeRowIndex; |
||||
|
|
||||
|
public ExcelFillCellMergeStrategy() { |
||||
|
} |
||||
|
|
||||
|
public ExcelFillCellMergeStrategy(int mergeRowIndex, int[] mergeColumnIndexArr) { |
||||
|
this.mergeRowIndex = mergeRowIndex; |
||||
|
this.mergeColumnIndexArr = mergeColumnIndexArr; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void beforeCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Head head, Integer columnIndex, Integer relativeRowIndex, Boolean isHead) { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void afterCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) { |
||||
|
// 隐藏id列
|
||||
|
writeSheetHolder.getSheet().setColumnHidden(0, true); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<WriteCellData<?>> list, Cell cell, Head head, Integer integer, Boolean aBoolean) { |
||||
|
int curRowIndex = cell.getRowIndex(); |
||||
|
int curColIndex = cell.getColumnIndex(); |
||||
|
if (curRowIndex <= mergeRowIndex) { |
||||
|
return; |
||||
|
} |
||||
|
//如果不指定 合并的列则全部列进行 合并判断
|
||||
|
if (mergeColumnIndexArr == null) { |
||||
|
mergeWithPrevRow(writeSheetHolder, cell, curRowIndex, curColIndex); |
||||
|
} else { |
||||
|
//合并指定的列号
|
||||
|
for (int columnIndex : mergeColumnIndexArr) { |
||||
|
if (curColIndex == columnIndex) { |
||||
|
mergeWithPrevRow(writeSheetHolder, cell, curRowIndex, curColIndex); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 当前单元格向上合并 |
||||
|
* |
||||
|
* @param writeSheetHolder |
||||
|
* @param cell 当前单元格 |
||||
|
* @param curRowIndex 当前行 |
||||
|
* @param curColIndex 当前列 |
||||
|
*/ |
||||
|
private void mergeWithPrevRow(WriteSheetHolder writeSheetHolder, Cell cell, int curRowIndex, int curColIndex) { |
||||
|
// 当前行的第一个Cell
|
||||
|
Cell curFirstCell = cell.getSheet().getRow(curRowIndex).getCell(0); |
||||
|
Object curFirstData = curFirstCell.getCellType() == CellType.STRING ? curFirstCell.getStringCellValue() : curFirstCell.getNumericCellValue(); |
||||
|
// 上一行的第一个Cell
|
||||
|
Cell preFirstCell = cell.getSheet().getRow(curRowIndex - 1).getCell(0); |
||||
|
Object preFirstData = preFirstCell.getCellType() == CellType.STRING ? preFirstCell.getStringCellValue() : preFirstCell.getNumericCellValue(); |
||||
|
|
||||
|
if (curFirstData.equals(preFirstData)) { |
||||
|
Object curData = cell.getCellType() == CellType.STRING ? cell.getStringCellValue() : cell.getNumericCellValue(); |
||||
|
Cell preCell = cell.getSheet().getRow(curRowIndex - 1).getCell(curColIndex); |
||||
|
Object preData = preCell.getCellType() == CellType.STRING ? preCell.getStringCellValue() : preCell.getNumericCellValue(); |
||||
|
// 将当前单元格数据与上一个单元格数据比较
|
||||
|
Boolean dataBool = preData.equals(curData); |
||||
|
//此处需要注意:因为我是按照序号确定是否需要合并的,所以获取每一行第一列数据和上一行第一列数据进行比较,如果相等合并
|
||||
|
Boolean bool = cell.getRow().getCell(0).getStringCellValue().equals(cell.getSheet().getRow(curRowIndex - 1).getCell(0).getStringCellValue()); |
||||
|
|
||||
|
if (!dataBool || !bool) { |
||||
|
return; |
||||
|
} |
||||
|
Sheet sheet = writeSheetHolder.getSheet(); |
||||
|
List<CellRangeAddress> mergeRegions = sheet.getMergedRegions(); |
||||
|
boolean isMerged = false; |
||||
|
for (int i = 0; i < mergeRegions.size() && !isMerged; i++) { |
||||
|
CellRangeAddress cellRangeAddr = mergeRegions.get(i); |
||||
|
// 若上一个单元格已经被合并,则先移出原有的合并单元,再重新添加合并单元
|
||||
|
if (cellRangeAddr.isInRange(curRowIndex - 1, curColIndex)) { |
||||
|
sheet.removeMergedRegion(i); |
||||
|
cellRangeAddr.setLastRow(curRowIndex); |
||||
|
sheet.addMergedRegion(cellRangeAddr); |
||||
|
isMerged = true; |
||||
|
} |
||||
|
} |
||||
|
// 若上一个单元格未被合并,则新增合并单元
|
||||
|
if (!isMerged) { |
||||
|
CellRangeAddress cellRangeAddress = new CellRangeAddress(curRowIndex - 1, curRowIndex, curColIndex, curColIndex); |
||||
|
sheet.addMergedRegion(cellRangeAddress); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
@ -1,4 +1,4 @@ |
|||||
package com.epmet.commons.tools.utils.poi.excel; |
package com.epmet.commons.tools.utils.poi.excel.handler; |
||||
|
|
||||
/** |
/** |
||||
* desc:easyExcel 冻结标题 |
* desc:easyExcel 冻结标题 |
@ -0,0 +1,19 @@ |
|||||
|
/** |
||||
|
* Copyright (c) 2018 人人开源 All rights reserved. |
||||
|
* |
||||
|
* https://www.renren.io
|
||||
|
* |
||||
|
* 版权所有,侵权必究! |
||||
|
*/ |
||||
|
|
||||
|
package com.epmet.commons.tools.validator.group; |
||||
|
|
||||
|
/** |
||||
|
* 导出 Group |
||||
|
* |
||||
|
* @author Mark sunlightcs@gmail.com |
||||
|
* @since 1.0.0 |
||||
|
*/ |
||||
|
public interface ExportGroup { |
||||
|
|
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @author sun |
||||
|
* @dscription 【人房】房屋总数饼图-接口入参 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class HouseChartFormDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 405799151478155056L; |
||||
|
|
||||
|
/** |
||||
|
* 组织、网格、小区Id |
||||
|
*/ |
||||
|
private String orgId; |
||||
|
/** |
||||
|
* 组织、网格、小区类型 agency grid village |
||||
|
*/ |
||||
|
private String orgType; |
||||
|
|
||||
|
//token这信息
|
||||
|
private String customerId; |
||||
|
private String userId; |
||||
|
|
||||
|
} |
@ -0,0 +1,32 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import javax.validation.constraints.NotNull; |
||||
|
import java.io.Serializable; |
||||
|
import java.math.BigDecimal; |
||||
|
|
||||
|
/** |
||||
|
* @Author zxc |
||||
|
* @DateTime 2022/5/5 17:40 |
||||
|
* @DESC |
||||
|
*/ |
||||
|
@Data |
||||
|
public class UpdateSortFormDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 2348273552712227952L; |
||||
|
public interface UpdateSortForm{} |
||||
|
|
||||
|
@NotBlank(message = "id不能为空",groups = UpdateSortForm.class) |
||||
|
private String id; |
||||
|
|
||||
|
@NotNull(message = "sort不能为空",groups = UpdateSortForm.class) |
||||
|
private BigDecimal sort; |
||||
|
|
||||
|
/** |
||||
|
* house:房屋,building:楼栋 |
||||
|
*/ |
||||
|
@NotBlank(message = "type不能为空",groups = UpdateSortForm.class) |
||||
|
private String type; |
||||
|
} |
@ -0,0 +1,57 @@ |
|||||
|
package com.epmet.dto.result; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @author sun |
||||
|
* @dscription 【人房】房屋总数饼图-接口返参 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class HouseChartResultDTO implements Serializable { |
||||
|
/** |
||||
|
* 组织、网格、小区Id |
||||
|
*/ |
||||
|
private String orgId; |
||||
|
/** |
||||
|
* 组织、网格、小区类型 agency grid village |
||||
|
*/ |
||||
|
private String orgType; |
||||
|
/** |
||||
|
* 房屋总数 |
||||
|
*/ |
||||
|
private Integer houseTotal = 0; |
||||
|
/** |
||||
|
* 房屋自住总数 |
||||
|
*/ |
||||
|
private Integer zzHouseTotal = 0; |
||||
|
/** |
||||
|
* 房屋自住总数占比(保留两位小数,带百分号的) |
||||
|
*/ |
||||
|
private Double zzHouseRatio = 0.0; |
||||
|
/** |
||||
|
* 房屋常住总数 |
||||
|
*/ |
||||
|
private Integer czHouseTotal = 0; |
||||
|
/** |
||||
|
* 房屋常住总数占比(保留两位小数,带百分号的) |
||||
|
*/ |
||||
|
private Double czHouseRatio = 0.0; |
||||
|
/** |
||||
|
* 房屋闲置总数 |
||||
|
*/ |
||||
|
private Integer xzHouseTotal = 0; |
||||
|
/** |
||||
|
* 房屋闲置总数占比(保留两位小数,带百分号的) |
||||
|
*/ |
||||
|
private Double xzHouseRatio = 0.0; |
||||
|
|
||||
|
@JsonIgnore |
||||
|
private Integer num; |
||||
|
//1:出租 0:自住 2:闲置
|
||||
|
@JsonIgnore |
||||
|
private Integer rentFlag; |
||||
|
|
||||
|
} |
@ -0,0 +1,74 @@ |
|||||
|
package com.epmet.dto.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @author sun |
||||
|
* @dscription 【人房】下级人房概览列表-接口返参 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class SubUserHouseListResultDTO implements Serializable { |
||||
|
/** |
||||
|
* 组织、网格、小区Id |
||||
|
*/ |
||||
|
private String orgId; |
||||
|
/** |
||||
|
* 组织、网格、小区名称 |
||||
|
*/ |
||||
|
private String orgName; |
||||
|
/** |
||||
|
* 组织、网格、小区类型 agency grid village |
||||
|
*/ |
||||
|
private String orgType; |
||||
|
/** |
||||
|
* 房屋总数 |
||||
|
*/ |
||||
|
private Integer houseTotal = 0; |
||||
|
/** |
||||
|
* 房屋自住总数 |
||||
|
*/ |
||||
|
private Integer zzHouseTotal = 0; |
||||
|
/** |
||||
|
* 房屋自住总数占比(保留两位小数,带百分号的) |
||||
|
*/ |
||||
|
private Double zzHouseRatio = 0.0; |
||||
|
/** |
||||
|
* 房屋常住总数 |
||||
|
*/ |
||||
|
private Integer czHouseTotal = 0; |
||||
|
/** |
||||
|
* 房屋常住总数占比(保留两位小数,带百分号的) |
||||
|
*/ |
||||
|
private Double czHouseRatio = 0.0; |
||||
|
/** |
||||
|
* 房屋闲置总数 |
||||
|
*/ |
||||
|
private Integer xzHouseTotal = 0; |
||||
|
/** |
||||
|
* 房屋闲置总数占比(保留两位小数,带百分号的) |
||||
|
*/ |
||||
|
private Double xzHouseRatio = 0.0; |
||||
|
/** |
||||
|
* 居民总数 |
||||
|
*/ |
||||
|
private Integer userTotal = 0; |
||||
|
/** |
||||
|
* 常住人口总数 |
||||
|
*/ |
||||
|
private Integer czUserTotal = 0; |
||||
|
/** |
||||
|
* 常住人口占比(保留两位小数,带百分号的) |
||||
|
*/ |
||||
|
private Double czUserRatio = 0.0; |
||||
|
/** |
||||
|
* 流动人口总数 |
||||
|
*/ |
||||
|
private Integer ldUserTotal = 0; |
||||
|
/** |
||||
|
* 流动人口占比(保留两位小数,带百分号的) |
||||
|
*/ |
||||
|
private Double ldUserRatio = 0.0; |
||||
|
|
||||
|
} |
@ -0,0 +1,2 @@ |
|||||
|
alter table ic_building add COLUMN BUILDING_LEADER_NAME VARCHAR(11) comment '楼长姓名' AFTER TOTAL_HOUSE_NUM; |
||||
|
alter table ic_building add COLUMN BUILDING_LEADER_MOBILE VARCHAR(11) comment '楼长电话' AFTER BUILDING_LEADER_NAME; |
@ -0,0 +1,3 @@ |
|||||
|
ALTER TABLE ic_building DROP SORT; |
||||
|
alter table ic_building add COLUMN SORT DECIMAL(6,2) comment '排序' DEFAULT 0.00 AFTER BUILDING_LEADER_NAME; |
||||
|
alter table ic_house add COLUMN SORT DECIMAL(6,2) comment '排序' DEFAULT 0.00 AFTER OWNER_ID_CARD; |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue