Kaynağa Gözat

fix:合并代码

wangzaijun 7 ay önce
ebeveyn
işleme
8abb27a7a2

+ 1 - 2
service-base/src/main/java/com/simuwang/base/common/util/EmailUtil.java

@@ -255,7 +255,7 @@ public class EmailUtil {
         return props;
     }
 
-    public static void senEmail(MailboxInfoDTO mailboxInfoDTO, String emails, File file, JavaMailSender javaMailSender) throws Exception {
+    public static void senEmail(MailboxInfoDTO mailboxInfoDTO, String emails, File file, JavaMailSender javaMailSender,String htmlText) throws Exception {
         logger.info("send email begin .........");
         // 根据Session 构建邮件信息
         MimeMessage message = javaMailSender.createMimeMessage();
@@ -279,7 +279,6 @@ public class EmailUtil {
         BodyPart bodyPart = new MimeBodyPart();
         logger.info("组装 htmlText.........");
         // 邮件内容
-        String htmlText = "<p>您好,附件为产品的数据未发送到最新,麻烦尽快发送缺失的数据。若是产品清算或者有其他原因不再发送数据,还请将产品的清算日期或者不再发送数据的原因发送给我们,非常感谢~\n</p>";
         bodyPart.setContent(htmlText, "text/html;charset=utf-8");
         //设置附件
         BodyPart filePart = new MimeBodyPart();

+ 3 - 1
service-base/src/main/java/com/simuwang/base/pojo/dos/report/ReportBaseInfoDO.java

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.util.Date;
+
 /**
  * @author wangzaijun
  * @date 2024/9/26 16:44
@@ -16,7 +18,7 @@ public class ReportBaseInfoDO extends BaseReportDO {
     /**
      * 报告日期
      */
-    private String reportDate;
+    private Date reportDate;
     /**
      * 报告名称
      */

+ 2 - 1
service-base/src/main/java/com/simuwang/base/pojo/dto/report/ReportBaseInfoDTO.java

@@ -1,5 +1,6 @@
 package com.simuwang.base.pojo.dto.report;
 
+import cn.hutool.core.date.DateUtil;
 import com.simuwang.base.pojo.dos.report.ReportBaseInfoDO;
 import lombok.Getter;
 import lombok.Setter;
@@ -29,7 +30,7 @@ public class ReportBaseInfoDTO extends BaseReportDTO<ReportBaseInfoDO> {
     public ReportBaseInfoDO toEntity() {
         ReportBaseInfoDO entity = new ReportBaseInfoDO();
         entity.setFileId(this.getFileId());
-        entity.setReportDate(this.reportDate);
+        entity.setReportDate(this.reportDate == null ? null : DateUtil.parseDate(this.reportDate));
         entity.setReportName(this.reportName);
         entity.setReportType(this.reportType);
         return entity;

+ 6 - 0
service-base/src/main/resources/mapper/EmailTemplateInfoMapper.xml

@@ -38,6 +38,9 @@
         <if test="name != null and name !=''">
             and name like concat('%',#{name},'%')
         </if>
+        <if test="keyword != null and keyword !=''">
+            and name like concat('%',#{keyword},'%')
+        </if>
         <if test="type != null">
             and type =#{type}
         </if>
@@ -53,6 +56,9 @@
         <if test="name != null and name !=''">
             and name like concat('%',#{name},'%')
         </if>
+        <if test="keyword != null and keyword !=''">
+            and name like concat('%',#{keyword},'%')
+        </if>
         <if test="type != null">
             and type =#{type}
         </if>

+ 2 - 2
service-base/src/main/resources/mapper/EmailTemplateMappingMapper.xml

@@ -65,7 +65,7 @@
         <if test="templateName != null and templateName != ''">
             and t.name like concat('%',#{templateName},'%')
         </if>
-        <if test="status != null and status !=''">
+        <if test="status != null">
             and mapping.status=#{status}
         </if>
         limit #{offset},#{pageSize}
@@ -87,7 +87,7 @@
         <if test="templateName != null and templateName != ''">
             and t.name like concat('%',#{templateName},'%')
         </if>
-        <if test="status != null and status !=''">
+        <if test="status != null">
             and mapping.status=#{status}
         </if>
     </select>

+ 2 - 1
service-base/src/main/resources/mapper/system/SysConfigMapper.xml

@@ -51,6 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 				AND config_key like concat('%', #{configKey}, '%')
 			</if>
 		</where>
+		order by updatetime desc
 		limit #{offset},#{pageSize}
     </select>
     
@@ -64,7 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where config_key = #{configKey}  and isvalid =1 limit 1
     </select>
     <select id="selectConfigByKey" resultType="java.lang.String">
-
+            select config_value from PPW_EMAIL.sys_config where config_key = #{configKey}  and isvalid =1 limit 1
     </select>
     <select id="countConfigList" resultType="java.lang.Long">
         select count(1) from PPW_EMAIL.sys_config

+ 4 - 0
service-daq/src/main/java/com/simuwang/daq/components/report/parser/py/AbstractPyReportParser.java

@@ -18,6 +18,7 @@ import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.util.Map;
+import java.util.Objects;
 
 /**
  * @author wangzaijun
@@ -62,6 +63,9 @@ public abstract class AbstractPyReportParser<T extends ReportData> implements Re
         }
         String body = HttpUtil.post(pyBaseUrl + api, JSONUtil.toJsonStr(params));
         PythonResult<T> result = PythonReportConverter.convert(JSONUtil.parseObj(body), reportType);
+        if (!Objects.equals(1, result.getStatus())) {
+            this.logger.error("报告{} 解析失败:{}", params, result.getMsg());
+        }
         return result.getData();
     }
 

+ 91 - 0
service-manage/src/main/java/com/simuwang/manage/init/CompleteScheduleConfig.java

@@ -0,0 +1,91 @@
+package com.simuwang.manage.init;
+
+import com.simuwang.base.common.util.DateUtils;
+import com.simuwang.base.mapper.system.SysConfigMapper;
+import com.simuwang.manage.task.FundDeletionTask;
+import com.simuwang.manage.task.SendCompanyEmailTask;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.SchedulingConfigurer;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
+import org.springframework.scheduling.config.ScheduledTaskRegistrar;
+import org.springframework.scheduling.support.CronTrigger;
+
+import java.time.LocalDateTime;
+
+
+/**
+ * TODO
+ * @version 1.0
+ * @author chenjianhua
+ * @date 2021/12/29 13:35
+ */
+@Configuration
+@EnableScheduling
+public class CompleteScheduleConfig implements SchedulingConfigurer {
+
+    private static Logger logger = LoggerFactory.getLogger(CompleteScheduleConfig.class);
+
+    @Autowired
+    private FundDeletionTask fundDeletionTask;
+
+    @Autowired
+    private SendCompanyEmailTask sendCompanyEmailTask;
+
+    @Autowired
+    private SysConfigMapper sysConfigMapper;
+    /**
+     * 执行定时任务.
+     */
+    @Override
+    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
+        ThreadPoolTaskScheduler taskScheduler=new ThreadPoolTaskScheduler();
+        // 设定最大可用的线程数目
+        taskScheduler.setPoolSize(10);
+        taskScheduler.initialize();
+        taskRegistrar.setScheduler(taskScheduler);
+        taskRegistrar.addTriggerTask(
+                //1.添加任务内容(Runnable)
+                () -> {
+                    try {
+                        logger.info("缺失统计任务开始"+ DateUtils.getTime());
+                        fundDeletionTask.computeDeletion();//定时拉取数据
+                        logger.info("缺失统计任务结束"+ DateUtils.getTime());
+                    } catch (Exception e) {
+                        logger.error("缺失统计任务异常========="+e.getMessage()+"----" +DateUtils.getTime(),e);
+                    }
+                },
+                //2.设置执行周期(Trigger)
+                loadFtpFileTriggerContext -> {
+                    String cron = sysConfigMapper.selectConfigByKey("deletion_cron");
+                    logger.info("缺失统计定时任务执行时间:"+cron);
+                    //2.2 返回执行周期(Date)
+                    return new CronTrigger(cron).nextExecutionTime(loadFtpFileTriggerContext).toInstant();
+                }
+        );
+        //增量补数
+        taskRegistrar.addTriggerTask(
+                //1.添加任务内容(Runnable)
+                () -> {
+                    try {
+                        logger.info("给管理人发送基金缺失预警邮件定时任务开始"+DateUtils.getTime());
+                        sendCompanyEmailTask.sendEmail();//定时拉取数据
+                        logger.info("给管理人发送基金缺失预警邮件定时任务结束========="+ DateUtils.getTime());
+                    } catch (Exception e) {
+                        logger.error("给管理人发送基金缺失预警邮件定时任务异常========="+e.getMessage()+ DateUtils.getTime(),e);
+                    }
+                },
+                //2.设置执行周期(Trigger)
+                loadFtpFileUpdateTriggerContext -> {
+                    String cron = sysConfigMapper.selectConfigByKey("send_company_email");
+                    logger.info("给管理人发送基金缺失预警邮件定时任务轮训时间:"+cron);
+                    //2.2 返回执行周期(Date)
+                    return new CronTrigger(cron).nextExecutionTime(loadFtpFileUpdateTriggerContext).toInstant();
+                }
+        );
+    }
+
+}

+ 7 - 1
service-manage/src/main/java/com/simuwang/manage/service/impl/CompanyEmailConfigServiceImpl.java

@@ -11,6 +11,7 @@ import com.simuwang.base.mapper.CompanyEmailConfigMapper;
 import com.simuwang.base.mapper.CompanyEmailSendHistoryMapper;
 import com.simuwang.base.mapper.DeletionInfoMapper;
 import com.simuwang.base.mapper.FundInfoMapper;
+import com.simuwang.base.mapper.system.SysConfigMapper;
 import com.simuwang.base.pojo.dos.CompanyEmailConfigDO;
 import com.simuwang.base.pojo.dos.CompanyEmailSendHistoryDO;
 import com.simuwang.base.pojo.dos.EmailDeletionInfoDO;
@@ -55,6 +56,9 @@ public class CompanyEmailConfigServiceImpl implements CompanyEmailConfigService
     @Resource
     private JavaMailSender javaMailSender;
 
+    @Autowired
+    private SysConfigMapper sysConfigMapper;
+
     @Value("${email.file.path}")
     private String path;
     @Value("${spring.mail.username}")
@@ -172,7 +176,9 @@ public class CompanyEmailConfigServiceImpl implements CompanyEmailConfigService
             file.setExecutable(true);
             try {
                 MailboxInfoDTO dto = getFromEmailInfo();
-                EmailUtil.senEmail(dto,emails,file,javaMailSender);
+                // "<p>您好,附件为产品的数据未发送到最新,麻烦尽快发送缺失的数据。若是产品清算或者有其他原因不再发送数据,还请将产品的清算日期或者不再发送数据的原因发送给我们,非常感谢~\n</p>";
+                String htmlText = sysConfigMapper.selectConfigByKey("deletion_email_body");
+                EmailUtil.senEmail(dto,emails,file,javaMailSender,htmlText);
                 //发送成功之后修改数据为已发送
                 deletionInfoMapper.updateSendStatusByFundId(fundIdList);
                 //写入发送历史

+ 2 - 2
service-manage/src/main/java/com/simuwang/manage/task/FundDeletionTask.java

@@ -25,7 +25,7 @@ import java.util.stream.Collectors;
  * Date:     2024/9/18 22:43
  * Description: ${DESCRIPTION}
  */
-@EnableScheduling
+//@EnableScheduling
 @Component
 public class FundDeletionTask {
 
@@ -33,7 +33,7 @@ public class FundDeletionTask {
     private NavMapper navMapper;
     @Autowired
     private DeletionService deletionService;
-    @Scheduled(cron = "0 0 5,12,19 * * ?")
+//    @Scheduled(cron = "0 0 5,12,19 * * ?")
     public void computeDeletion(){
         List<String> fundIdList = navMapper.getAllFundId();
         for(String fundId : fundIdList){

+ 2 - 2
service-manage/src/main/java/com/simuwang/manage/task/SendCompanyEmailTask.java

@@ -18,7 +18,7 @@ import java.util.stream.Collectors;
  * Date:     2024/9/20 22:45
  * Description: ${DESCRIPTION}
  */
-@EnableScheduling
+//@EnableScheduling
 @Component
 public class SendCompanyEmailTask {
 
@@ -28,7 +28,7 @@ public class SendCompanyEmailTask {
 
     @Autowired
     private CompanyEmailConfigService companyEmailConfigService;
-    @Scheduled(cron = "0 09 15 * * ?")
+//    @Scheduled(cron = "0 09 15 * * ?")
     public void sendEmail(){
         List<CompanyEmailConfigDO> configDOList = companyEmailConfigMapper.getAllCompanyConfig();
         Map<String,List<CompanyEmailConfigDO>> companyListMap = configDOList.stream().collect(Collectors.groupingBy(e -> e.getCompanyId()));