Commit 232078e7 authored by shenxin's avatar shenxin

蓉易办推送数据

parent b853a39f
...@@ -17,6 +17,7 @@ public enum NodeTypeEnum { ...@@ -17,6 +17,7 @@ public enum NodeTypeEnum {
受理("BusiType_1","11","受理"), 受理("BusiType_1","11","受理"),
审查("BusiType_13","21","审查"), 审查("BusiType_13","21","审查"),
决定("BusiType_8","41","决定"), 决定("BusiType_8","41","决定"),
已提交("BusiType_12","61","已提交"),
办结("end","81","办结"); 办结("end","81","办结");
private String code; private String code;
......
package com.mortals.xhx.modules.implementlist.dao;
import com.mortals.framework.dao.ICRUDDao;
import com.mortals.xhx.modules.implementlist.model.ImplementlistEntity;
import com.mortals.xhx.modules.implementlist.model.RybMatterListEntry;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface RybMatterDao extends ICRUDDao<ImplementlistEntity,Long> {
List<RybMatterListEntry> find(String eventCode);
void inserts(List<RybMatterListEntry> informationQueries);
}
package com.mortals.xhx.modules.implementlist.dao.ibatis;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import com.mortals.xhx.modules.implementlist.dao.ImplementlistDao;
import com.mortals.xhx.modules.implementlist.dao.RybMatterDao;
import com.mortals.xhx.modules.implementlist.model.ImplementlistEntity;
import com.mortals.xhx.modules.implementlist.model.RybMatterListEntry;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* <p>Title: 实施清单主表</p>
* <p>Description: ImplementlistDaoImpl DAO接口 </p>
* @author
* @version 1.0.0
*/
@Repository("rybMatterDao")
public class RybMatterDaoImpl extends BaseCRUDDaoMybatis<ImplementlistEntity,Long> implements RybMatterDao {
@Override
public List<RybMatterListEntry> find(String eventCode) {
return getSqlSession().selectList(getSqlId("findRyb"),eventCode);
}
@Override
public void inserts(List<RybMatterListEntry> informationQueries) {
getSqlSession().insert(getSqlId("insertRyb"),informationQueries);
}
}
package com.mortals.xhx.modules.implementlist.model;
/**
* 蓉易办对接实体类
*/
import com.mortals.framework.model.BaseEntityLong;
import lombok.Data;
import java.util.Date;
@Data
public class RybMatterListEntry extends BaseEntityLong {
//部门编码
private String deptCode;
//部门名称
private String deptName;
//事项名称
private String matterName;
//事项编码
private String matterCode;
//taskId
private String taskId;
//事项类型
private String matterType;
/**
* 是否推送(0 否 1是)
*/
private String isReport;
/**
* 是否成功(0 否 1是)
*/
private String isSuccess;
/**
* 失败次数
*/
private Integer failTimes;
/**
* 推送失败原因
*/
private String failReason;
private Date createTime;
}
package com.mortals.xhx.modules.implementlist.service;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.modules.implementlist.model.RybMatterListEntry;
public interface RybMatterListService{
RybMatterListEntry getThImplement(String event_code);
}
\ No newline at end of file
package com.mortals.xhx.modules.implementlist.service.impl;
import com.github.benmanes.caffeine.cache.Cache;
import com.mortals.xhx.modules.implementlist.dao.RybMatterDao;
import com.mortals.xhx.modules.implementlist.model.RybMatterListEntry;
import com.mortals.xhx.modules.implementlist.service.RybMatterListService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class RybMatterListServiceImpl implements RybMatterListService {
@Resource
private RybMatterDao rybMatterDao;
private final Cache<String, Object> caffeineCache;
@Override
public RybMatterListEntry getThImplement(String event_code) {
caffeineCache.getIfPresent(event_code);
RybMatterListEntry thImplementList = (RybMatterListEntry) caffeineCache.asMap().get(event_code);
if (thImplementList != null) {
return thImplementList;
}
//根据事项编码查
List<RybMatterListEntry> rybMatterListEntries = rybMatterDao.find(event_code);
if (rybMatterListEntries.size() > 0) {
for (RybMatterListEntry entity : rybMatterListEntries) {
thImplementList=entity;
caffeineCache.put(event_code, entity);
}
}
return thImplementList;
}
}
\ No newline at end of file
...@@ -11,8 +11,11 @@ import com.mortals.xhx.common.code.NodeTypeEnum; ...@@ -11,8 +11,11 @@ import com.mortals.xhx.common.code.NodeTypeEnum;
import com.mortals.xhx.common.utils.DateByAffairUtils; import com.mortals.xhx.common.utils.DateByAffairUtils;
import com.mortals.xhx.common.utils.FilterSuppDataUtils; import com.mortals.xhx.common.utils.FilterSuppDataUtils;
import com.mortals.xhx.common.utils.SnowFlakeUtil; import com.mortals.xhx.common.utils.SnowFlakeUtil;
import com.mortals.xhx.modules.implementlist.dao.RybMatterDao;
import com.mortals.xhx.modules.implementlist.model.ImplementlistEntity; import com.mortals.xhx.modules.implementlist.model.ImplementlistEntity;
import com.mortals.xhx.modules.implementlist.model.RybMatterListEntry;
import com.mortals.xhx.modules.implementlist.service.ImplementlistService; import com.mortals.xhx.modules.implementlist.service.ImplementlistService;
import com.mortals.xhx.modules.implementlist.service.RybMatterListService;
import com.mortals.xhx.modules.information.dao.InformationDao; import com.mortals.xhx.modules.information.dao.InformationDao;
import com.mortals.xhx.modules.information.model.InformationEntity; import com.mortals.xhx.modules.information.model.InformationEntity;
import com.mortals.xhx.modules.supplement.model.SupplementEntity; import com.mortals.xhx.modules.supplement.model.SupplementEntity;
...@@ -22,6 +25,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -22,6 +25,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
...@@ -43,9 +47,15 @@ public class SupplementTaskImpl implements ITaskExcuteService { ...@@ -43,9 +47,15 @@ public class SupplementTaskImpl implements ITaskExcuteService {
@Autowired @Autowired
private ImplementlistService implementlistService; private ImplementlistService implementlistService;
@Resource
private RybMatterListService rybMatterListService;
@Autowired @Autowired
private InformationDao informationDao; private InformationDao informationDao;
@Resource
private RybMatterDao rybMatterDao;
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
//TODO:因临时对接蓉易办暂时屏蔽,等后期蓉易办对接完成后放开 //TODO:因临时对接蓉易办暂时屏蔽,等后期蓉易办对接完成后放开
...@@ -53,7 +63,62 @@ public class SupplementTaskImpl implements ITaskExcuteService { ...@@ -53,7 +63,62 @@ public class SupplementTaskImpl implements ITaskExcuteService {
// List<SupplementEntity> supplementEntities = queryDataThatHasNotBeenPushed(task.getExcuteParam()); // List<SupplementEntity> supplementEntities = queryDataThatHasNotBeenPushed(task.getExcuteParam());
// //开始进行数据清洗 // //开始进行数据清洗
// this.dataCleaning(supplementEntities); // this.dataCleaning(supplementEntities);
this.temporaryDocking(); // this.temporaryDocking();
this.ryb();
}
//TODO:因临时对接蓉易办,后期可删除
private void ryb() {
SupplementQuery supplementQuery = new SupplementQuery();
supplementQuery.setIsExecute("0");
supplementQuery.setIsSuccess("0");
List<InformationEntity> informationQueries = new ArrayList<>();
List<SupplementEntity> supplementEntities = supplementService.find(supplementQuery, null);
if (!supplementEntities.isEmpty()) {
List<SupplementEntity> collect = supplementEntities.parallelStream().map(e -> {
//TODO:查询实施清单信息,通过事项编码查询有问题(但因数据库存储的事项数据是条件过滤后的,故暂时不改动查询),后期改动
RybMatterListEntry thImplement = rybMatterListService.getThImplement(e.getImplCode());
try {
InformationEntity informationQuery = new InformationEntity();
//组装第一次业务数据(清洗后的)
informationQuery = assemblyOfficeData(informationQuery, e);
if (null != thImplement) {
informationQuery.setDeptCode(thImplement.getDeptCode());
informationQuery.setEventCode(thImplement.getMatterCode());
informationQuery.setEventName(thImplement.getMatterName());
informationQuery.setAreaCode("510121");
//是否转化成功:0默认 1成功
informationQuery.setIsSuccess("1");
//是否推送(0 否 1是)
informationQuery.setIsReport("0");
//设置 失败次数 默认为0
informationQuery.setFailTimes(0);
// 是否执行转化(0.未执行 1.已执行)
e.setIsExecute("1");
//是否转化成功(0默认 1成功)
e.setIsSuccess("1");
} else {
e.setFailReason(" Err:实施清单不存在");
informationQuery.setFailReason(" Err:实施清单不存在");
informationQuery.setIsSuccess("0");
// 是否执行转化(0.未执行 1.已执行)
e.setIsExecute("1");
//是否转化成功(0默认 1成功)
e.setIsSuccess("0");
}
e.setUpdateDate(DateTime.now());
informationQueries.add(informationQuery);
return e;
} catch (Exception ex) {
e.setIsExecute("1");
log.error("转换失败:SupplementID:" + e.getId());
log.error("转换失败:失败原因" + ex.getMessage());
return e;
}
}).collect(Collectors.toList());
supplementService.update(collect, null);
informationDao.insertBatch(informationQueries);
}
} }
//TODO:因临时对接蓉易办,后期可删除 //TODO:因临时对接蓉易办,后期可删除
...@@ -63,7 +128,7 @@ public class SupplementTaskImpl implements ITaskExcuteService { ...@@ -63,7 +128,7 @@ public class SupplementTaskImpl implements ITaskExcuteService {
supplementQuery.setIsSuccess("0"); supplementQuery.setIsSuccess("0");
List<InformationEntity> informationQueries = new ArrayList<>(); List<InformationEntity> informationQueries = new ArrayList<>();
List<SupplementEntity> supplementEntities = supplementService.find(supplementQuery, null); List<SupplementEntity> supplementEntities = supplementService.find(supplementQuery, null);
if (!supplementEntities.isEmpty()){ if (!supplementEntities.isEmpty()) {
List<SupplementEntity> collect = supplementEntities.parallelStream().map(e -> { List<SupplementEntity> collect = supplementEntities.parallelStream().map(e -> {
//TODO:查询实施清单信息,通过事项编码查询有问题(但因数据库存储的事项数据是条件过滤后的,故暂时不改动查询),后期改动 //TODO:查询实施清单信息,通过事项编码查询有问题(但因数据库存储的事项数据是条件过滤后的,故暂时不改动查询),后期改动
ImplementlistEntity thImplement = implementlistService.getThImplement(e.getImplCode()); ImplementlistEntity thImplement = implementlistService.getThImplement(e.getImplCode());
...@@ -105,7 +170,7 @@ public class SupplementTaskImpl implements ITaskExcuteService { ...@@ -105,7 +170,7 @@ public class SupplementTaskImpl implements ITaskExcuteService {
return e; return e;
} }
}).collect(Collectors.toList()); }).collect(Collectors.toList());
supplementService.update(collect,null); supplementService.update(collect, null);
informationDao.insertBatch(informationQueries); informationDao.insertBatch(informationQueries);
} }
} }
...@@ -156,7 +221,7 @@ public class SupplementTaskImpl implements ITaskExcuteService { ...@@ -156,7 +221,7 @@ public class SupplementTaskImpl implements ITaskExcuteService {
return e; return e;
} }
}).collect(Collectors.toList()); }).collect(Collectors.toList());
supplementService.update(collect,null); supplementService.update(collect, null);
informationDao.insertBatch(informationQueries); informationDao.insertBatch(informationQueries);
} else { } else {
log.info("没有从临时表中获取到需要清洗的数据"); log.info("没有从临时表中获取到需要清洗的数据");
...@@ -238,7 +303,7 @@ public class SupplementTaskImpl implements ITaskExcuteService { ...@@ -238,7 +303,7 @@ public class SupplementTaskImpl implements ITaskExcuteService {
//当月第几天 //当月第几天
String theDayOfTheMonth = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); String theDayOfTheMonth = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
//每月第一天,去查询上月的数据是否存在未处理的数据 //每月第一天,去查询上月的数据是否存在未处理的数据
if (theFirstDayOfTheMonth.equals(theDayOfTheMonth)){ if (theFirstDayOfTheMonth.equals(theDayOfTheMonth)) {
//获取上月第一天的开始时间 //获取上月第一天的开始时间
supplementQuery.setCreateDateStart( supplementQuery.setCreateDateStart(
DateByAffairUtils.getLastMonthFirstDate(new Date(), new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").toPattern())); DateByAffairUtils.getLastMonthFirstDate(new Date(), new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").toPattern()));
...@@ -246,7 +311,7 @@ public class SupplementTaskImpl implements ITaskExcuteService { ...@@ -246,7 +311,7 @@ public class SupplementTaskImpl implements ITaskExcuteService {
supplementQuery.setCreateDateEnd( supplementQuery.setCreateDateEnd(
DateByAffairUtils.getLastMonthLastDate(new Date(), new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").toPattern())); DateByAffairUtils.getLastMonthLastDate(new Date(), new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").toPattern()));
try { try {
supplementEntities = supplementService.find(supplementQuery, pageInfo,null).getList(); supplementEntities = supplementService.find(supplementQuery, pageInfo, null).getList();
} catch (Exception e) { } catch (Exception e) {
log.info("报错属于业务正常,查询当月表数据"); log.info("报错属于业务正常,查询当月表数据");
supplementEntities = queryCurrentMonthTableData(supplementQuery, pageInfo); supplementEntities = queryCurrentMonthTableData(supplementQuery, pageInfo);
...@@ -255,9 +320,9 @@ public class SupplementTaskImpl implements ITaskExcuteService { ...@@ -255,9 +320,9 @@ public class SupplementTaskImpl implements ITaskExcuteService {
if (supplementEntities.size() <= 0) { if (supplementEntities.size() <= 0) {
supplementEntities = queryCurrentMonthTableData(supplementQuery, pageInfo); supplementEntities = queryCurrentMonthTableData(supplementQuery, pageInfo);
} }
}else { } else {
//上月未存在未处理的数据,则查询当月数据 //上月未存在未处理的数据,则查询当月数据
supplementEntities = queryCurrentMonthTableData(supplementQuery,pageInfo); supplementEntities = queryCurrentMonthTableData(supplementQuery, pageInfo);
} }
...@@ -271,7 +336,7 @@ public class SupplementTaskImpl implements ITaskExcuteService { ...@@ -271,7 +336,7 @@ public class SupplementTaskImpl implements ITaskExcuteService {
//获取当前时间 //获取当前时间
supplementQuery.setCreateDateEnd( supplementQuery.setCreateDateEnd(
DateUtils.convertTime2Str(new Date().getTime(), DateUtils.P_yyyy_MM_dd_HH_mm_ss)); DateUtils.convertTime2Str(new Date().getTime(), DateUtils.P_yyyy_MM_dd_HH_mm_ss));
return supplementService.find(supplementQuery, pageInfo,null).getList(); return supplementService.find(supplementQuery, pageInfo, null).getList();
} }
} }
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.mortals.xhx.modules.implementlist.dao.ibatis.RybMatterDaoImpl">
<select id="findRyb" resultType="com.mortals.xhx.modules.implementlist.model.RybMatterListEntry">
select
dept_code as deptCode,
dept_name as deptName,
matter_name as matterName,
matter_code as matterCode,
task_id as taskId,
matter_type as matterType,
create_time as createTime,
is_report as isReport,
is_success as isSuccess,
fail_times as failTimes,
fail_reason as failReason
from ryb_matter_list
where matter_code = #{eventCode}
</select>
<select id="insertRyb" parameterType="collection">
insert into values
<foreach collection="collection" item="entry" index=",">
(#{entry.deptCode},#{entry.deptName},#{entry.matterName},#{entry.matterCode},#{entry.taskId},#{entry.matterType},#{entry.createTime},#{entry.isReport},#{entry.isSuccess},#{entry.failTimes},#{entry.failReason})
</foreach>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment