合并代碼

release
zhenghaiyang@ele-cloud.com 2 years ago
parent 5fe8b27433
commit 99d6722729
  1. 20
      dxhy-core/src/main/java/com/dxhy/core/controller/mailGather/EmailMaintainController.java
  2. 29
      dxhy-core/src/main/java/com/dxhy/core/controller/mailGather/MailGatherLogController.java
  3. 2
      dxhy-core/src/main/java/com/dxhy/core/dao/mailGather/EmailMaintainDao.java
  4. 3
      dxhy-core/src/main/java/com/dxhy/core/job/service/impl/ConfirmServiceImpl.java
  5. 13
      dxhy-core/src/main/java/com/dxhy/core/model/mailGather/MailGatherLogVo.java
  6. 2
      dxhy-core/src/main/java/com/dxhy/core/service/mailGather/EmailMaintainService.java
  7. 6
      dxhy-core/src/main/java/com/dxhy/core/service/mailGather/impl/EmailMaintainServiceImpl.java
  8. 7
      dxhy-core/src/main/java/com/dxhy/core/service/mailGather/impl/MailGatherLogServiceImpl.java
  9. 4
      dxhy-core/src/main/java/com/dxhy/core/task/SnEmailGatherTask.java
  10. 13
      dxhy-core/src/main/java/com/dxhy/core/task/SnEmailGatherTaskTest.java
  11. 2
      dxhy-core/src/main/resources/mapper/mailGather/EmailMaintainMapper.xml
  12. 46
      dxhy-core/src/main/resources/mapper/mailGather/MailGatherLogMapper.xml

