diff --git a/dxhy-core/src/main/java/com/dxhy/core/controller/mailGather/EmailMaintainController.java b/dxhy-core/src/main/java/com/dxhy/core/controller/mailGather/EmailMaintainController.java index b2f4cf11..53dca740 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/controller/mailGather/EmailMaintainController.java +++ b/dxhy-core/src/main/java/com/dxhy/core/controller/mailGather/EmailMaintainController.java @@ -4,7 +4,9 @@ import cn.hutool.core.codec.Base64; import cn.hutool.core.util.ObjectUtil; import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSONObject; +import com.dxhy.common.constant.DbConstant; import com.dxhy.common.controller.AbstractController; +import com.dxhy.common.datasource.config.DynamicContextHolder; import com.dxhy.common.util.UUIDUtils; import com.dxhy.common.utils.Base64Encoding; import com.dxhy.common.utils.R; @@ -91,6 +93,13 @@ public class EmailMaintainController extends AbstractController { } String loginname = getUserInfo().getLoginname(); 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); if(insert){ return ResponseEntity.ok(R.ok()); @@ -106,6 +115,16 @@ public class EmailMaintainController extends AbstractController { */ @PostMapping("/edit") public ResponseEntity 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); if(b){ return ResponseEntity.ok(R.ok()); @@ -142,6 +161,7 @@ public class EmailMaintainController extends AbstractController { errorMsgList.add("第" + resultIndex + "行,用户编码不能为空"); continue; } + DynamicContextHolder.push(DbConstant.BASICS_READ); String userName = emailMaintainService.getUserName(userId); if(StringUtils.isBlank(userName)){ errorMsgList.add("第" + resultIndex + "行,用户编码在系统中查询不到,请核实!"); diff --git a/dxhy-core/src/main/java/com/dxhy/core/controller/mailGather/MailGatherLogController.java b/dxhy-core/src/main/java/com/dxhy/core/controller/mailGather/MailGatherLogController.java index 6815c9d5..448522f5 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/controller/mailGather/MailGatherLogController.java +++ b/dxhy-core/src/main/java/com/dxhy/core/controller/mailGather/MailGatherLogController.java @@ -1,8 +1,12 @@ package com.dxhy.core.controller.mailGather; +import com.dxhy.common.constant.DbConstant; import com.dxhy.common.controller.AbstractController; +import com.dxhy.common.datasource.config.DynamicContextHolder; import com.dxhy.common.utils.R; 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.web.bind.annotation.PostMapping; 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 javax.annotation.Resource; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.Map; /** @@ -18,6 +25,7 @@ import java.util.Map; * @author makejava * @since 2023-03-23 08:42:35 */ +@Slf4j @RestController @RequestMapping("/mailGatherLog") public class MailGatherLogController extends AbstractController { @@ -26,6 +34,7 @@ public class MailGatherLogController extends AbstractController { */ @Resource 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"))) { 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))); } diff --git a/dxhy-core/src/main/java/com/dxhy/core/dao/mailGather/EmailMaintainDao.java b/dxhy-core/src/main/java/com/dxhy/core/dao/mailGather/EmailMaintainDao.java index 4cad42c4..67042ce5 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/dao/mailGather/EmailMaintainDao.java +++ b/dxhy-core/src/main/java/com/dxhy/core/dao/mailGather/EmailMaintainDao.java @@ -35,7 +35,7 @@ public interface EmailMaintainDao extends BaseMapper { * @param emailMaintainVo 查询条件 * @return 总行数 */ - long count(EmailMaintainVo emailMaintainVo); + EmailMaintainVo getEmailMaintainVo(EmailMaintainVo emailMaintainVo); /** * 新增数据 diff --git a/dxhy-core/src/main/java/com/dxhy/core/job/service/impl/ConfirmServiceImpl.java b/dxhy-core/src/main/java/com/dxhy/core/job/service/impl/ConfirmServiceImpl.java index d7983001..8c0c8b3a 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/job/service/impl/ConfirmServiceImpl.java +++ b/dxhy-core/src/main/java/com/dxhy/core/job/service/impl/ConfirmServiceImpl.java @@ -102,6 +102,9 @@ public class ConfirmServiceImpl extends ServiceImpl impl if (list != null && list.size() > 0) { for (TAcOrg tAcOrg : list) { + + DynamicContextHolder.push(DbConstant.BASICS_READ); + BasisSysDeptCfg baseSysDeptCfg = basisSysDeptCfgDao.selectOne(new QueryWrapper().eq("nsrsbh", tAcOrg.getTaxno())); if (baseSysDeptCfg != null) { continue; diff --git a/dxhy-core/src/main/java/com/dxhy/core/model/mailGather/MailGatherLogVo.java b/dxhy-core/src/main/java/com/dxhy/core/model/mailGather/MailGatherLogVo.java index 2e665fa2..5e8a9a96 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/model/mailGather/MailGatherLogVo.java +++ b/dxhy-core/src/main/java/com/dxhy/core/model/mailGather/MailGatherLogVo.java @@ -26,4 +26,17 @@ public class MailGatherLogVo extends CommonDTO { private String fileName; private Date createTime; + + public String deptId; + + private String companyCode; + + public String deptName; + + public String username; + + public String userId; + + public String createUser; + } diff --git a/dxhy-core/src/main/java/com/dxhy/core/service/mailGather/EmailMaintainService.java b/dxhy-core/src/main/java/com/dxhy/core/service/mailGather/EmailMaintainService.java index 99328e74..d855e687 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/service/mailGather/EmailMaintainService.java +++ b/dxhy-core/src/main/java/com/dxhy/core/service/mailGather/EmailMaintainService.java @@ -51,4 +51,6 @@ public interface EmailMaintainService { String getUserName(String userCode); int insertBatch(List entities); + + EmailMaintainVo getEmailMaintainVo(EmailMaintainVo emailMaintain); } diff --git a/dxhy-core/src/main/java/com/dxhy/core/service/mailGather/impl/EmailMaintainServiceImpl.java b/dxhy-core/src/main/java/com/dxhy/core/service/mailGather/impl/EmailMaintainServiceImpl.java index 892b849f..338a5daa 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/service/mailGather/impl/EmailMaintainServiceImpl.java +++ b/dxhy-core/src/main/java/com/dxhy/core/service/mailGather/impl/EmailMaintainServiceImpl.java @@ -70,6 +70,7 @@ public class EmailMaintainServiceImpl implements EmailMaintainService { */ @Override public boolean insert(EmailMaintainVo emailMaintain) { + DynamicContextHolder.push(DbConstant.BASICS_READ); if(StringUtils.isEmpty(emailMaintain.getId())){ emailMaintain.setId(IdUtil.nanoId()); } @@ -116,6 +117,11 @@ public class EmailMaintainServiceImpl implements EmailMaintainService { return emailMaintainDao.insertBatch(entities); } + @Override + public EmailMaintainVo getEmailMaintainVo(EmailMaintainVo emailMaintain) { + return emailMaintainDao.getEmailMaintainVo(emailMaintain); + } + //根据用户名进行查询 public void getdeptInfo(String deptId){ DynamicContextHolder.push(DbConstant.BASICS_READ); diff --git a/dxhy-core/src/main/java/com/dxhy/core/service/mailGather/impl/MailGatherLogServiceImpl.java b/dxhy-core/src/main/java/com/dxhy/core/service/mailGather/impl/MailGatherLogServiceImpl.java index 83ebd997..12e63f4f 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/service/mailGather/impl/MailGatherLogServiceImpl.java +++ b/dxhy-core/src/main/java/com/dxhy/core/service/mailGather/impl/MailGatherLogServiceImpl.java @@ -5,16 +5,19 @@ import cn.hutool.core.codec.Base64; import com.alibaba.fastjson.JSONObject; import com.dxhy.common.constant.DbConstant; import com.dxhy.common.datasource.config.DynamicContextHolder; +import com.dxhy.common.util.UUIDUtils; import com.dxhy.core.dao.mailGather.MailGatherLogDao; import com.dxhy.core.model.mailGather.MailGatherLogVo; import com.dxhy.core.service.mailGather.MailGatherLogService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.Map; @@ -70,6 +73,10 @@ public class MailGatherLogServiceImpl implements MailGatherLogService { */ @Override public MailGatherLogVo insert(MailGatherLogVo mailGatherLog) { + if(StringUtils.isEmpty(mailGatherLog.getId())){ + mailGatherLog.setId(UUIDUtils.generateShortUuid()); + } + mailGatherLog.setCreateTime(new Date()); this.mailGatherLogDao.insert(mailGatherLog); return mailGatherLog; } diff --git a/dxhy-core/src/main/java/com/dxhy/core/service/openservice/impl/OpenServicePlatformServiceImpl.java b/dxhy-core/src/main/java/com/dxhy/core/service/openservice/impl/OpenServicePlatformServiceImpl.java index 8fe4a8f7..1e44ea59 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/service/openservice/impl/OpenServicePlatformServiceImpl.java +++ b/dxhy-core/src/main/java/com/dxhy/core/service/openservice/impl/OpenServicePlatformServiceImpl.java @@ -205,8 +205,8 @@ public class OpenServicePlatformServiceImpl implements IOpenServicePlatformServi */ public List OcrToSn(String picture){ //判断是否为图片流文件, 兼容公司平台进行base64解密 - String str = Base64Decoder.decodeStr(picture); String requestUrl = snOcrUrl; + log.info("调用山能OCR识别请求路径:"+snOcrUrl); String result = FileUtil.uploadFile(requestUrl, Base64Decoder.decode(picture)); if(StringUtils.isBlank(result)){ log.info("调用山能ocr识别失败"); @@ -227,7 +227,6 @@ public class OpenServicePlatformServiceImpl implements IOpenServicePlatformServi */ public static List OcrToSnTest(String picture){ //判断是否为图片流文件, 兼容公司平台进行base64解密 - String str = Base64Decoder.decodeStr(picture); String requestUrl = "http://192.168.33.102:30006/cci_ai/service/v1/receipt_crop_and_recog?crop_complete_image=1"; String result = FileUtil.uploadFile(requestUrl, Base64Decoder.decode(picture)); if(StringUtils.isBlank(result)){ diff --git a/dxhy-core/src/main/java/com/dxhy/core/service/openservice/model/ocr/SnpjInvoiceTypeEnum.java b/dxhy-core/src/main/java/com/dxhy/core/service/openservice/model/ocr/SnpjInvoiceTypeEnum.java new file mode 100644 index 00000000..0dc78f77 --- /dev/null +++ b/dxhy-core/src/main/java/com/dxhy/core/service/openservice/model/ocr/SnpjInvoiceTypeEnum.java @@ -0,0 +1,78 @@ +package com.dxhy.core.service.openservice.model.ocr; + +import lombok.AllArgsConstructor; + +@AllArgsConstructor +public enum SnpjInvoiceTypeEnum { + + TAX_SPECIAL_INVOICE("01","100", "增值税专用发票"), + TAX_INVOICE("04","101", "增值税普通发票" ), + ELECTRONIC_INVOICE("10","102","增值税电子普通发票"), + ROLL_TICKET("11","103","增值税普通发票(卷票)"), + MOTOR_VEHICLE_SALE("15","104","机动车销售统一发票"), + USED_CAR_SALES("15","105","二手车销售统一发票"), + QUOTA_INVOICE("95","106","定额发票"), + AIRCRAFT_INVOICE("97","107","机打发票"), + TAXI_TICKETS("91","108","出租车发票"), + RAILWAY_TICKET("92","109","火车票"), + PASSENGER_TICKET("94","110","客运汽车票"), + FLIGHT_ITINERARY("93","111","航空运输电子客票行程单"), + STEAMER_TICKET("00","112","船票"), + TOLL_ROADS("98","113","过路费"), + RECEIPT("96","115","小票"), + DIDI_ITINERARY("86","116","滴滴出行行程单"), + DUTY_PAID_PROOF("87","117","完税证明"), + ELECTRONIC_INVOICE_ITINERARY("14","118","增值税电子普通发票(通行费)"), +// ELECTRONIC_INVOICE_QUKUAILIAN("119","区块链发票", ""), +// PLACE_AIRCRAFT_INVOICE("120","浙江通用机打发票", ""), + ELECTRONIC_OFD_INVOICE("04","121","增值税电子专用发票"), + ELECTRONIC_TAX_SPECIAL_INVOICE("31","130","电子发票(增值税专用发票)"), + ELECTRONIC_TAX_INVOICE("32","131","电子发票(普通发票)"), +// FINAL_STATEMENT("200","结算单", ""), +// RECEIPT_OF_RECEIPT("201","验收单", ""), + IMAGE_OTHERS("00","444","其他"); + + private String key; + + private String value; + + private String msg; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public static String getVal(String key) { + for (SnpjInvoiceTypeEnum typeEnum : SnpjInvoiceTypeEnum.values()) { + if (typeEnum.key.equals(key)) { + return typeEnum.getValue(); + } + } + return null; + } + + public static void main(String[] args) { + String val = getVal("00"); + System.out.println(val); + } +} diff --git a/dxhy-core/src/main/java/com/dxhy/core/task/SnEmailGatherTask.java b/dxhy-core/src/main/java/com/dxhy/core/task/SnEmailGatherTask.java index 0e009d08..32d6e59d 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/task/SnEmailGatherTask.java +++ b/dxhy-core/src/main/java/com/dxhy/core/task/SnEmailGatherTask.java @@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject; import com.dxhy.common.constant.DbConstant; import com.dxhy.common.datasource.config.DynamicContextHolder; import com.dxhy.common.util.MD5; +import com.dxhy.common.util.UUIDUtils; import com.dxhy.core.job.entity.ScheduleJobEntity; import com.dxhy.core.job.service.ScheduleJobService; import com.dxhy.core.model.mailGather.EmailMaintainVo; @@ -18,6 +19,7 @@ import com.dxhy.core.service.mailGather.EmailMaintainService; import com.dxhy.core.service.mailGather.MailGatherLogService; import com.dxhy.core.service.openservice.IOpenServicePlatformService; import com.dxhy.core.service.openservice.impl.OpenServicePlatformServiceImpl; +import com.dxhy.core.service.openservice.model.ocr.SnpjInvoiceTypeEnum; import com.dxhy.core.util.EmailParseUtils; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -70,13 +72,19 @@ public class SnEmailGatherTask { if(maintainVos != null && !maintainVos.isEmpty()){ for (EmailMaintainVo maintainVo : maintainVos) { //挨个邮箱进行数据采集 - parseEmail(maintainVo); + try { + parseEmail(maintainVo); + } catch (Exception e) { + log.error("邮箱采集错误日志:{}", e); + throw new RuntimeException(e); + } } }else { log.info("未配置邮箱数据--"); } log.info("邮箱采集接口执行结束--"); } catch (Exception e) { + log.error("邮箱采集错误日志:{}", e); e.printStackTrace(); } finally { log.info("邮箱采集--重置执行状态"); @@ -98,10 +106,9 @@ public class SnEmailGatherTask { Store store = mailAuth(emailName, password); if(store == null){ MailGatherLogVo gatherLogVo = new MailGatherLogVo(); - gatherLogVo.setId(IdUtil.nanoId()); + gatherLogVo.setId(UUIDUtils.generateShortUuid()); gatherLogVo.setErrorMsg("邮箱认证失败"); gatherLogVo.setOcrType("1"); - gatherLogVo.setCreateTime(new Date()); gatherLogVo.setFromAddress(emailName); mailGatherLogService.insert(gatherLogVo); return; @@ -127,17 +134,19 @@ public class SnEmailGatherTask { gatherLogVo.setId(IdUtil.nanoId()); gatherLogVo.setSubject(EmailParseUtils.getSubject(msg)); gatherLogVo.setFromAddress(emailName); - gatherLogVo.setReceiveAddress(EmailParseUtils.getReceiveAddress(msg, null)); - gatherLogVo.setSentDate( EmailParseUtils.getSentDate(msg, null)); +// String address = EmailParseUtils.getReceiveAddress(msg, null); + gatherLogVo.setReceiveAddress(emailName); + String sentDate = EmailParseUtils.getSentDate(msg, null); + gatherLogVo.setSentDate(sentDate); gatherLogVo.setCreateTime(new Date()); log.debug("主题: " + EmailParseUtils.getSubject(msg)); log.debug("发件人: " + EmailParseUtils.getFrom(msg)); - log.debug("收件人:" + EmailParseUtils.getReceiveAddress(msg, null)); - log.debug("发送时间:" + EmailParseUtils.getSentDate(msg, null)); +// log.debug("收件人:" + address); + log.debug("发送时间:" + sentDate); log.debug("是否已读:" + EmailParseUtils.isSeen(msg)); - log.debug("邮件优先级:" + EmailParseUtils.getPriority(msg)); - log.debug("是否需要回执:" + EmailParseUtils.isReplySign(msg)); +// log.debug("邮件优先级:" + EmailParseUtils.getPriority(msg)); +// log.debug("是否需要回执:" + EmailParseUtils.isReplySign(msg)); log.debug("邮件大小:" + msg.getSize() * 1024 + "kb"); POP3Folder inbox = (POP3Folder) folder; @@ -147,18 +156,22 @@ public class SnEmailGatherTask { } //增量处理 等于之后就跳过本地循环 if(StringUtils.isNotBlank(maintainVo.getEmailUid()) && maintainVo.getEmailUid().equals(uid)){ - return; + log.debug("跳过本次循环: "+maintainVo.getEmailUid()+"===="+uid); + continue; } gatherLogVo.setMsgUid(uid); boolean isContainerAttachment = EmailParseUtils.isContainAttachment(msg); + log.debug("是否有附件: "+isContainerAttachment); if(isContainerAttachment){ List> mapList = Lists.newArrayList(); EmailParseUtils.saveAttachment(msg, mapList); + log.debug("获取附件的数量:"+mapList.size()); for (Map map : mapList) { map.put("emailName",emailName); String pdfStream = map.get("pdfStream"); if(StringUtils.isNotBlank(pdfStream)){ - List openServiceOcrs = OpenServicePlatformServiceImpl.OcrToSnTest(pdfStream); + log.debug("开始调用山能OCR识别---------"); + List openServiceOcrs = openServicePlatformService.ocrInvoice(pdfStream); if(openServiceOcrs != null && !openServiceOcrs.isEmpty()){ Map ocrResult = convertToOcrResult(openServiceOcrs, map, maintainVo); try { @@ -184,6 +197,8 @@ public class SnEmailGatherTask { throw new RuntimeException(e); } + }else { + log.debug("山能OCR识别失败------"); } } } @@ -205,8 +220,10 @@ public class SnEmailGatherTask { store.close(); log.info("邮箱采集使用时间:{}",System.currentTimeMillis() - startTime); } catch (MessagingException e) { + log.error("邮箱采集邮件解析异常:{}", e); throw new RuntimeException(e); } catch (IOException e) { + log.error("邮箱采集IO异常:{}", e); throw new RuntimeException(e); } } @@ -229,7 +246,7 @@ public class SnEmailGatherTask { resultToyxVo.setBuyerName(invoiceOcrData.getGMFMC()); resultToyxVo.setSellerName(invoiceOcrData.getXHFMC()); resultToyxVo.setFileName(map.get("fileName")); - resultToyxVo.setFileType("102"); + resultToyxVo.setFileType(SnpjInvoiceTypeEnum.getVal(openServiceOcr.getFPLXDM())); resultToyxVo.setFileByte(map.get("pdfStream")); resultToyxVo.setEmail(map.get("emailName")); resultToyxVo.setEmployeeId(maintainVo.getUserId()); diff --git a/dxhy-core/src/main/java/com/dxhy/core/task/SnEmailGatherTaskTest.java b/dxhy-core/src/main/java/com/dxhy/core/task/SnEmailGatherTaskTest.java index f18287d5..3c5b6fdb 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/task/SnEmailGatherTaskTest.java +++ b/dxhy-core/src/main/java/com/dxhy/core/task/SnEmailGatherTaskTest.java @@ -37,8 +37,10 @@ class SnEmailGatherTaskTest { String port = "110"; //邮件接收服务器地址 String mail_host = "mail.pop3.host"; - String emailName = "15201210373@163.com"; - String password = "JKZATQTPHDDQTQSH"; + String emailName = "745139984@qq.com"; + String password = "ncmydeiilzyabfgb"; +// String emailName = "15201210373@163.com"; +// String password = "JKZATQTPHDDQTQSH"; String mailSuffix = emailName.split("@")[1]; //邮箱类型 String mailType = mailSuffix.split("\\.")[0]; @@ -60,8 +62,8 @@ class SnEmailGatherTaskTest { store.connect(emailName, password); //连接邮箱服务器 //获取当前时间 - Date currentTime = new Date(); - // 获得收件箱 pop3协议只有一个有效的文件夹就是INBOX +// Date currentTime = new Date(); + // 品 ping获得收件箱 pop3协议只有一个有效的文件夹就是INBOX Folder folder = store.getFolder("INBOX"); //获取邮件列表 folder.open(Folder.READ_WRITE); @@ -85,13 +87,14 @@ class SnEmailGatherTaskTest { System.out.println("------------------解析第" + msg.getMessageNumber() + "封邮件-------------------- "); System.out.println("主题: " + EmailParseUtils.getSubject(msg)); System.out.println("发件人: " + EmailParseUtils.getFrom(msg)); - System.out.println("收件人:" + EmailParseUtils.getReceiveAddress(msg, null)); +// System.out.println("收件人:" + EmailParseUtils.getReceiveAddress(msg, null)); System.out.println("发送时间:" + EmailParseUtils.getSentDate(msg, null)); System.out.println("是否已读:" + EmailParseUtils.isSeen(msg)); System.out.println("邮件优先级:" + EmailParseUtils.getPriority(msg)); System.out.println("是否需要回执:" + EmailParseUtils.isReplySign(msg)); System.out.println("邮件大小:" + msg.getSize() * 1024 + "kb"); boolean isContainerAttachment = EmailParseUtils.isContainAttachment(msg); + System.out.println("是否有附件: "+isContainerAttachment); if(isContainerAttachment) { List> mapList = Lists.newArrayList(); EmailParseUtils.saveAttachment(msg, mapList); @@ -113,6 +116,7 @@ class SnEmailGatherTaskTest { Map resultMap = JSONObject.parseObject(body, Map.class); Object status = resultMap.get("status"); + System.out.println(JSONObject.toJSONString("================="+resultMap)); if(status != null && "200".equals(String.valueOf(status))){ } @@ -138,7 +142,7 @@ class SnEmailGatherTaskTest { System.out.println(""); } System.out.println(""); - Date endTime = new Date(); +// Date endTime = new Date(); //计算耗时时间 // double elapsedTime = CalendarUtil.arithDateTime(endTime, currentTime); // 释放资源 @@ -165,7 +169,7 @@ class SnEmailGatherTaskTest { OpenServiceOcr openServiceOcr = openServiceOcrs.get(i); OpenServiceOcr.InvoiceOcrData invoiceOcrData = openServiceOcr.getData(); OcrResultToyxVo resultToyxVo = new OcrResultToyxVo(); - resultToyxVo.setCompanyId(""); + resultToyxVo.setCompanyId("c040"); resultToyxVo.setSource("01"); resultToyxVo.setInvoiceCode(invoiceOcrData.getFPDM()); resultToyxVo.setInvoiceNumber(invoiceOcrData.getFPHM()); @@ -176,7 +180,7 @@ class SnEmailGatherTaskTest { resultToyxVo.setFileType("102"); resultToyxVo.setFileByte(map.get("pdfStream")); resultToyxVo.setEmail(map.get("emailName")); - resultToyxVo.setEmployeeId(""); + resultToyxVo.setEmployeeId("01142085"); resultToyxVoList.add(resultToyxVo); } diff --git a/dxhy-core/src/main/java/com/dxhy/core/util/EmailParseUtils.java b/dxhy-core/src/main/java/com/dxhy/core/util/EmailParseUtils.java index 8ae7d7c2..b53732c8 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/util/EmailParseUtils.java +++ b/dxhy-core/src/main/java/com/dxhy/core/util/EmailParseUtils.java @@ -267,19 +267,20 @@ public class EmailParseUtils { //某一个邮件体也有可能是由多个邮件体组成的复杂体 String disp = bodyPart.getDisposition(); if (disp != null && (disp.equalsIgnoreCase(Part.ATTACHMENT) || disp.equalsIgnoreCase(Part.INLINE))) { - if ((StringUtils.isNotBlank(contentType)) && - (contentType.toUpperCase().contains("PDF") || contentType.toUpperCase().contains("OFD"))){ + if ((StringUtils.isNotBlank(contentType)) && (contentType.toUpperCase().contains("PDF") || contentType.toUpperCase().contains("OFD"))){ InputStream is = bodyPart.getInputStream(); byte[] pdfStream = IOUtils.toByteArray(is); - mapLog.put("contentType", contentType.toUpperCase().contains("PDF")?"PDF":"OFD"); + String pdf = contentType.toUpperCase().contains("PDF") ? "PDF" : "OFD"; + mapLog.put("contentType", pdf); if(pdfStream != null){ mapLog.put("pdfStream", Base64Encoding.encodeToString(pdfStream)); mapList.add(mapLog); } - }else if (StringUtils.isNotBlank(fileName) && "application/octet-stream".equals(contentType) && (fileName.endsWith("pdf") || fileName.endsWith("ofd"))){ + }else if (StringUtils.isNotBlank(fileName) && (fileName.toUpperCase().contains("PDF") || fileName.toUpperCase().contains("OFD"))){ InputStream is = bodyPart.getInputStream(); byte[] pdfStream = IOUtils.toByteArray(is); - mapLog.put("contentType", contentType.toUpperCase().contains("PDF")?"PDF":"OFD"); + String pdf = fileName.toUpperCase().contains("PDF") ? "PDF" : "OFD"; + mapLog.put("contentType", pdf); if(pdfStream != null){ mapLog.put("pdfStream", Base64Encoding.encodeToString(pdfStream)); mapList.add(mapLog); diff --git a/dxhy-core/src/main/resources/mapper/mailGather/EmailMaintainMapper.xml b/dxhy-core/src/main/resources/mapper/mailGather/EmailMaintainMapper.xml index d1ae63c0..9d3d1a52 100644 --- a/dxhy-core/src/main/resources/mapper/mailGather/EmailMaintainMapper.xml +++ b/dxhy-core/src/main/resources/mapper/mailGather/EmailMaintainMapper.xml @@ -48,7 +48,7 @@ - select count(1) from email_maintain diff --git a/dxhy-core/src/main/resources/mapper/mailGather/MailGatherLogMapper.xml b/dxhy-core/src/main/resources/mapper/mailGather/MailGatherLogMapper.xml index 734cbac5..16ebd4b3 100644 --- a/dxhy-core/src/main/resources/mapper/mailGather/MailGatherLogMapper.xml +++ b/dxhy-core/src/main/resources/mapper/mailGather/MailGatherLogMapper.xml @@ -28,42 +28,32 @@ diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/service/impl/ReceiptOutServiceImpl.java b/dxhy-erp/src/main/java/com/dxhy/erp/service/impl/ReceiptOutServiceImpl.java index 56402633..fbcaf001 100644 --- a/dxhy-erp/src/main/java/com/dxhy/erp/service/impl/ReceiptOutServiceImpl.java +++ b/dxhy-erp/src/main/java/com/dxhy/erp/service/impl/ReceiptOutServiceImpl.java @@ -132,8 +132,8 @@ public class ReceiptOutServiceImpl extends MpBaseServiceImpl 0) { throw new RRException("累计转出金额不能大于发票金额"); } + **/ // 转出金额 - condRecord.setOutInvoiceAmout(newOutAmount); + condRecord.setOutInvoiceAmout(record.getInvoiceAmount()); // 转出税额累加 BigDecimal oldOutTax = record.getOutTaxAmount() == null ? new BigDecimal(0) : record.getOutTaxAmount(); @@ -166,7 +169,7 @@ public class ReceiptOutServiceImpl extends MpBaseServiceImpl 0) { - throw new RRException("累计转出金额不能大于发票金额"); - } // 转出金额 - record.setOutInvoiceAmout(newOutAmount); + record.setOutInvoiceAmout(invoice.getInvoiceAmount()); // 转出税额累加 BigDecimal oldOutTax = record.getOutTaxAmount() == null ? new BigDecimal(0) : record.getOutTaxAmount(); @@ -232,7 +226,7 @@ public class ReceiptOutServiceImpl extends MpBaseServiceImpl getPullRecordList(@RequestBody PullRecordReq pullRecordReq){ + try{ + return ResponseEntity.ok(R.ok().put("data",extInvoicePoolService.selectPullRecord(pullRecordReq))); + }catch (Exception e){ + e.printStackTrace(); + log.error("",e); + return ResponseEntity.ok(R.error(CommonConstants.MSG_ERR_DEFAULT)); + + } + + } } diff --git a/dxhy-extend/src/main/java/com/dxhy/extend/dao/ExtInvoicePoolDao.java b/dxhy-extend/src/main/java/com/dxhy/extend/dao/ExtInvoicePoolDao.java index 7edda046..b98e92cc 100644 --- a/dxhy-extend/src/main/java/com/dxhy/extend/dao/ExtInvoicePoolDao.java +++ b/dxhy-extend/src/main/java/com/dxhy/extend/dao/ExtInvoicePoolDao.java @@ -3,12 +3,10 @@ package com.dxhy.extend.dao; import java.util.List; import java.util.Map; +import com.dxhy.extend.entity.*; import org.apache.ibatis.annotations.Mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.dxhy.extend.entity.AmortizeRecordEntity; -import com.dxhy.extend.entity.ExtAddTaxInvoice; -import com.dxhy.extend.entity.ExtOtherInvoice; /** * @author dxhy @@ -80,4 +78,6 @@ public interface ExtInvoicePoolDao extends BaseMapper { List listAmortizeRecord(Map pramsMap); List listIncentiveFlag(); + + List getPullRecord(PullRecordReq pullRecordReq); } diff --git a/dxhy-extend/src/main/java/com/dxhy/extend/entity/PullRecordModel.java b/dxhy-extend/src/main/java/com/dxhy/extend/entity/PullRecordModel.java new file mode 100644 index 00000000..45664035 --- /dev/null +++ b/dxhy-extend/src/main/java/com/dxhy/extend/entity/PullRecordModel.java @@ -0,0 +1,68 @@ +package com.dxhy.extend.entity; + +import lombok.Data; + +/** + * @Author wangzhikun + * @Date 2023/4/15 2023/4/15 + */ +@Data +public class PullRecordModel { + + //公司名称 + private String companyName; + //会计凭证号码 + private String belnr; + //会计年度 + private String gjahr; + //账期 + private String monat; + //过账日期 + private String budat; + //报账单号 + private String zbzdh; + + //结算单 + private String zjsdh; + //报账单状态 + private String zbzdzt; + //借贷标识 + private String zdrcrk; + //科目编码 + private String racct; + //科目描述 + private String txt50; + //供应商名称 + private String zname; + //供应商编码 + private String lifnr; + //客户编码 + private String kunnr; + //客户名称 + private String zname2; + //物料编码 + private String matnr; + //数量 + private String msl; + //单位 + private String runit; + //税码 + private String mwskz; + //税率 + private String kbetr; + //本位币借方金额 + private String zhslj; + //本位币贷方金额 + private String zhsld; + //销售订单 + private String kdauf; + //销售订单行 + private String kdpos; + //矿别编号 + private String kbbh; + //矿别 + private String ktype; + //最后接收时间 + private String lastReceiveTime; + +} diff --git a/dxhy-extend/src/main/java/com/dxhy/extend/entity/PullRecordReq.java b/dxhy-extend/src/main/java/com/dxhy/extend/entity/PullRecordReq.java new file mode 100644 index 00000000..75ffa921 --- /dev/null +++ b/dxhy-extend/src/main/java/com/dxhy/extend/entity/PullRecordReq.java @@ -0,0 +1,32 @@ +package com.dxhy.extend.entity; + +import lombok.Data; + +/** + * @Author wangzhikun + * @Date 2023/4/14 2023/4/14 + */ +@Data +public class PullRecordReq { + //公司名称 + private String companyName; + //账期 + private String accountPeriod; + //税码 + private String sm; + //科目编码 + private String kmbm; + //科目描述 + private String kmms; + //供应商名称 + private String supplierName; + //客户名称 + private String customerName; + //过账起始日期 + private String accountStartDate; + //过账终止日期 + private String accountEndDate; + + private int curr; + private int size; +} diff --git a/dxhy-extend/src/main/java/com/dxhy/extend/service/pool/ExtInvoicePoolService.java b/dxhy-extend/src/main/java/com/dxhy/extend/service/pool/ExtInvoicePoolService.java index aa3cc9b2..8365106e 100644 --- a/dxhy-extend/src/main/java/com/dxhy/extend/service/pool/ExtInvoicePoolService.java +++ b/dxhy-extend/src/main/java/com/dxhy/extend/service/pool/ExtInvoicePoolService.java @@ -4,6 +4,7 @@ import java.util.Map; import com.dxhy.common.service.MpBaseService; import com.dxhy.extend.entity.ExtAddTaxInvoice; +import com.dxhy.extend.entity.PullRecordReq; /** * @author dxhy @@ -59,4 +60,6 @@ public interface ExtInvoicePoolService extends MpBaseService { Object amortizeRecord(Map pramsMap); Object incentiveFlagList(String dbName); + + Object selectPullRecord(PullRecordReq pullRecordReq); } diff --git a/dxhy-extend/src/main/java/com/dxhy/extend/service/pool/ExtInvoicePoolServiceImpl.java b/dxhy-extend/src/main/java/com/dxhy/extend/service/pool/ExtInvoicePoolServiceImpl.java index cd42dae9..bbd9878e 100644 --- a/dxhy-extend/src/main/java/com/dxhy/extend/service/pool/ExtInvoicePoolServiceImpl.java +++ b/dxhy-extend/src/main/java/com/dxhy/extend/service/pool/ExtInvoicePoolServiceImpl.java @@ -3,6 +3,7 @@ package com.dxhy.extend.service.pool; import java.util.List; import java.util.Map; +import com.dxhy.extend.entity.*; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -14,9 +15,6 @@ import com.dxhy.common.service.impl.MpBaseServiceImpl; import com.dxhy.common.util.AmountFormatUtil; import com.dxhy.common.util.MathUtil; import com.dxhy.extend.dao.ExtInvoicePoolDao; -import com.dxhy.extend.entity.AmortizeRecordEntity; -import com.dxhy.extend.entity.ExtAddTaxInvoice; -import com.dxhy.extend.entity.ExtOtherInvoice; import com.dxhy.extend.util.InvoiceTypeUtils; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -406,6 +404,32 @@ public class ExtInvoicePoolServiceImpl extends MpBaseServiceImpl recordList=super.baseMapper.getPullRecord(pullRecordReq); + PageInfo pageInfo = new PageInfo<>(recordList); + json.put("total",pageInfo.getTotal()); + json.put("dataList",pageInfo.getList()); + + }catch (Exception e){ + e.printStackTrace(); + json = super.errorResult(e); + } + return super.responseResult(json); + } /** * 摊销记录 @@ -452,4 +476,5 @@ public class ExtInvoicePoolServiceImpl extends MpBaseServiceImpl + +