Commit 232078e7 authored by shenxin's avatar shenxin

蓉易办推送数据

parent b853a39f
......@@ -17,6 +17,7 @@ public enum NodeTypeEnum {
受理("BusiType_1","11","受理"),
审查("BusiType_13","21","审查"),
决定("BusiType_8","41","决定"),
已提交("BusiType_12","61","已提交"),
办结("end","81","办结");
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
......@@ -10,8 +10,10 @@ import com.mortals.framework.util.DateUtils;
import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.common.code.NodeTypeEnum;
import com.mortals.xhx.common.utils.DateByAffairUtils;
import com.mortals.xhx.modules.implementlist.dao.RybMatterDao;
import com.mortals.xhx.modules.implementlist.model.ImplementlistEntity;
import com.mortals.xhx.modules.implementlist.model.ImplementlistQuery;
import com.mortals.xhx.modules.implementlist.model.RybMatterListEntry;
import com.mortals.xhx.modules.implementlist.service.ImplementlistService;
import com.mortals.xhx.modules.information.dao.InformationDao;
import com.mortals.xhx.modules.information.model.InformationEntity;
......@@ -45,6 +47,9 @@ public class InformationServiceImpl extends AbstractCRUDServiceImpl<InformationD
@Resource
private InformationService informationService;
@Resource
private RybMatterDao rybMatterDao;
@Autowired
private ImplementlistService implementlistService;
......@@ -76,12 +81,15 @@ public class InformationServiceImpl extends AbstractCRUDServiceImpl<InformationD
//默认区间3~20分钟
e.setCreateTime(DateByAffairUtils.getTimeByAddRandomDouble(DateTime.now(), null, null));
e.setOfficeCode(jsonObject.getJSONObject("data").getJSONObject("custom").getJSONObject("content").getString("flowsn"));
log.info("推送成功");
} else {
log.info("推送失败");
e.setIsReport("1");
e.setIsSuccess("0");
log.info("推送失败:"+jsonObject);
}
return e;
}).collect(Collectors.toList());
System.out.println(JSONArray.toJSONString(objects));
log.info(JSONArray.toJSONString(objects));
informationService.update(entities, null);
}
......@@ -104,26 +112,19 @@ public class InformationServiceImpl extends AbstractCRUDServiceImpl<InformationD
baseInfoMap.put("address", "地址暂无");
baseInfoMap.put("contactmobile", e.getContactPhone());
baseInfoMap.put("contactperson", e.getContactName());
HashMap<String, String> map = randomlyExtractPersonnelInformation();
if (null != map) {
baseInfoMap.put("receiveusername", map.get("receiveusername"));
baseInfoMap.put("receiveuserphone", map.get("receiveuserphone"));
baseInfoMap.put("receiveuseridcard", map.get("receiveuseridcard"));
}
baseInfoMap.putAll(randomlyExtractPersonnelInformation());
baseInfoMap.put("receivedate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(e.getCreateTime()));
ImplementlistQuery implementlistQuery = new ImplementlistQuery();
implementlistQuery.setEventCode(e.getEventCode());
ImplementlistEntity implementlistEntity = implementlistService.find(implementlistQuery, null).get(0);
if (null != implementlistEntity) {
baseInfoMap.put("tasktype", implementlistEntity.getEventType());
baseInfoMap.put("task_id", implementlistEntity.getId());
RybMatterListEntry entry = rybMatterDao.find(e.getEventCode()).get(0);
if (null != entry) {
baseInfoMap.put("tasktype", entry.getMatterType());
baseInfoMap.put("task_id", entry.getTaskId());
} else {
baseInfoMap.put("tasktype", "1A");
baseInfoMap.put("task_id", "123");
}
baseInfoMap.put("eventcode", implementlistEntity.getEventCode());
baseInfoMap.put("areacode", implementlistEntity.getAreaCode());
baseInfoMap.put("source", implementlistEntity.getAreaCode());
baseInfoMap.put("eventcode", entry.getMatterCode());
baseInfoMap.put("areacode", e.getAreaCode());
baseInfoMap.put("source", e.getAreaCode());
baseInfoMap.put("contactIdCard", e.getContactIdCard());
dataMap.put("params", baseInfoMap);
return dataMap;
......@@ -132,27 +133,103 @@ public class InformationServiceImpl extends AbstractCRUDServiceImpl<InformationD
private HashMap<String, String> randomlyExtractPersonnelInformation() {
HashMap<String, String> dataMap = new HashMap<>(16);
Random random = new Random();
int i = random.nextInt(5);
if (0 == i) {
dataMap.put("receiveusername","0");
dataMap.put("receiveuserphone","0");
dataMap.put("receiveuseridcard","0");
} else if (1 == i) {
dataMap.put("receiveusername","1");
dataMap.put("receiveuserphone","1");
dataMap.put("receiveuseridcard","1");
} else if (2 == i) {
dataMap.put("receiveusername","2");
dataMap.put("receiveuserphone","2");
dataMap.put("receiveuseridcard","2");
} else if (3 == i) {
dataMap.put("receiveusername","3");
dataMap.put("receiveuserphone","3");
dataMap.put("receiveuseridcard","3");
} else if (4 == i) {
dataMap.put("receiveusername","4");
dataMap.put("receiveuserphone","4");
dataMap.put("receiveuseridcard","4");
int i = random.nextInt(19);
switch (i){
case 0: {
dataMap.put("receiveusername","陈丽娜");
dataMap.put("receiveuseridcard","510121198605260045");
dataMap.put("receiveuserphone","13880461766");
};break;
case 1: {
dataMap.put("receiveusername","阳辉强");
dataMap.put("receiveuseridcard","510121199012101051");
dataMap.put("receiveuserphone","15882486917");
};break;
case 2: {
dataMap.put("receiveusername","陈雯");
dataMap.put("receiveuseridcard","510121198105266088");
dataMap.put("receiveuserphone","13551872266");
};break;
case 3: {
dataMap.put("receiveusername","李琳");
dataMap.put("receiveuseridcard","510121197308010029");
dataMap.put("receiveuserphone","13880367238");
};break;
case 4: {
dataMap.put("receiveusername","黄家玲");
dataMap.put("receiveuseridcard","511302199308260062");
dataMap.put("receiveuserphone","18111572752");
};break;
case 5: {
dataMap.put("receiveusername","张丁月");
dataMap.put("receiveuseridcard","510121199312101029");
dataMap.put("receiveuserphone","18111572752");
};break;
case 6: {
dataMap.put("receiveusername","廖鸥");
dataMap.put("receiveuseridcard","510121199410040020");
dataMap.put("receiveuserphone","13699070588");
};break;
case 7: {
dataMap.put("receiveusername","唐泽");
dataMap.put("receiveuseridcard","510121199503296076");
dataMap.put("receiveuserphone","15202806722");
};break;
case 8: {
dataMap.put("receiveusername","高玲");
dataMap.put("receiveuseridcard","510121199112256069");
dataMap.put("receiveuserphone","13608192679");
};break;
case 9: {
dataMap.put("receiveusername","胡红霞");
dataMap.put("receiveuseridcard","510121197907215288");
dataMap.put("receiveuserphone","18980958260");
};break;
case 10: {
dataMap.put("receiveusername","唐瑶");
dataMap.put("receiveuseridcard","510121199812318865");
dataMap.put("receiveuserphone","15228964765");
};break;
case 11: {
dataMap.put("receiveusername","陈雯");
dataMap.put("receiveuseridcard","510121198105266088");
dataMap.put("receiveuserphone","13551872266");
};break;
case 12: {
dataMap.put("receiveusername","曾华");
dataMap.put("receiveuseridcard","51012119711230122");
dataMap.put("receiveuserphone","13438829733");
};break;
case 13: {
dataMap.put("receiveusername","李琳");
dataMap.put("receiveuseridcard","510121197308010029");
dataMap.put("receiveuserphone","13880367238");
};break;
case 14: {
dataMap.put("receiveusername","肖开泉");
dataMap.put("receiveuseridcard","510121196810019219");
dataMap.put("receiveuserphone","15828660138");
};break;
case 15: {
dataMap.put("receiveusername","唐小芳");
dataMap.put("receiveuseridcard","510121199410114843");
dataMap.put("receiveuserphone","15881045053");
};break;
case 16: {
dataMap.put("receiveusername","王何");
dataMap.put("receiveuseridcard","510121197504040014");
dataMap.put("receiveuserphone","13880000262");
};break;
case 17: {
dataMap.put("receiveusername","肖毛毛");
dataMap.put("receiveuseridcard","510121199108300047");
dataMap.put("receiveuserphone","13668269394");
};break;
case 18: {
dataMap.put("receiveusername","蒋熙揆");
dataMap.put("receiveuseridcard","510921199206205215");
dataMap.put("receiveuserphone","17808253623");
};break;
}
return dataMap;
}
......@@ -162,20 +239,31 @@ public class InformationServiceImpl extends AbstractCRUDServiceImpl<InformationD
PageInfo pageInfo = new PageInfo();
pageInfo.setPrePageResult(100);
InformationQuery informationQuery = new InformationQuery();
informationQuery.setNodeType("BusiType_1");
informationQuery.setNodeType(NodeTypeEnum.办结.getCode());
informationQuery.setIsReport("1");
informationQuery.setIsSuccess("1");
List<InformationEntity> informationEntities = informationService.find(informationQuery, pageInfo, null).getList();
List<InformationEntity> entities = informationEntities.parallelStream().map(e -> {
List<InformationEntity> collect = informationEntities.parallelStream().map(e -> {
//组装参数
HashMap<String, Object> stringObjectHashMap = assemblyParametersLink(e);
HttpUtil
String appKey = HttpUtil
.createGet("https://171.221.172.95:4433/gateway/api/1/wllz/bjsqtjbsl/cs")
.body(JSONObject.toJSONString(stringObjectHashMap))
.header("AppKey", "743109085582327808")
.execute()
.charset("utf-8")
.body();
JSONObject jsonObject = JSONObject.parseObject(appKey);
e.setBizStatus(NodeTypeEnum.已提交.getDesc());
e.setNodeType(NodeTypeEnum.已提交.getCode());
if ("200".equals(jsonObject.getString("code"))) {
log.info("提交成功");
} else {
log.info("提交失败:" + jsonObject);
}
return e;
}).collect(Collectors.toList());
informationService.update(collect,null);
}
private HashMap<String, Object> assemblyParametersLink(InformationEntity e) {
......@@ -186,9 +274,7 @@ public class InformationServiceImpl extends AbstractCRUDServiceImpl<InformationD
baseInfoMap.put("operatetype", "80");
baseInfoMap.put("startdate", e.getGenTime());
baseInfoMap.put("enddate", e.getCompleteTime());
baseInfoMap.put("operateusername", "");
baseInfoMap.put("operateuserphone", "");
baseInfoMap.put("operateuseridcard", "");
baseInfoMap.putAll(randomlyExtractPersonnelInformation());
baseInfoMap.put("areacode", e.getAreaCode());
baseInfoMap.put("handleTime", e.getCreateTime());
baseInfoMap.put("nodeStatus", "1");
......
......@@ -11,8 +11,11 @@ import com.mortals.xhx.common.code.NodeTypeEnum;
import com.mortals.xhx.common.utils.DateByAffairUtils;
import com.mortals.xhx.common.utils.FilterSuppDataUtils;
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.RybMatterListEntry;
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.model.InformationEntity;
import com.mortals.xhx.modules.supplement.model.SupplementEntity;
......@@ -22,6 +25,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
......@@ -43,9 +47,15 @@ public class SupplementTaskImpl implements ITaskExcuteService {
@Autowired
private ImplementlistService implementlistService;
@Resource
private RybMatterListService rybMatterListService;
@Autowired
private InformationDao informationDao;
@Resource
private RybMatterDao rybMatterDao;
@Override
public void excuteTask(ITask task) throws AppException {
//TODO:因临时对接蓉易办暂时屏蔽,等后期蓉易办对接完成后放开
......@@ -53,7 +63,62 @@ public class SupplementTaskImpl implements ITaskExcuteService {
// List<SupplementEntity> supplementEntities = queryDataThatHasNotBeenPushed(task.getExcuteParam());
// //开始进行数据清洗
// 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:因临时对接蓉易办,后期可删除
......@@ -63,7 +128,7 @@ public class SupplementTaskImpl implements ITaskExcuteService {
supplementQuery.setIsSuccess("0");
List<InformationEntity> informationQueries = new ArrayList<>();
List<SupplementEntity> supplementEntities = supplementService.find(supplementQuery, null);
if (!supplementEntities.isEmpty()){
if (!supplementEntities.isEmpty()) {
List<SupplementEntity> collect = supplementEntities.parallelStream().map(e -> {
//TODO:查询实施清单信息,通过事项编码查询有问题(但因数据库存储的事项数据是条件过滤后的,故暂时不改动查询),后期改动
ImplementlistEntity thImplement = implementlistService.getThImplement(e.getImplCode());
......@@ -105,7 +170,7 @@ public class SupplementTaskImpl implements ITaskExcuteService {
return e;
}
}).collect(Collectors.toList());
supplementService.update(collect,null);
supplementService.update(collect, null);
informationDao.insertBatch(informationQueries);
}
}
......@@ -156,7 +221,7 @@ public class SupplementTaskImpl implements ITaskExcuteService {
return e;
}
}).collect(Collectors.toList());
supplementService.update(collect,null);
supplementService.update(collect, null);
informationDao.insertBatch(informationQueries);
} else {
log.info("没有从临时表中获取到需要清洗的数据");
......@@ -238,7 +303,7 @@ public class SupplementTaskImpl implements ITaskExcuteService {
//当月第几天
String theDayOfTheMonth = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
//每月第一天,去查询上月的数据是否存在未处理的数据
if (theFirstDayOfTheMonth.equals(theDayOfTheMonth)){
if (theFirstDayOfTheMonth.equals(theDayOfTheMonth)) {
//获取上月第一天的开始时间
supplementQuery.setCreateDateStart(
DateByAffairUtils.getLastMonthFirstDate(new Date(), new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").toPattern()));
......@@ -246,7 +311,7 @@ public class SupplementTaskImpl implements ITaskExcuteService {
supplementQuery.setCreateDateEnd(
DateByAffairUtils.getLastMonthLastDate(new Date(), new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").toPattern()));
try {
supplementEntities = supplementService.find(supplementQuery, pageInfo,null).getList();
supplementEntities = supplementService.find(supplementQuery, pageInfo, null).getList();
} catch (Exception e) {
log.info("报错属于业务正常,查询当月表数据");
supplementEntities = queryCurrentMonthTableData(supplementQuery, pageInfo);
......@@ -255,9 +320,9 @@ public class SupplementTaskImpl implements ITaskExcuteService {
if (supplementEntities.size() <= 0) {
supplementEntities = queryCurrentMonthTableData(supplementQuery, pageInfo);
}
}else {
} else {
//上月未存在未处理的数据,则查询当月数据
supplementEntities = queryCurrentMonthTableData(supplementQuery,pageInfo);
supplementEntities = queryCurrentMonthTableData(supplementQuery, pageInfo);
}
......@@ -271,7 +336,7 @@ public class SupplementTaskImpl implements ITaskExcuteService {
//获取当前时间
supplementQuery.setCreateDateEnd(
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