处理忽略文件

main
youHong.ai 2022-11-25 16:50:19 +08:00
commit 82a22c3af8
8 changed files with 152 additions and 30 deletions

View File

@ -0,0 +1,19 @@
package weaver.xuanran.wang.common.annocation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* <h1></h1>
*
* @Author xuanran.wang
* @Date 2022/11/25 15:55
*/
@Target({ElementType.FIELD,ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface CusDateFormat {
String from();
String to() default "yyyy-MM-dd";
}

View File

@ -6,15 +6,15 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import weaver.xuanran.wang.common.annocation.CusDateFormat;
import weaver.xuanran.wang.common.annocation.ParamNotNull; import weaver.xuanran.wang.common.annocation.ParamNotNull;
import java.io.*; import java.io.*;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.util.Collections; import java.text.ParseException;
import java.util.Enumeration; import java.text.SimpleDateFormat;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
@ -31,6 +31,8 @@ public class CommonUtil {
public static final int SQL_IN_PAGE_SIZE = 100; public static final int SQL_IN_PAGE_SIZE = 100;
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
/** /**
* <h1></h1> * <h1></h1>
* @author xuanran.wang * @author xuanran.wang
@ -120,6 +122,7 @@ public class CommonUtil {
} }
return builder.toString(); return builder.toString();
} }
/** /**
* <h1></h1> * <h1></h1>
* @author xuanran.wang * @author xuanran.wang
@ -158,6 +161,15 @@ public class CommonUtil {
} }
} }
} }
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2022/11/25 16:01
* @param list
* @param splitSize
* @return
**/
public static <T> List<List<T>> splitList(List<T> list, int splitSize) { public static <T> List<List<T>> splitList(List<T> list, int splitSize) {
//判断集合是否为空 //判断集合是否为空
if (CollectionUtils.isEmpty(list)) if (CollectionUtils.isEmpty(list))
@ -172,4 +184,33 @@ public class CommonUtil {
.filter(b -> !b.isEmpty()) .filter(b -> !b.isEmpty())
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
/**
* <h1></h1>
* @author xuanran.wang
* @dateTime 2022/11/25 16:07
* @param cusDateFormat
* @param value
* @return
**/
public static String getDateByCusDateFormat(CusDateFormat cusDateFormat, Object value){
String from = cusDateFormat.from();
if(StringUtils.isBlank(Util.null2String(from))){
throw new CustomerException("使用CusDateFormat注解时, from参数不能为空!");
}
Date date = null;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(from);
try {
date = simpleDateFormat.parse(String.valueOf(value));
}catch (ParseException e) {
throw new RuntimeException(Util.logStr("解析日期失败!当前传入转化格式:[{}],待转化日期:[{}]", from, value));
}
String to = cusDateFormat.to();
simpleDateFormat = new SimpleDateFormat(to);
try {
// 用时间戳进行转换
return simpleDateFormat.format(date.getTime());
}catch (Exception e){
throw new RuntimeException(Util.logStr("解析日期失败!当前传入转化格式:[{}],待转化日期:[{}]", to, date));
}
}
} }

View File

@ -1,4 +1,4 @@
package weaver.xuanran.wang.util; package weaver.xuanran.wang.common.util;
import aiyh.utils.Util; import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException; import aiyh.utils.excention.CustomerException;
@ -6,14 +6,13 @@ import com.jcraft.jsch.*;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import java.io.File; import java.io.File;
import java.io.FileOutputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.Iterator; import java.util.Iterator;
import java.util.Properties; import java.util.Properties;
import java.util.Vector; import java.util.Vector;
/** /**
* <h1></h1> * <h1>ftpUtil</h1>
* *
* @Author xuanran.wang * @Author xuanran.wang
* @Date 2022/11/22 17:25 * @Date 2022/11/22 17:25
@ -155,7 +154,7 @@ public class FtpUtil {
if(!file.getParentFile().exists()){ if(!file.getParentFile().exists()){
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
} }
sftp.get(downloadFile, new FileOutputStream(file)); sftp.get(downloadFile, Files.newOutputStream(file.toPath()));
} catch (Exception e) { } catch (Exception e) {
throw new CustomerException("下载文件出现异常: " + e.getMessage()); throw new CustomerException("下载文件出现异常: " + e.getMessage());
} }

View File

@ -1,6 +1,7 @@
package weaver.xuanran.wang.traffic_bank.waco_first.entity; package weaver.xuanran.wang.traffic_bank.waco_first.entity;
import lombok.Data; import lombok.Data;
import weaver.xuanran.wang.common.annocation.CusDateFormat;
import weaver.xuanran.wang.traffic_bank.waco_first.annocation.BodyPath; import weaver.xuanran.wang.traffic_bank.waco_first.annocation.BodyPath;
/** /**
@ -17,6 +18,7 @@ public class Info {
private String jurisdictionName; private String jurisdictionName;
private String adminPenaltyNumber; private String adminPenaltyNumber;
private String industryClassification; private String industryClassification;
@CusDateFormat(from = "yyyy.MM.dd")
private String adminPenaltyDate; private String adminPenaltyDate;
private String punishmentObjectType; private String punishmentObjectType;
private String punishedParties; private String punishedParties;

View File

@ -8,7 +8,7 @@ import weaver.xuanran.wang.common.annocation.ParamNotNull;
import weaver.xuanran.wang.common.util.CommonUtil; import weaver.xuanran.wang.common.util.CommonUtil;
import weaver.xuanran.wang.traffic_bank.waco_first.entity.Info; import weaver.xuanran.wang.traffic_bank.waco_first.entity.Info;
import weaver.xuanran.wang.traffic_bank.waco_first.service.WacoDataPushOAService; import weaver.xuanran.wang.traffic_bank.waco_first.service.WacoDataPushOAService;
import weaver.xuanran.wang.util.FtpUtil; import weaver.xuanran.wang.common.util.FtpUtil;
import java.util.List; import java.util.List;

View File

@ -4,8 +4,6 @@ import aiyh.utils.Util;
import aiyh.utils.excention.CustomerException; import aiyh.utils.excention.CustomerException;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jcraft.jsch.ChannelSftp; import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.SftpException;
import com.weaver.procedure.doc.Doc_diracl_insert_type3;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -13,17 +11,17 @@ import org.dom4j.Document;
import org.dom4j.Element; import org.dom4j.Element;
import org.dom4j.io.SAXReader; import org.dom4j.io.SAXReader;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
import weaver.conn.RecordSetTrans;
import weaver.docs.webservices.DocInfo; import weaver.docs.webservices.DocInfo;
import weaver.docs.webservices.DocServiceImpl; import weaver.docs.webservices.DocServiceImpl;
import weaver.general.GCONST; import weaver.general.GCONST;
import weaver.general.TimeUtil; import weaver.general.TimeUtil;
import weaver.hrm.User; import weaver.hrm.User;
import weaver.xuanran.wang.common.annocation.CusDateFormat;
import weaver.xuanran.wang.common.util.CommonUtil; import weaver.xuanran.wang.common.util.CommonUtil;
import weaver.xuanran.wang.common.util.CusInfoToOAUtil; import weaver.xuanran.wang.common.util.CusInfoToOAUtil;
import weaver.xuanran.wang.traffic_bank.waco_first.annocation.BodyPath; import weaver.xuanran.wang.traffic_bank.waco_first.annocation.BodyPath;
import weaver.xuanran.wang.traffic_bank.waco_first.entity.Info; import weaver.xuanran.wang.traffic_bank.waco_first.entity.Info;
import weaver.xuanran.wang.util.FtpUtil; import weaver.xuanran.wang.common.util.FtpUtil;
import java.io.File; import java.io.File;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@ -44,7 +42,7 @@ public class WacoDataPushOAService {
private static final String WACO_TEMP_PATH = File.separator + "WACO" + File.separator + "temp" + File.separator; private static final String WACO_TEMP_PATH = File.separator + "WACO" + File.separator + "temp" + File.separator;
private static final String INSERT_DOC_DETAIL_CONTENT_SQL = "insert into docdetailcontent(docid,doccontent) values(?,?)"; private static final String INSERT_DOC_DETAIL_CONTENT_SQL = "insert into docdetailcontent(docid,doccontent) values(?,?)";
/** /**
* <h1></h1> * <h1>ftp,info</h1>
* @author xuanran.wang * @author xuanran.wang
* @dateTime 2022/11/23 16:29 * @dateTime 2022/11/23 16:29
* @param connect ftp * @param connect ftp
@ -85,43 +83,67 @@ public class WacoDataPushOAService {
return infos; return infos;
} }
/**
* <h1>info</h1>
* @author xuanran.wang
* @dateTime 2022/11/23 21:33
* @param modelId id
* @param secCategory id
* @param infos
**/
public void writeInfoToOA(int modelId, int secCategory, List<Info> infos) { public void writeInfoToOA(int modelId, int secCategory, List<Info> infos) {
String whereSql = "select 1 from " + CusInfoToOAUtil.TABLE_NAME_PLACEHOLDER + " where infoId = ?"; String whereSql = "select 1 from " + CusInfoToOAUtil.TABLE_NAME_PLACEHOLDER + " where infoId = ?";
List<String> ids = new ArrayList<>(); List<String> ids = new ArrayList<>();
// docDetailContent表参数
List<List> docDetailContentParams = new ArrayList<>();
try { try {
for (Info info : infos) { for (Info info : infos) {
Map<String, Object> param = getParamsMapByInfo(secCategory, info); List<String> docDetailParam = new ArrayList<>();
Map<String, Object> param = getParamsMapByInfo(secCategory, info, docDetailParam);
int dataId = CusInfoToOAUtil.execute(modelId, param, int dataId = CusInfoToOAUtil.execute(modelId, param,
whereSql, whereSql,
Collections.singletonList(info.getInfoId())); Collections.singletonList(info.getInfoId()));
ids.add(String.valueOf(dataId)); ids.add(String.valueOf(dataId));
docDetailContentParams.add(docDetailParam);
}
RecordSet updateRs = new RecordSet();
if (!updateRs.executeBatchSql(INSERT_DOC_DETAIL_CONTENT_SQL, docDetailContentParams)) {
throw new CustomerException("批量数据写入doc_detail_content表失败!, 当前参数: " + docDetailContentParams.get(0));
} }
}catch (Exception e){ }catch (Exception e){
logger.error(Util.logStr("写入建模出现异常:[{}]", e.getMessage())); logger.error(Util.logStr("写入建模出现异常:[{}]", e.getMessage()));
// sql用了in防止集合过大sql报错进行集合分割
List<List<String>> splitList = CommonUtil.splitList(ids, CommonUtil.SQL_IN_PAGE_SIZE); List<List<String>> splitList = CommonUtil.splitList(ids, CommonUtil.SQL_IN_PAGE_SIZE);
for (List<String> list : splitList) { for (List<String> list : splitList) {
if (!CusInfoToOAUtil.deleteModelDataByIds(String.valueOf(modelId), list)) { if (!CusInfoToOAUtil.deleteModelDataByIds(String.valueOf(modelId), list)) {
logger.error(Util.logStr("删除数据失败, 数据集合 : [{}] ", JSONObject.toJSONString(list))); logger.error(Util.logStr("删除数据失败, 数据集合 : [{}] ", JSONObject.toJSONString(list)));
} }
} }
throw new RuntimeException("写入建模出现异常:" + e.getMessage());
} }
} }
/** /**
* <h1></h1> * <h1>info</h1>
* @author xuanran.wang * @author xuanran.wang
* @dateTime 2022/11/23 21:09 * @dateTime 2022/11/23 21:09
* @param secCategory * @param secCategory id
* @param info * @param info
* @return * @return
**/ **/
public Map<String, Object> getParamsMapByInfo(int secCategory, Info info) throws Exception { public Map<String, Object> getParamsMapByInfo(int secCategory, Info info, List<String> docDetailParam) throws Exception {
Class<? extends Info> clazz = info.getClass(); Class<? extends Info> clazz = info.getClass();
Field[] fields = clazz.getDeclaredFields(); Field[] fields = clazz.getDeclaredFields();
HashMap<String, Object> res = new HashMap<>(); HashMap<String, Object> res = new HashMap<>();
for (Field field : fields) { for (Field field : fields) {
field.setAccessible(true); field.setAccessible(true);
Object value = field.get(info); Object value = field.get(info);
// 进行日期解析
CusDateFormat cusDate = field.getDeclaredAnnotation(CusDateFormat.class);
if(cusDate != null){
value = CommonUtil.getDateByCusDateFormat(cusDate, value);
}
// 文件解析
BodyPath annotation = field.getDeclaredAnnotation(BodyPath.class); BodyPath annotation = field.getDeclaredAnnotation(BodyPath.class);
if(annotation != null){ if(annotation != null){
DocInfo docInfo = new DocInfo(); DocInfo docInfo = new DocInfo();
@ -131,10 +153,11 @@ public class WacoDataPushOAService {
docInfo.setDoccontent(body); docInfo.setDoccontent(body);
DocServiceImpl docService = new DocServiceImpl(); DocServiceImpl docService = new DocServiceImpl();
int docId = docService.createDocByUser(docInfo, new User(1)); int docId = docService.createDocByUser(docInfo, new User(1));
res.put(field.getName(), docId); docDetailParam.add(String.valueOf(docId));
}else { docDetailParam.add(body);
res.put(field.getName(), value); value = docId;
} }
res.put(field.getName(), value);
} }
return res; return res;
} }

View File

@ -4,19 +4,12 @@ import aiyh.utils.excention.CustomerException;
import basetest.BaseTest; import basetest.BaseTest;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.DailyRollingFileAppender;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.Priority;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import weaver.general.GCONST; import weaver.general.GCONST;
import weaver.general.TimeUtil; import weaver.general.TimeUtil;
import weaver.xuanran.wang.common.util.CommonUtil; import weaver.xuanran.wang.common.util.CommonUtil;
import weaver.xuanran.wang.traffic_bank.waco_first.entity.Info; import weaver.xuanran.wang.traffic_bank.waco_first.entity.Info;
import weaver.xuanran.wang.traffic_bank.waco_first.service.WacoDataPushOAService; import weaver.xuanran.wang.traffic_bank.waco_first.service.WacoDataPushOAService;
import weaver.xuanran.wang.util.FtpUtil;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -383,3 +383,48 @@ from workflow_nodebase nb
``` ```
### 后端 ### 后端
**1.后端根据请求获取登录用户信息**
> 维护人员xuanran.wang
```java
User logInUser = HrmUserVarify.getUser(request, response));
// 传入id会将此人员信息带出
User user = new User(id);
// 获取人员id
user.getUID();
```
**2.发送邮件**
> 维护人员xuanran.wang
```java
/**
* <h1>发送邮件</h1>
* @param address 邮箱地址
* @param title 标题
* @param content 正文
**/
EmailWorkRunnable.threadModeReminder(address, title, content);
```
**3.短信服务**
> 维护人员xuanran.wang
```java
public class SendSms implements SmsService {
@Override
public boolean sendSMS(String smsId, String number, String msg) {
//执行短信调用接口逻辑
return SMSUtil.sendSms(number,msg,url,sn,pwd);
}
}
```
**4.三方插件文档转PDF(培训群找过来的)**
> 维护人员xuanran.wang
```java
wps转PDF
DocImagefileToPdfUseWps toPdfUseWps = new DocImagefileToPdfUseWps();
newimagefileid = toPdfUseWps.officeDocumetnToPdfByImagefileid(docimagefileid);
永中转PDF
DocImagefileToPdf yozoToPdf = new DocImagefileToPdf();
newimagefileid = yozoToPdf.officeDocumetnToPdfByImagefileid(docimagefileid);
```