@ -4,7 +4,9 @@ import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.dxhy.common.constant.DbConstant;
import com.dxhy.common.controller.AbstractController; import com.dxhy.common.controller.AbstractController;
import com.dxhy.common.datasource.config.DynamicContextHolder;
import com.dxhy.common.util.UUIDUtils; import com.dxhy.common.util.UUIDUtils;
import com.dxhy.common.utils.Base64Encoding; import com.dxhy.common.utils.Base64Encoding;
import com.dxhy.common.utils.R; import com.dxhy.common.utils.R;
@ -91,6 +93,13 @@ public class EmailMaintainController extends AbstractController {
} }
String loginname = getUserInfo().getLoginname(); String loginname = getUserInfo().getLoginname();
emailMaintain.setCreateUser(loginname); emailMaintain.setCreateUser(loginname);
DynamicContextHolder.push(DbConstant.BASICS_READ);
EmailMaintainVo vo = new EmailMaintainVo();
vo.setEmailAddress(emailMaintain.getEmailAddress());
EmailMaintainVo maintainVo = emailMaintainService.getEmailMaintainVo(vo);
if(maintainVo != null){
return ResponseEntity.ok(R.error("邮箱地址已存在!"));
}
boolean insert = this.emailMaintainService.insert(emailMaintain); boolean insert = this.emailMaintainService.insert(emailMaintain);
if(insert){ if(insert){
return ResponseEntity.ok(R.ok()); return ResponseEntity.ok(R.ok());
@ -106,6 +115,16 @@ public class EmailMaintainController extends AbstractController {
*/ */
@PostMapping("/edit") @PostMapping("/edit")
public ResponseEntity<R> edit(@RequestBody EmailMaintainVo emailMaintain) { public ResponseEntity<R> edit(@RequestBody EmailMaintainVo emailMaintain) {
if(StringUtils.isBlank(emailMaintain.getEmailPassword())){
return ResponseEntity.ok(R.error("邮箱地址不能为空!"));
}
DynamicContextHolder.push(DbConstant.BASICS_READ);
EmailMaintainVo vo = new EmailMaintainVo();
vo.setEmailAddress(emailMaintain.getEmailAddress());
EmailMaintainVo maintainVo = emailMaintainService.getEmailMaintainVo(vo);
if(maintainVo != null && maintainVo.getId().equals(emailMaintain.getId())){
return ResponseEntity.ok(R.error("邮箱地址已存在!"));
}
boolean b = emailMaintainService.update(emailMaintain); boolean b = emailMaintainService.update(emailMaintain);
if(b){ if(b){
return ResponseEntity.ok(R.ok()); return ResponseEntity.ok(R.ok());
@ -142,6 +161,7 @@ public class EmailMaintainController extends AbstractController {
errorMsgList.add("第" + resultIndex + "行,用户编码不能为空"); errorMsgList.add("第" + resultIndex + "行,用户编码不能为空");
continue; continue;
} }
DynamicContextHolder.push(DbConstant.BASICS_READ);
String userName = emailMaintainService.getUserName(userId); String userName = emailMaintainService.getUserName(userId);
if(StringUtils.isBlank(userName)){ if(StringUtils.isBlank(userName)){
errorMsgList.add("第" + resultIndex + "行,用户编码在系统中查询不到,请核实!"); errorMsgList.add("第" + resultIndex + "行,用户编码在系统中查询不到,请核实!");

@ -1,8 +1,12 @@
package com.dxhy.core.controller.mailGather; package com.dxhy.core.controller.mailGather;
import com.dxhy.common.constant.DbConstant;
import com.dxhy.common.controller.AbstractController; import com.dxhy.common.controller.AbstractController;
import com.dxhy.common.datasource.config.DynamicContextHolder;
import com.dxhy.common.utils.R; import com.dxhy.common.utils.R;
import com.dxhy.core.service.mailGather.MailGatherLogService; import com.dxhy.core.service.mailGather.MailGatherLogService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@ -10,6 +14,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map; import java.util.Map;
/** /**
@ -18,6 +25,7 @@ import java.util.Map;
* @author makejava * @author makejava
* @since 2023-03-23 08:42:35 * @since 2023-03-23 08:42:35
*/ */
@Slf4j
@RestController @RestController
@RequestMapping("/mailGatherLog") @RequestMapping("/mailGatherLog")
public class MailGatherLogController extends AbstractController { public class MailGatherLogController extends AbstractController {
@ -26,6 +34,7 @@ public class MailGatherLogController extends AbstractController {
*/ */
@Resource @Resource
private MailGatherLogService mailGatherLogService; private MailGatherLogService mailGatherLogService;
final SimpleDateFormat sf2 = new SimpleDateFormat("yyyy-MM-dd");
/** /**
* 分页查询 * 分页查询
@ -46,6 +55,26 @@ public class MailGatherLogController extends AbstractController {
if (pramsMap.get("parseEnd") == null || "".equals(pramsMap.get("parseEnd"))) { if (pramsMap.get("parseEnd") == null || "".equals(pramsMap.get("parseEnd"))) {
return ResponseEntity.ok(R.error("结束日期不能为空!")); return ResponseEntity.ok(R.error("结束日期不能为空!"));
} }
Object parseStart = pramsMap.get("parseStart");
Object parseEnd = pramsMap.get("parseEnd");
if (parseEnd == null || parseEnd == null) {
} else {
try {
Date starttime = sf2.parse(String.valueOf(parseStart));
Date endtime = sf2.parse(String.valueOf(parseEnd));
if (starttime.after(endtime)) {
return ResponseEntity.ok(R.error("开始时间不能大于结束时间"));
}
pramsMap.put("startTime", starttime);
pramsMap.put("endTime", endtime);
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
String loginname = getUserInfo().getLoginname();
pramsMap.put("createUser",loginname);
DynamicContextHolder.push(DbConstant.BASICS_READ);
return ResponseEntity.ok(R.ok().put("data",this.mailGatherLogService.queryByPage(pramsMap))); return ResponseEntity.ok(R.ok().put("data",this.mailGatherLogService.queryByPage(pramsMap)));
} }

@ -35,7 +35,7 @@ public interface EmailMaintainDao extends BaseMapper<EmailMaintainVo> {
* @param emailMaintainVo 查询条件 * @param emailMaintainVo 查询条件
* @return 总行数 * @return 总行数
*/ */
long count(EmailMaintainVo emailMaintainVo); EmailMaintainVo getEmailMaintainVo(EmailMaintainVo emailMaintainVo);
/** /**
* 新增数据 * 新增数据

@ -102,6 +102,9 @@ public class ConfirmServiceImpl extends ServiceImpl<ConfirmDao, TDxHttpLog> impl
if (list != null && list.size() > 0) { if (list != null && list.size() > 0) {
for (TAcOrg tAcOrg : list) { for (TAcOrg tAcOrg : list) {
DynamicContextHolder.push(DbConstant.BASICS_READ);
BasisSysDeptCfg baseSysDeptCfg = basisSysDeptCfgDao.selectOne(new QueryWrapper<BasisSysDeptCfg>().eq("nsrsbh", tAcOrg.getTaxno())); BasisSysDeptCfg baseSysDeptCfg = basisSysDeptCfgDao.selectOne(new QueryWrapper<BasisSysDeptCfg>().eq("nsrsbh", tAcOrg.getTaxno()));
if (baseSysDeptCfg != null) { if (baseSysDeptCfg != null) {
continue; continue;

@ -26,4 +26,17 @@ public class MailGatherLogVo extends CommonDTO {
private String fileName; private String fileName;
private Date createTime; private Date createTime;
public String deptId;
private String companyCode;
public String deptName;
public String username;
public String userId;
public String createUser;
} }

@ -51,4 +51,6 @@ public interface EmailMaintainService {
String getUserName(String userCode); String getUserName(String userCode);
int insertBatch(List<EmailMaintainVo> entities); int insertBatch(List<EmailMaintainVo> entities);
EmailMaintainVo getEmailMaintainVo(EmailMaintainVo emailMaintain);
} }

@ -70,6 +70,7 @@ public class EmailMaintainServiceImpl implements EmailMaintainService {
*/ */
@Override @Override
public boolean insert(EmailMaintainVo emailMaintain) { public boolean insert(EmailMaintainVo emailMaintain) {
DynamicContextHolder.push(DbConstant.BASICS_READ);
if(StringUtils.isEmpty(emailMaintain.getId())){ if(StringUtils.isEmpty(emailMaintain.getId())){
emailMaintain.setId(IdUtil.nanoId()); emailMaintain.setId(IdUtil.nanoId());
} }
@ -116,6 +117,11 @@ public class EmailMaintainServiceImpl implements EmailMaintainService {
return emailMaintainDao.insertBatch(entities); return emailMaintainDao.insertBatch(entities);
} }
@Override
public EmailMaintainVo getEmailMaintainVo(EmailMaintainVo emailMaintain) {
return emailMaintainDao.getEmailMaintainVo(emailMaintain);
}
//根据用户名进行查询 //根据用户名进行查询
public void getdeptInfo(String deptId){ public void getdeptInfo(String deptId){
DynamicContextHolder.push(DbConstant.BASICS_READ); DynamicContextHolder.push(DbConstant.BASICS_READ);

@ -5,16 +5,19 @@ import cn.hutool.core.codec.Base64;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.dxhy.common.constant.DbConstant; import com.dxhy.common.constant.DbConstant;
import com.dxhy.common.datasource.config.DynamicContextHolder; import com.dxhy.common.datasource.config.DynamicContextHolder;
import com.dxhy.common.util.UUIDUtils;
import com.dxhy.core.dao.mailGather.MailGatherLogDao; import com.dxhy.core.dao.mailGather.MailGatherLogDao;
import com.dxhy.core.model.mailGather.MailGatherLogVo; import com.dxhy.core.model.mailGather.MailGatherLogVo;
import com.dxhy.core.service.mailGather.MailGatherLogService; import com.dxhy.core.service.mailGather.MailGatherLogService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -70,6 +73,10 @@ public class MailGatherLogServiceImpl implements MailGatherLogService {
*/ */
@Override @Override
public MailGatherLogVo insert(MailGatherLogVo mailGatherLog) { public MailGatherLogVo insert(MailGatherLogVo mailGatherLog) {
if(StringUtils.isEmpty(mailGatherLog.getId())){
mailGatherLog.setId(UUIDUtils.generateShortUuid());
}
mailGatherLog.setCreateTime(new Date());
this.mailGatherLogDao.insert(mailGatherLog); this.mailGatherLogDao.insert(mailGatherLog);
return mailGatherLog; return mailGatherLog;
} }

@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject;
import com.dxhy.common.constant.DbConstant; import com.dxhy.common.constant.DbConstant;
import com.dxhy.common.datasource.config.DynamicContextHolder; import com.dxhy.common.datasource.config.DynamicContextHolder;
import com.dxhy.common.util.MD5; import com.dxhy.common.util.MD5;
import com.dxhy.common.util.UUIDUtils;
import com.dxhy.core.job.entity.ScheduleJobEntity; import com.dxhy.core.job.entity.ScheduleJobEntity;
import com.dxhy.core.job.service.ScheduleJobService; import com.dxhy.core.job.service.ScheduleJobService;
import com.dxhy.core.model.mailGather.EmailMaintainVo; import com.dxhy.core.model.mailGather.EmailMaintainVo;
@ -98,10 +99,9 @@ public class SnEmailGatherTask {
Store store = mailAuth(emailName, password); Store store = mailAuth(emailName, password);
if(store == null){ if(store == null){
MailGatherLogVo gatherLogVo = new MailGatherLogVo(); MailGatherLogVo gatherLogVo = new MailGatherLogVo();
gatherLogVo.setId(IdUtil.nanoId()); gatherLogVo.setId(UUIDUtils.generateShortUuid());
gatherLogVo.setErrorMsg("邮箱认证失败"); gatherLogVo.setErrorMsg("邮箱认证失败");
gatherLogVo.setOcrType("1"); gatherLogVo.setOcrType("1");
gatherLogVo.setCreateTime(new Date());
gatherLogVo.setFromAddress(emailName); gatherLogVo.setFromAddress(emailName);
mailGatherLogService.insert(gatherLogVo); mailGatherLogService.insert(gatherLogVo);
return; return;

@ -37,8 +37,10 @@ class SnEmailGatherTaskTest {
String port = "110"; String port = "110";
//邮件接收服务器地址 //邮件接收服务器地址
String mail_host = "mail.pop3.host"; String mail_host = "mail.pop3.host";
String emailName = "15201210373@163.com"; String emailName = "1149953701@qq.com";
String password = "JKZATQTPHDDQTQSH"; String password = "pmdzleyabmlzgdhc";
// String emailName = "15201210373@163.com";
// String password = "JKZATQTPHDDQTQSH";
String mailSuffix = emailName.split("@")[1]; String mailSuffix = emailName.split("@")[1];
//邮箱类型 //邮箱类型
String mailType = mailSuffix.split("\\.")[0]; String mailType = mailSuffix.split("\\.")[0];
@ -61,7 +63,7 @@ class SnEmailGatherTaskTest {
//连接邮箱服务器 //连接邮箱服务器
//获取当前时间 //获取当前时间
Date currentTime = new Date(); Date currentTime = new Date();
// 获得收件箱 pop3协议只有一个有效的文件夹就是INBOX // 品 ping获得收件箱 pop3协议只有一个有效的文件夹就是INBOX
Folder folder = store.getFolder("INBOX"); Folder folder = store.getFolder("INBOX");
//获取邮件列表 //获取邮件列表
folder.open(Folder.READ_WRITE); folder.open(Folder.READ_WRITE);
@ -113,6 +115,7 @@ class SnEmailGatherTaskTest {
Map resultMap = JSONObject.parseObject(body, Map.class); Map resultMap = JSONObject.parseObject(body, Map.class);
Object status = resultMap.get("status"); Object status = resultMap.get("status");
System.out.println(JSONObject.toJSONString("================="+resultMap));
if(status != null && "200".equals(String.valueOf(status))){ if(status != null && "200".equals(String.valueOf(status))){
} }
@ -165,7 +168,7 @@ class SnEmailGatherTaskTest {
OpenServiceOcr openServiceOcr = openServiceOcrs.get(i); OpenServiceOcr openServiceOcr = openServiceOcrs.get(i);
OpenServiceOcr.InvoiceOcrData invoiceOcrData = openServiceOcr.getData(); OpenServiceOcr.InvoiceOcrData invoiceOcrData = openServiceOcr.getData();
OcrResultToyxVo resultToyxVo = new OcrResultToyxVo(); OcrResultToyxVo resultToyxVo = new OcrResultToyxVo();
resultToyxVo.setCompanyId(""); resultToyxVo.setCompanyId("c040");
resultToyxVo.setSource("01"); resultToyxVo.setSource("01");
resultToyxVo.setInvoiceCode(invoiceOcrData.getFPDM()); resultToyxVo.setInvoiceCode(invoiceOcrData.getFPDM());
resultToyxVo.setInvoiceNumber(invoiceOcrData.getFPHM()); resultToyxVo.setInvoiceNumber(invoiceOcrData.getFPHM());
@ -176,7 +179,7 @@ class SnEmailGatherTaskTest {
resultToyxVo.setFileType("102"); resultToyxVo.setFileType("102");
resultToyxVo.setFileByte(map.get("pdfStream")); resultToyxVo.setFileByte(map.get("pdfStream"));
resultToyxVo.setEmail(map.get("emailName")); resultToyxVo.setEmail(map.get("emailName"));
resultToyxVo.setEmployeeId(""); resultToyxVo.setEmployeeId("01142085");
resultToyxVoList.add(resultToyxVo); resultToyxVoList.add(resultToyxVo);
} }

@ -48,7 +48,7 @@
</select> </select>
<!--统计总行数--> <!--统计总行数-->
<select id="count" resultType="java.lang.Long"> <select id="getEmailMaintainVo" resultMap="EmailMaintainMap">
select count(1) select count(1)
from email_maintain from email_maintain
<where> <where>

@ -28,42 +28,32 @@
<!--查询指定行数据--> <!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="MailGatherLogMap" parameterType="java.util.Map"> <select id="queryAllByLimit" resultMap="MailGatherLogMap" parameterType="java.util.Map">
select SELECT
id, subject, from_address, receive_address, sent_date, file_type, fpdm, fphm, msg_uid, ocr_type, error_msg, file_name, create_time m.create_time, e.dept_name, e.username, m.from_address, m.file_name, m.file_type, m.ocr_type, m.error_msg
from mail_gather_log FROM
mail_gather_log m
LEFT JOIN email_maintain e ON m.from_address = e.email_address
<where> <where>
<if test="fromAddress != null and fromAddress != ''"> <if test="deptId != null and deptId != ''">
and from_address = #{fromAddress} and e.dept_id = #{deptId}
</if>
<if test="receiveAddress != null and receiveAddress != ''">
and receive_address = #{receiveAddress}
</if> </if>
<if test="sentDate != null and sentDate != ''"> <if test="username != null and username != ''">
and sent_date = #{sentDate} and e.username = #{username}
</if> </if>
<if test="fileType != null and fileType != ''"> <if test="userId != null and userId != ''">
and file_type = #{fileType} and e.user_id = #{userId}
</if> </if>
<if test="fpdm != null and fpdm != ''"> <if test="createUser != null and createUser != ''">
and fpdm = #{fpdm} and e.create_user = #{createUser}
</if>
<if test="fphm != null and fphm != ''">
and fphm = #{fphm}
</if>
<if test="msgUid != null and msgUid != ''">
and msg_uid = #{msgUid}
</if> </if>
<if test="ocrType != null and ocrType != ''"> <if test="ocrType != null and ocrType != ''">
and ocr_type = #{ocrType} and m.ocr_type = #{ocrType}
</if> </if>
<if test="errorMsg != null and errorMsg != ''"> <if test="startTime !=null and startTime != ''">
and error_msg = #{errorMsg} and m.create_time >= #{startTime}
</if>
<if test="fileName != null and fileName != ''">
and file_name = #{fileName}
</if> </if>
<if test="createTime != null"> <if test="endTime !=null and endTime != ''">
and create_time = #{createTime} and #{endTime} >= m.create_time
</if> </if>
</where> </where>
</select> </select>

Loading…
Cancel
Save